From 2873c3f0e2bd12a7612e905c920c058855f4072a Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Thu, 24 May 2018 16:37:46 -0400 Subject: [PATCH 001/903] iio: 104-quad-8: Fix off-by-one error in register selection The reset flags operation is selected by bit 2 in the "Reset and Load Signals Decoders" register, not bit 1. Fixes: 28e5d3bb0325 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8") Signed-off-by: William Breathitt Gray Signed-off-by: Jonathan Cameron --- drivers/iio/counter/104-quad-8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c index b56985078d8c..4be85ec54af4 100644 --- a/drivers/iio/counter/104-quad-8.c +++ b/drivers/iio/counter/104-quad-8.c @@ -138,7 +138,7 @@ static int quad8_write_raw(struct iio_dev *indio_dev, outb(val >> (8 * i), base_offset); /* Reset Borrow, Carry, Compare, and Sign flags */ - outb(0x02, base_offset + 1); + outb(0x04, base_offset + 1); /* Reset Error flag */ outb(0x06, base_offset + 1); From c2c8406b315f7606175b85e9ac1b4fc0972c917f Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 25 May 2018 17:34:23 +0200 Subject: [PATCH 002/903] iio: adc: sun4i-gpadc: select REGMAP_IRQ We can't call regmap_irq_get_virq() unless the regmap-irq support is enabled: drivers/iio/adc/sun4i-gpadc-iio.o: In function `sun4i_irq_init': sun4i-gpadc-iio.c:(.text+0x59c): undefined reference to `regmap_irq_get_virq' I came across this in a randconfig build now, but I guess this is a much older problem that I simply never hit before because regmap_irq is usually enabled by one of the other drivers that need it. Fixes: d1caa9905538 ("iio: adc: add support for Allwinner SoCs ADC") Signed-off-by: Arnd Bergmann Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 9da79070357c..13922b595503 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -717,6 +717,7 @@ config SUN4I_GPADC depends on IIO depends on MFD_SUN4I_GPADC || MACH_SUN8I depends on THERMAL || !THERMAL_OF + select REGMAP_IRQ help Say yes here to build support for Allwinner (A10, A13 and A31) SoCs GPADC. This ADC provides 4 channels which can be used as an ADC or as From 3ca4fb431b83faaeb9476d10f394882e135a3d83 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Maneyrol Date: Tue, 22 May 2018 16:18:18 +0200 Subject: [PATCH 003/903] iio: imu: inv_mpu6050: replace timestamp fifo by generic timestamp Using a fifo for storing timestamps is useless since the interrupt is in one-shot mode, preventing the hard irq handler to be called when the irq thread is running. Instead use the generic timestamp function iio_pollfunc_store_time. Signed-off-by: Jean-Baptiste Maneyrol Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 +-- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 10 ----- drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 44 +--------------------- 3 files changed, 2 insertions(+), 58 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index f9c0624505a2..08937a6d59db 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include #include #include @@ -1003,7 +1001,7 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, indio_dev->modes = INDIO_BUFFER_TRIGGERED; result = devm_iio_triggered_buffer_setup(dev, indio_dev, - inv_mpu6050_irq_handler, + iio_pollfunc_store_time, inv_mpu6050_read_fifo, NULL); if (result) { @@ -1016,8 +1014,6 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, return result; } - INIT_KFIFO(st->timestamps); - spin_lock_init(&st->time_stamp_lock); result = devm_iio_device_register(dev, indio_dev); if (result) { dev_err(dev, "IIO register fail %d\n", result); diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index c54da777945d..a92ddd45586c 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -12,8 +12,6 @@ */ #include #include -#include -#include #include #include #include @@ -116,36 +114,30 @@ struct inv_mpu6050_hw { /* * struct inv_mpu6050_state - Driver state variables. - * @TIMESTAMP_FIFO_SIZE: fifo size for timestamp. * @lock: Chip access lock. * @trig: IIO trigger. * @chip_config: Cached attribute information. * @reg: Map of important registers. * @hw: Other hardware-specific information. * @chip_type: chip type. - * @time_stamp_lock: spin lock to time stamp. * @plat_data: platform data (deprecated in favor of @orientation). * @orientation: sensor chip orientation relative to main hardware. - * @timestamps: kfifo queue to store time stamp. * @map regmap pointer. * @irq interrupt number. * @irq_mask the int_pin_cfg mask to configure interrupt type. */ struct inv_mpu6050_state { -#define TIMESTAMP_FIFO_SIZE 16 struct mutex lock; struct iio_trigger *trig; struct inv_mpu6050_chip_config chip_config; const struct inv_mpu6050_reg_map *reg; const struct inv_mpu6050_hw *hw; enum inv_devices chip_type; - spinlock_t time_stamp_lock; struct i2c_mux_core *muxc; struct i2c_client *mux_client; unsigned int powerup_count; struct inv_mpu6050_platform_data plat_data; struct iio_mount_matrix orientation; - DECLARE_KFIFO(timestamps, long long, TIMESTAMP_FIFO_SIZE); struct regmap *map; int irq; u8 irq_mask; @@ -234,7 +226,6 @@ struct inv_mpu6050_state { /* init parameters */ #define INV_MPU6050_INIT_FIFO_RATE 50 -#define INV_MPU6050_TIME_STAMP_TOR 5 #define INV_MPU6050_MAX_FIFO_RATE 1000 #define INV_MPU6050_MIN_FIFO_RATE 4 #define INV_MPU6050_ONE_K_HZ 1000 @@ -300,7 +291,6 @@ enum inv_mpu6050_clock_sel_e { NUM_CLK }; -irqreturn_t inv_mpu6050_irq_handler(int irq, void *p); irqreturn_t inv_mpu6050_read_fifo(int irq, void *p); int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev, int irq_type); int inv_reset_fifo(struct iio_dev *indio_dev); diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 1795418438e4..5436d181f2dc 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -19,20 +19,9 @@ #include #include #include -#include #include #include "inv_mpu_iio.h" -static void inv_clear_kfifo(struct inv_mpu6050_state *st) -{ - unsigned long flags; - - /* take the spin lock sem to avoid interrupt kick in */ - spin_lock_irqsave(&st->time_stamp_lock, flags); - kfifo_reset(&st->timestamps); - spin_unlock_irqrestore(&st->time_stamp_lock, flags); -} - int inv_reset_fifo(struct iio_dev *indio_dev) { int result; @@ -62,9 +51,6 @@ int inv_reset_fifo(struct iio_dev *indio_dev) if (result) goto reset_fifo_fail; - /* clear timestamps fifo */ - inv_clear_kfifo(st); - /* enable interrupt */ if (st->chip_config.accl_fifo_enable || st->chip_config.gyro_fifo_enable) { @@ -98,23 +84,6 @@ reset_fifo_fail: return result; } -/** - * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. - */ -irqreturn_t inv_mpu6050_irq_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct inv_mpu6050_state *st = iio_priv(indio_dev); - s64 timestamp; - - timestamp = iio_get_time_ns(indio_dev); - kfifo_in_spinlocked(&st->timestamps, ×tamp, 1, - &st->time_stamp_lock); - - return IRQ_WAKE_THREAD; -} - /** * inv_mpu6050_read_fifo() - Transfer data from hardware FIFO to KFIFO. */ @@ -127,7 +96,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) int result; u8 data[INV_MPU6050_OUTPUT_DATA_SIZE]; u16 fifo_count; - s64 timestamp; + s64 timestamp = pf->timestamp; int int_status; mutex_lock(&st->lock); @@ -171,28 +140,17 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) goto flush_fifo; if (fifo_count > INV_MPU6050_FIFO_THRESHOLD) goto flush_fifo; - /* Timestamp mismatch. */ - if (kfifo_len(&st->timestamps) > - fifo_count / bytes_per_datum + INV_MPU6050_TIME_STAMP_TOR) - goto flush_fifo; do { result = regmap_bulk_read(st->map, st->reg->fifo_r_w, data, bytes_per_datum); if (result) goto flush_fifo; - - result = kfifo_out(&st->timestamps, ×tamp, 1); - /* when there is no timestamp, put timestamp as 0 */ - if (result == 0) - timestamp = 0; - /* skip first samples if needed */ if (st->skip_samples) st->skip_samples--; else iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); - fifo_count -= bytes_per_datum; } while (fifo_count >= bytes_per_datum); From 7b782508f829d39f30a80250935974e8f77c173a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Maneyrol Date: Tue, 22 May 2018 16:18:19 +0200 Subject: [PATCH 004/903] iio: imu: inv_mpu6050: switch to use sample rate divider Instead of storing fifo rate in Hz, store the chip internal sample rate divider. This will be more useful for timestamping. There are both equivalent. Signed-off-by: Jean-Baptiste Maneyrol Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 18 +++++++++++------- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 08937a6d59db..f50477c360e2 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -82,7 +82,7 @@ static const struct inv_mpu6050_reg_map reg_set_6050 = { static const struct inv_mpu6050_chip_config chip_config_6050 = { .fsr = INV_MPU6050_FSR_2000DPS, .lpf = INV_MPU6050_FILTER_20HZ, - .fifo_rate = INV_MPU6050_INIT_FIFO_RATE, + .divider = INV_MPU6050_FIFO_RATE_TO_DIVIDER(INV_MPU6050_INIT_FIFO_RATE), .gyro_fifo_enable = false, .accl_fifo_enable = false, .accl_fs = INV_MPU6050_FS_02G, @@ -278,7 +278,7 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev) if (result) goto error_power_off; - d = INV_MPU6050_ONE_K_HZ / INV_MPU6050_INIT_FIFO_RATE - 1; + d = INV_MPU6050_FIFO_RATE_TO_DIVIDER(INV_MPU6050_INIT_FIFO_RATE); result = regmap_write(st->map, st->reg->sample_rate_div, d); if (result) goto error_power_off; @@ -628,7 +628,7 @@ static ssize_t inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - s32 fifo_rate; + int fifo_rate; u8 d; int result; struct iio_dev *indio_dev = dev_to_iio_dev(dev); @@ -644,8 +644,13 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr, if (result) return result; + /* compute the chip sample rate divider */ + d = INV_MPU6050_FIFO_RATE_TO_DIVIDER(fifo_rate); + /* compute back the fifo rate to handle truncation cases */ + fifo_rate = INV_MPU6050_DIVIDER_TO_FIFO_RATE(d); + mutex_lock(&st->lock); - if (fifo_rate == st->chip_config.fifo_rate) { + if (d == st->chip_config.divider) { result = 0; goto fifo_rate_fail_unlock; } @@ -653,11 +658,10 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr, if (result) goto fifo_rate_fail_unlock; - d = INV_MPU6050_ONE_K_HZ / fifo_rate - 1; result = regmap_write(st->map, st->reg->sample_rate_div, d); if (result) goto fifo_rate_fail_power_off; - st->chip_config.fifo_rate = fifo_rate; + st->chip_config.divider = d; result = inv_mpu6050_set_lpf(st, fifo_rate); if (result) @@ -685,7 +689,7 @@ inv_fifo_rate_show(struct device *dev, struct device_attribute *attr, unsigned fifo_rate; mutex_lock(&st->lock); - fifo_rate = st->chip_config.fifo_rate; + fifo_rate = INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider); mutex_unlock(&st->lock); return scnprintf(buf, PAGE_SIZE, "%u\n", fifo_rate); diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index a92ddd45586c..a1130b9a420c 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -86,7 +86,7 @@ enum inv_devices { * @accl_fs: accel full scale range. * @accl_fifo_enable: enable accel data output * @gyro_fifo_enable: enable gyro data output - * @fifo_rate: FIFO update rate. + * @divider: chip sample rate divider (sample rate divider - 1) */ struct inv_mpu6050_chip_config { unsigned int fsr:2; @@ -94,7 +94,7 @@ struct inv_mpu6050_chip_config { unsigned int accl_fs:2; unsigned int accl_fifo_enable:1; unsigned int gyro_fifo_enable:1; - u16 fifo_rate; + u8 divider; u8 user_ctrl; }; @@ -228,7 +228,17 @@ struct inv_mpu6050_state { #define INV_MPU6050_INIT_FIFO_RATE 50 #define INV_MPU6050_MAX_FIFO_RATE 1000 #define INV_MPU6050_MIN_FIFO_RATE 4 -#define INV_MPU6050_ONE_K_HZ 1000 + +/* chip internal frequency: 1KHz */ +#define INV_MPU6050_INTERNAL_FREQ_HZ 1000 +/* return the frequency divider (chip sample rate divider + 1) */ +#define INV_MPU6050_FREQ_DIVIDER(st) \ + ((st)->chip_config.divider + 1) +/* chip sample rate divider to fifo rate */ +#define INV_MPU6050_FIFO_RATE_TO_DIVIDER(fifo_rate) \ + ((INV_MPU6050_INTERNAL_FREQ_HZ / (fifo_rate)) - 1) +#define INV_MPU6050_DIVIDER_TO_FIFO_RATE(divider) \ + (INV_MPU6050_INTERNAL_FREQ_HZ / ((divider) + 1)) #define INV_MPU6050_REG_WHOAMI 117 From 5cba7caaacfb842c4326959315f2817897711f53 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Maneyrol Date: Tue, 22 May 2018 16:18:20 +0200 Subject: [PATCH 005/903] iio: imu: inv_mpu6050: fix fifo count reading Use unaligned access since buffer is a bytes table. Truncate fifo count to read only complete datum. Signed-off-by: Jean-Baptiste Maneyrol Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 5436d181f2dc..7724888a4696 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "inv_mpu_iio.h" int inv_reset_fifo(struct iio_dev *indio_dev) @@ -98,6 +99,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) u16 fifo_count; s64 timestamp = pf->timestamp; int int_status; + size_t i, nb; mutex_lock(&st->lock); @@ -132,27 +134,23 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) INV_MPU6050_FIFO_COUNT_BYTE); if (result) goto end_session; - fifo_count = be16_to_cpup((__be16 *)(&data[0])); - if (fifo_count < bytes_per_datum) - goto end_session; - /* fifo count can't be an odd number. If it is odd, reset the FIFO. */ - if (fifo_count & 1) - goto flush_fifo; + fifo_count = get_unaligned_be16(&data[0]); if (fifo_count > INV_MPU6050_FIFO_THRESHOLD) goto flush_fifo; - do { + /* compute and process all complete datum */ + nb = fifo_count / bytes_per_datum; + for (i = 0; i < nb; ++i) { result = regmap_bulk_read(st->map, st->reg->fifo_r_w, data, bytes_per_datum); if (result) goto flush_fifo; /* skip first samples if needed */ - if (st->skip_samples) + if (st->skip_samples) { st->skip_samples--; - else - iio_push_to_buffers_with_timestamp(indio_dev, data, - timestamp); - fifo_count -= bytes_per_datum; - } while (fifo_count >= bytes_per_datum); + continue; + } + iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); + } end_session: mutex_unlock(&st->lock); From f5057e7b2dba4c33ed293196d75cb139d5014715 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Maneyrol Date: Tue, 22 May 2018 16:18:21 +0200 Subject: [PATCH 006/903] iio: imu: inv_mpu6050: better fifo overflow handling Use fifo overflow bit from int status rather than using an arbitrary threshold. Signed-off-by: Jean-Baptiste Maneyrol Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index a1130b9a420c..6bc80ac9d120 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -166,6 +166,7 @@ struct inv_mpu6050_state { #define INV_MPU6050_REG_RAW_GYRO 0x43 #define INV_MPU6050_REG_INT_STATUS 0x3A +#define INV_MPU6050_BIT_FIFO_OVERFLOW_INT 0x10 #define INV_MPU6050_BIT_RAW_DATA_RDY_INT 0x01 #define INV_MPU6050_REG_USER_CTRL 0x6A @@ -190,7 +191,6 @@ struct inv_mpu6050_state { #define INV_MPU6050_BYTES_PER_3AXIS_SENSOR 6 #define INV_MPU6050_FIFO_COUNT_BYTE 2 -#define INV_MPU6050_FIFO_THRESHOLD 500 /* mpu6500 registers */ #define INV_MPU6500_REG_ACCEL_CONFIG_2 0x1D diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 7724888a4696..7a4aaed83044 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -110,6 +110,9 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) "failed to ack interrupt\n"); goto flush_fifo; } + /* handle fifo overflow by reseting fifo */ + if (int_status & INV_MPU6050_BIT_FIFO_OVERFLOW_INT) + goto flush_fifo; if (!(int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT)) { dev_warn(regmap_get_device(st->map), "spurious interrupt with status 0x%x\n", int_status); @@ -135,8 +138,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) if (result) goto end_session; fifo_count = get_unaligned_be16(&data[0]); - if (fifo_count > INV_MPU6050_FIFO_THRESHOLD) - goto flush_fifo; /* compute and process all complete datum */ nb = fifo_count / bytes_per_datum; for (i = 0; i < nb; ++i) { From 17f0361936a5bdeb4958813b1c5542fdc91de925 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Sun, 27 May 2018 13:18:43 -0400 Subject: [PATCH 007/903] iio: 104-quad-8: Provide defines for magic numbers This patch adds several register and bit defines to help improve the clarity of the code by cleaning up magic numbers throughout the driver. Signed-off-by: William Breathitt Gray Signed-off-by: Jonathan Cameron --- drivers/iio/counter/104-quad-8.c | 87 ++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c index 4be85ec54af4..92be8d0f7735 100644 --- a/drivers/iio/counter/104-quad-8.c +++ b/drivers/iio/counter/104-quad-8.c @@ -59,6 +59,39 @@ struct quad8_iio { unsigned int base; }; +#define QUAD8_REG_CHAN_OP 0x11 +#define QUAD8_REG_INDEX_INPUT_LEVELS 0x16 +/* Borrow Toggle flip-flop */ +#define QUAD8_FLAG_BT BIT(0) +/* Carry Toggle flip-flop */ +#define QUAD8_FLAG_CT BIT(1) +/* Error flag */ +#define QUAD8_FLAG_E BIT(4) +/* Up/Down flag */ +#define QUAD8_FLAG_UD BIT(5) +/* Reset and Load Signal Decoders */ +#define QUAD8_CTR_RLD 0x00 +/* Counter Mode Register */ +#define QUAD8_CTR_CMR 0x20 +/* Input / Output Control Register */ +#define QUAD8_CTR_IOR 0x40 +/* Index Control Register */ +#define QUAD8_CTR_IDR 0x60 +/* Reset Byte Pointer (three byte data pointer) */ +#define QUAD8_RLD_RESET_BP 0x01 +/* Reset Counter */ +#define QUAD8_RLD_RESET_CNTR 0x02 +/* Reset Borrow Toggle, Carry Toggle, Compare Toggle, and Sign flags */ +#define QUAD8_RLD_RESET_FLAGS 0x04 +/* Reset Error flag */ +#define QUAD8_RLD_RESET_E 0x06 +/* Preset Register to Counter */ +#define QUAD8_RLD_PRESET_CNTR 0x08 +/* Transfer Counter to Output Latch */ +#define QUAD8_RLD_CNTR_OUT 0x10 +#define QUAD8_CHAN_OP_ENABLE_COUNTERS 0x00 +#define QUAD8_CHAN_OP_RESET_COUNTERS 0x01 + static int quad8_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { @@ -72,19 +105,21 @@ static int quad8_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: if (chan->type == IIO_INDEX) { - *val = !!(inb(priv->base + 0x16) & BIT(chan->channel)); + *val = !!(inb(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) + & BIT(chan->channel)); return IIO_VAL_INT; } flags = inb(base_offset + 1); - borrow = flags & BIT(0); - carry = !!(flags & BIT(1)); + borrow = flags & QUAD8_FLAG_BT; + carry = !!(flags & QUAD8_FLAG_CT); /* Borrow XOR Carry effectively doubles count range */ *val = (borrow ^ carry) << 24; /* Reset Byte Pointer; transfer Counter to Output Latch */ - outb(0x11, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, + base_offset + 1); for (i = 0; i < 3; i++) *val |= (unsigned int)inb(base_offset) << (8 * i); @@ -120,17 +155,17 @@ static int quad8_write_raw(struct iio_dev *indio_dev, return -EINVAL; /* Reset Byte Pointer */ - outb(0x01, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); /* Counter can only be set via Preset Register */ for (i = 0; i < 3; i++) outb(val >> (8 * i), base_offset); /* Transfer Preset Register to Counter */ - outb(0x08, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1); /* Reset Byte Pointer */ - outb(0x01, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); /* Set Preset Register back to original value */ val = priv->preset[chan->channel]; @@ -138,9 +173,9 @@ static int quad8_write_raw(struct iio_dev *indio_dev, outb(val >> (8 * i), base_offset); /* Reset Borrow, Carry, Compare, and Sign flags */ - outb(0x04, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); /* Reset Error flag */ - outb(0x06, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); return 0; case IIO_CHAN_INFO_ENABLE: @@ -153,7 +188,7 @@ static int quad8_write_raw(struct iio_dev *indio_dev, ior_cfg = val | priv->preset_enable[chan->channel] << 1; /* Load I/O control configuration */ - outb(0x40 | ior_cfg, base_offset + 1); + outb(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); return 0; case IIO_CHAN_INFO_SCALE: @@ -217,7 +252,7 @@ static ssize_t quad8_write_preset(struct iio_dev *indio_dev, uintptr_t private, priv->preset[chan->channel] = preset; /* Reset Byte Pointer */ - outb(0x01, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); /* Set Preset Register */ for (i = 0; i < 3; i++) @@ -258,7 +293,7 @@ static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev, (unsigned int)preset_enable << 1; /* Load I/O control configuration to Input / Output Control Register */ - outb(0x40 | ior_cfg, base_offset); + outb(QUAD8_CTR_IOR | ior_cfg, base_offset); return len; } @@ -274,7 +309,7 @@ static int quad8_get_noise_error(struct iio_dev *indio_dev, struct quad8_iio *const priv = iio_priv(indio_dev); const int base_offset = priv->base + 2 * chan->channel + 1; - return !!(inb(base_offset) & BIT(4)); + return !!(inb(base_offset) & QUAD8_FLAG_E); } static const struct iio_enum quad8_noise_error_enum = { @@ -294,7 +329,7 @@ static int quad8_get_count_direction(struct iio_dev *indio_dev, struct quad8_iio *const priv = iio_priv(indio_dev); const int base_offset = priv->base + 2 * chan->channel + 1; - return !!(inb(base_offset) & BIT(5)); + return !!(inb(base_offset) & QUAD8_FLAG_UD); } static const struct iio_enum quad8_count_direction_enum = { @@ -324,7 +359,7 @@ static int quad8_set_count_mode(struct iio_dev *indio_dev, mode_cfg |= (priv->quadrature_scale[chan->channel] + 1) << 3; /* Load mode configuration to Counter Mode Register */ - outb(0x20 | mode_cfg, base_offset); + outb(QUAD8_CTR_CMR | mode_cfg, base_offset); return 0; } @@ -364,7 +399,7 @@ static int quad8_set_synchronous_mode(struct iio_dev *indio_dev, priv->synchronous_mode[chan->channel] = synchronous_mode; /* Load Index Control configuration to Index Control Register */ - outb(0x60 | idr_cfg, base_offset); + outb(QUAD8_CTR_IDR | idr_cfg, base_offset); return 0; } @@ -410,7 +445,7 @@ static int quad8_set_quadrature_mode(struct iio_dev *indio_dev, priv->quadrature_mode[chan->channel] = quadrature_mode; /* Load mode configuration to Counter Mode Register */ - outb(0x20 | mode_cfg, base_offset); + outb(QUAD8_CTR_CMR | mode_cfg, base_offset); return 0; } @@ -446,7 +481,7 @@ static int quad8_set_index_polarity(struct iio_dev *indio_dev, priv->index_polarity[chan->channel] = index_polarity; /* Load Index Control configuration to Index Control Register */ - outb(0x60 | idr_cfg, base_offset); + outb(QUAD8_CTR_IDR | idr_cfg, base_offset); return 0; } @@ -556,28 +591,28 @@ static int quad8_probe(struct device *dev, unsigned int id) priv->base = base[id]; /* Reset all counters and disable interrupt function */ - outb(0x01, base[id] + 0x11); + outb(QUAD8_CHAN_OP_RESET_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); /* Set initial configuration for all counters */ for (i = 0; i < QUAD8_NUM_COUNTERS; i++) { base_offset = base[id] + 2 * i; /* Reset Byte Pointer */ - outb(0x01, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); /* Reset Preset Register */ for (j = 0; j < 3; j++) outb(0x00, base_offset); /* Reset Borrow, Carry, Compare, and Sign flags */ - outb(0x04, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); /* Reset Error flag */ - outb(0x06, base_offset + 1); + outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); /* Binary encoding; Normal count; non-quadrature mode */ - outb(0x20, base_offset + 1); + outb(QUAD8_CTR_CMR, base_offset + 1); /* Disable A and B inputs; preset on index; FLG1 as Carry */ - outb(0x40, base_offset + 1); + outb(QUAD8_CTR_IOR, base_offset + 1); /* Disable index function; negative index polarity */ - outb(0x60, base_offset + 1); + outb(QUAD8_CTR_IDR, base_offset + 1); } /* Enable all counters */ - outb(0x00, base[id] + 0x11); + outb(QUAD8_CHAN_OP_ENABLE_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); return devm_iio_device_register(dev, indio_dev); } From 4bcc19f1b218983be841a319a3a506f2e446c6b5 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Maneyrol Date: Mon, 28 May 2018 15:22:04 +0200 Subject: [PATCH 008/903] iio: imu: inv_mpu6050: new timestamp mechanism Check validity of interrupt timestamps by computing time between 2 interrupts. If it matches the chip frequency modulo 4%, it is used as the data timestamp and also for estimating the chip frequency measured from the system. Otherwise timestamp is computed using the estimated chip frequency. Signed-off-by: Jean-Baptiste Maneyrol Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 8 +++ drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 82 +++++++++++++++++++++- 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index f50477c360e2..de68e83fc52d 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -295,6 +295,13 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev) memcpy(&st->chip_config, hw_info[st->chip_type].config, sizeof(struct inv_mpu6050_chip_config)); + /* + * Internal chip period is 1ms (1kHz). + * Let's use at the beginning the theorical value before measuring + * with interrupt timestamps. + */ + st->chip_period = NSEC_PER_MSEC; + return inv_mpu6050_set_power_itg(st, false); error_power_off: diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index 6bc80ac9d120..de8391693e17 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -125,6 +125,9 @@ struct inv_mpu6050_hw { * @map regmap pointer. * @irq interrupt number. * @irq_mask the int_pin_cfg mask to configure interrupt type. + * @chip_period: chip internal period estimation (~1kHz). + * @it_timestamp: timestamp from previous interrupt. + * @data_timestamp: timestamp for next data sample. */ struct inv_mpu6050_state { struct mutex lock; @@ -142,6 +145,9 @@ struct inv_mpu6050_state { int irq; u8 irq_mask; unsigned skip_samples; + s64 chip_period; + s64 it_timestamp; + s64 data_timestamp; }; /*register and associated bit definition*/ @@ -223,6 +229,8 @@ struct inv_mpu6050_state { #define INV_MPU6050_LATCH_INT_EN 0x20 #define INV_MPU6050_BIT_BYPASS_EN 0x2 +/* Allowed timestamp period jitter in percent */ +#define INV_MPU6050_TS_PERIOD_JITTER 4 /* init parameters */ #define INV_MPU6050_INIT_FIFO_RATE 50 diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 7a4aaed83044..548e042f7b5b 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -20,15 +20,93 @@ #include #include #include +#include #include #include "inv_mpu_iio.h" +/** + * inv_mpu6050_update_period() - Update chip internal period estimation + * + * @st: driver state + * @timestamp: the interrupt timestamp + * @nb: number of data set in the fifo + * + * This function uses interrupt timestamps to estimate the chip period and + * to choose the data timestamp to come. + */ +static void inv_mpu6050_update_period(struct inv_mpu6050_state *st, + s64 timestamp, size_t nb) +{ + /* Period boundaries for accepting timestamp */ + const s64 period_min = + (NSEC_PER_MSEC * (100 - INV_MPU6050_TS_PERIOD_JITTER)) / 100; + const s64 period_max = + (NSEC_PER_MSEC * (100 + INV_MPU6050_TS_PERIOD_JITTER)) / 100; + const s32 divider = INV_MPU6050_FREQ_DIVIDER(st); + s64 delta, interval; + bool use_it_timestamp = false; + + if (st->it_timestamp == 0) { + /* not initialized, forced to use it_timestamp */ + use_it_timestamp = true; + } else if (nb == 1) { + /* + * Validate the use of it timestamp by checking if interrupt + * has been delayed. + * nb > 1 means interrupt was delayed for more than 1 sample, + * so it's obviously not good. + * Compute the chip period between 2 interrupts for validating. + */ + delta = div_s64(timestamp - st->it_timestamp, divider); + if (delta > period_min && delta < period_max) { + /* update chip period and use it timestamp */ + st->chip_period = (st->chip_period + delta) / 2; + use_it_timestamp = true; + } + } + + if (use_it_timestamp) { + /* + * Manage case of multiple samples in the fifo (nb > 1): + * compute timestamp corresponding to the first sample using + * estimated chip period. + */ + interval = (nb - 1) * st->chip_period * divider; + st->data_timestamp = timestamp - interval; + } + + /* save it timestamp */ + st->it_timestamp = timestamp; +} + +/** + * inv_mpu6050_get_timestamp() - Return the current data timestamp + * + * @st: driver state + * @return: current data timestamp + * + * This function returns the current data timestamp and prepares for next one. + */ +static s64 inv_mpu6050_get_timestamp(struct inv_mpu6050_state *st) +{ + s64 ts; + + /* return current data timestamp and increment */ + ts = st->data_timestamp; + st->data_timestamp += st->chip_period * INV_MPU6050_FREQ_DIVIDER(st); + + return ts; +} + int inv_reset_fifo(struct iio_dev *indio_dev) { int result; u8 d; struct inv_mpu6050_state *st = iio_priv(indio_dev); + /* reset it timestamp validation */ + st->it_timestamp = 0; + /* disable interrupt */ result = regmap_write(st->map, st->reg->int_enable, 0); if (result) { @@ -97,7 +175,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) int result; u8 data[INV_MPU6050_OUTPUT_DATA_SIZE]; u16 fifo_count; - s64 timestamp = pf->timestamp; + s64 timestamp; int int_status; size_t i, nb; @@ -140,6 +218,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) fifo_count = get_unaligned_be16(&data[0]); /* compute and process all complete datum */ nb = fifo_count / bytes_per_datum; + inv_mpu6050_update_period(st, pf->timestamp, nb); for (i = 0; i < nb; ++i) { result = regmap_bulk_read(st->map, st->reg->fifo_r_w, data, bytes_per_datum); @@ -150,6 +229,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) st->skip_samples--; continue; } + timestamp = inv_mpu6050_get_timestamp(st); iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); } From adca2d68d70410b4a4266c2879cdfab05874c397 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 May 2018 14:45:01 +0100 Subject: [PATCH 009/903] staging: iio: Drop ADIS16060 driver from staging This part has been declared "not for new designs". It is now difficult to obtain and we have had no-one come forward with hardware making it difficult to proceed with the necessary work to move this driver out of staging. The device uses two separate chip selects and would require locking between them which is thought to be difficult to enforce without non trivial changes in the SPI subsystem. This work simply isn't worth doing given the status of the part and the fact no one seems to have gone for a similar hardware design since this one. If anyone does have access to one of these and is willing to contribute the time necessary then we can reevaluate dropping the driver. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/Kconfig | 1 - drivers/staging/iio/Makefile | 1 - drivers/staging/iio/gyro/Kconfig | 16 -- drivers/staging/iio/gyro/Makefile | 6 - drivers/staging/iio/gyro/adis16060_core.c | 234 ---------------------- 5 files changed, 258 deletions(-) delete mode 100644 drivers/staging/iio/gyro/Kconfig delete mode 100644 drivers/staging/iio/gyro/Makefile delete mode 100644 drivers/staging/iio/gyro/adis16060_core.c diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index aee2335a25a1..e86ac9e47867 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -9,7 +9,6 @@ source "drivers/staging/iio/adc/Kconfig" source "drivers/staging/iio/addac/Kconfig" source "drivers/staging/iio/cdc/Kconfig" source "drivers/staging/iio/frequency/Kconfig" -source "drivers/staging/iio/gyro/Kconfig" source "drivers/staging/iio/impedance-analyzer/Kconfig" source "drivers/staging/iio/meter/Kconfig" source "drivers/staging/iio/resolver/Kconfig" diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index c28d657497de..b15904b99581 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -8,7 +8,6 @@ obj-y += adc/ obj-y += addac/ obj-y += cdc/ obj-y += frequency/ -obj-y += gyro/ obj-y += impedance-analyzer/ obj-y += meter/ obj-y += resolver/ diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig deleted file mode 100644 index f62f68fd6f3f..000000000000 --- a/drivers/staging/iio/gyro/Kconfig +++ /dev/null @@ -1,16 +0,0 @@ -# -# IIO Digital Gyroscope Sensor drivers configuration -# -menu "Digital gyroscope sensors" - -config ADIS16060 - tristate "Analog Devices ADIS16060 Yaw Rate Gyroscope with SPI driver" - depends on SPI - help - Say Y (yes) here to build support for Analog Devices adis16060 wide bandwidth - yaw rate gyroscope with SPI. - - To compile this driver as a module, say M here: the module will be - called adis16060. If unsure, say N. - -endmenu diff --git a/drivers/staging/iio/gyro/Makefile b/drivers/staging/iio/gyro/Makefile deleted file mode 100644 index cf22d6d55e27..000000000000 --- a/drivers/staging/iio/gyro/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# -# Makefile for digital gyroscope sensor drivers -# - -adis16060-y := adis16060_core.o -obj-$(CONFIG_ADIS16060) += adis16060.o diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c deleted file mode 100644 index 4e7630caf7d3..000000000000 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * ADIS16060 Wide Bandwidth Yaw Rate Gyroscope with SPI driver - * - * Copyright 2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define ADIS16060_GYRO 0x20 /* Measure Angular Rate (Gyro) */ -#define ADIS16060_TEMP_OUT 0x10 /* Measure Temperature */ -#define ADIS16060_AIN2 0x80 /* Measure AIN2 */ -#define ADIS16060_AIN1 0x40 /* Measure AIN1 */ - -/** - * struct adis16060_state - device instance specific data - * @us_w: actual spi_device to write config - * @us_r: actual spi_device to read back data - * @buf: transmit or receive buffer - * @buf_lock: mutex to protect tx and rx - **/ -struct adis16060_state { - struct spi_device *us_w; - struct spi_device *us_r; - struct mutex buf_lock; - - u8 buf[3] ____cacheline_aligned; -}; - -static struct iio_dev *adis16060_iio_dev; - -static int adis16060_spi_write_then_read(struct iio_dev *indio_dev, - u8 conf, u16 *val) -{ - int ret; - struct adis16060_state *st = iio_priv(indio_dev); - - mutex_lock(&st->buf_lock); - st->buf[2] = conf; /* The last 8 bits clocked in are latched */ - ret = spi_write(st->us_w, st->buf, 3); - - if (ret < 0) { - mutex_unlock(&st->buf_lock); - return ret; - } - - ret = spi_read(st->us_r, st->buf, 3); - - /* The internal successive approximation ADC begins the - * conversion process on the falling edge of MSEL1 and - * starts to place data MSB first on the DOUT line at - * the 6th falling edge of SCLK - */ - if (!ret) - *val = ((st->buf[0] & 0x3) << 12) | - (st->buf[1] << 4) | - ((st->buf[2] >> 4) & 0xF); - mutex_unlock(&st->buf_lock); - - return ret; -} - -static int adis16060_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, int *val2, - long mask) -{ - u16 tval = 0; - int ret; - - switch (mask) { - case IIO_CHAN_INFO_RAW: - ret = adis16060_spi_write_then_read(indio_dev, - chan->address, &tval); - if (ret < 0) - return ret; - - *val = tval; - return IIO_VAL_INT; - case IIO_CHAN_INFO_OFFSET: - *val = -7; - *val2 = 461117; - return IIO_VAL_INT_PLUS_MICRO; - case IIO_CHAN_INFO_SCALE: - *val = 0; - *val2 = 34000; - return IIO_VAL_INT_PLUS_MICRO; - } - - return -EINVAL; -} - -static const struct iio_info adis16060_info = { - .read_raw = adis16060_read_raw, -}; - -static const struct iio_chan_spec adis16060_channels[] = { - { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .address = ADIS16060_GYRO, - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .address = ADIS16060_AIN1, - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .address = ADIS16060_AIN2, - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE), - .address = ADIS16060_TEMP_OUT, - } -}; - -static int adis16060_r_probe(struct spi_device *spi) -{ - int ret; - struct adis16060_state *st; - struct iio_dev *indio_dev; - - /* setup the industrialio driver allocated elements */ - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (!indio_dev) - return -ENOMEM; - /* this is only used for removal purposes */ - spi_set_drvdata(spi, indio_dev); - st = iio_priv(indio_dev); - st->us_r = spi; - mutex_init(&st->buf_lock); - - indio_dev->name = spi->dev.driver->name; - indio_dev->dev.parent = &spi->dev; - indio_dev->info = &adis16060_info; - indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = adis16060_channels; - indio_dev->num_channels = ARRAY_SIZE(adis16060_channels); - - ret = devm_iio_device_register(&spi->dev, indio_dev); - if (ret) - return ret; - - adis16060_iio_dev = indio_dev; - return 0; -} - -static int adis16060_w_probe(struct spi_device *spi) -{ - int ret; - struct iio_dev *indio_dev = adis16060_iio_dev; - struct adis16060_state *st; - - if (!indio_dev) { - ret = -ENODEV; - goto error_ret; - } - st = iio_priv(indio_dev); - spi_set_drvdata(spi, indio_dev); - st->us_w = spi; - return 0; - -error_ret: - return ret; -} - -static int adis16060_w_remove(struct spi_device *spi) -{ - return 0; -} - -static struct spi_driver adis16060_r_driver = { - .driver = { - .name = "adis16060_r", - }, - .probe = adis16060_r_probe, -}; - -static struct spi_driver adis16060_w_driver = { - .driver = { - .name = "adis16060_w", - }, - .probe = adis16060_w_probe, - .remove = adis16060_w_remove, -}; - -static __init int adis16060_init(void) -{ - int ret; - - ret = spi_register_driver(&adis16060_r_driver); - if (ret < 0) - return ret; - - ret = spi_register_driver(&adis16060_w_driver); - if (ret < 0) { - spi_unregister_driver(&adis16060_r_driver); - return ret; - } - - return 0; -} -module_init(adis16060_init); - -static __exit void adis16060_exit(void) -{ - spi_unregister_driver(&adis16060_w_driver); - spi_unregister_driver(&adis16060_r_driver); -} -module_exit(adis16060_exit); - -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); -MODULE_DESCRIPTION("Analog Devices ADIS16060 Yaw Rate Gyroscope Driver"); -MODULE_LICENSE("GPL v2"); From d22cd4dd6677274df30a38149891524dde8859f3 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Tue, 22 May 2018 10:52:31 +0300 Subject: [PATCH 010/903] MAINTAINERS: add generic resistive touchscreen adc Add MAINTAINERS entry for generic resistive touchscreen adc Signed-off-by: Eugen Hristev Signed-off-by: Jonathan Cameron --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3aa1f81922ff..8db4875b1fa9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6004,6 +6004,12 @@ F: drivers/base/power/domain*.c F: include/linux/pm_domain.h F: Documentation/devicetree/bindings/power/power_domain.txt +GENERIC RESISTIVE TOUCHSCREEN ADC DRIVER +M: Eugen Hristev +L: linux-input@vger.kernel.org +S: Maintained +F: drivers/input/touchscreen/resistive-adc-touch.c + GENERIC UIO DRIVER FOR PCI DEVICES M: "Michael S. Tsirkin" L: kvm@vger.kernel.org From 3055a6cfa04ba4288589778925e8838261e56078 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Tue, 22 May 2018 10:52:32 +0300 Subject: [PATCH 011/903] iio: Add channel for Position Relative Add new channel type for relative position on a pad. These type of analog sensor offers the position of a pen on a touchpad, and is represented as a voltage, which can be converted to a position on X and Y axis on the pad. The channel will hand the relative position on the pad in both directions. The channel can then be consumed by a touchscreen driver or read as-is for a raw indication of the touchpen on a touchpad. Signed-off-by: Eugen Hristev Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 12 ++++++++++++ drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + tools/iio/iio_event_monitor.c | 2 ++ 4 files changed, 16 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 731146c3b138..c7353030670a 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -197,6 +197,18 @@ Description: Angle of rotation. Units after application of scale and offset are radians. +What: /sys/bus/iio/devices/iio:deviceX/in_positionrelative_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_positionrelative_y_raw +KernelVersion: 4.18 +Contact: linux-iio@vger.kernel.org +Description: + Relative position in direction x or y on a pad (may be + arbitrarily assigned but should match other such assignments on + device). + Units after application of scale and offset are milli percents + from the pad's size in both directions. Should be calibrated by + the consumer. + What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 19bdf3d2962a..14bf3d243cb1 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -85,6 +85,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_COUNT] = "count", [IIO_INDEX] = "index", [IIO_GRAVITY] = "gravity", + [IIO_POSITIONRELATIVE] = "positionrelative", }; static const char * const iio_modifier_names[] = { diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index 4213cdf88e3c..033c7d28924e 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -44,6 +44,7 @@ enum iio_chan_type { IIO_COUNT, IIO_INDEX, IIO_GRAVITY, + IIO_POSITIONRELATIVE, }; enum iio_modifier { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index b61245e1181d..148f69dfae75 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -58,6 +58,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_PH] = "ph", [IIO_UVINDEX] = "uvindex", [IIO_GRAVITY] = "gravity", + [IIO_POSITIONRELATIVE] = "positionrelative", }; static const char * const iio_ev_type_text[] = { @@ -151,6 +152,7 @@ static bool event_is_known(struct iio_event_data *event) case IIO_PH: case IIO_UVINDEX: case IIO_GRAVITY: + case IIO_POSITIONRELATIVE: break; default: return false; From 15e20eabd7f9c857a005a34be642829dd8229538 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Tue, 22 May 2018 10:52:33 +0300 Subject: [PATCH 012/903] dt-bindings: input: touchscreen: add minimum pressure touchscreen property Add a common touchscreen optional property that will specify the minimum pressure applied to the screen that is needed such that the driver will report the touch event. Signed-off-by: Eugen Hristev Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/input/touchscreen/touchscreen.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt index 537643e86f61..d092d5d033a0 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt @@ -7,6 +7,9 @@ Optional properties for Touchscreens: (in pixels) - touchscreen-max-pressure : maximum reported pressure (arbitrary range dependent on the controller) + - touchscreen-min-pressure : minimum pressure on the touchscreen to be + achieved in order for the touchscreen + driver to report a touch event. - touchscreen-fuzz-x : horizontal noise value of the absolute input device (in pixels) - touchscreen-fuzz-y : vertical noise value of the absolute input From 1b5bd7d25c7826bb2cc56ff4e9e41a4bdfd8f7a8 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Tue, 22 May 2018 10:52:34 +0300 Subject: [PATCH 013/903] dt-bindings: input: touchscreen: resistive-adc-touch: create bindings Added bindings for generic resistive touchscreen ADC. Signed-off-by: Eugen Hristev Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../input/touchscreen/resistive-adc-touch.txt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/resistive-adc-touch.txt diff --git a/Documentation/devicetree/bindings/input/touchscreen/resistive-adc-touch.txt b/Documentation/devicetree/bindings/input/touchscreen/resistive-adc-touch.txt new file mode 100644 index 000000000000..51456c0e9a27 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/resistive-adc-touch.txt @@ -0,0 +1,30 @@ +Generic resistive touchscreen ADC + +Required properties: + + - compatible: must be "resistive-adc-touch" +The device must be connected to an ADC device that provides channels for +position measurement and optional pressure. +Refer to ../iio/iio-bindings.txt for details + - iio-channels: must have at least two channels connected to an ADC device. +These should correspond to the channels exposed by the ADC device and should +have the right index as the ADC device registers them. These channels +represent the relative position on the "x" and "y" axes. + - iio-channel-names: must have all the channels' names. Mandatory channels +are "x" and "y". + +Optional properties: + - iio-channels: The third channel named "pressure" is optional and can be +used if the ADC device also measures pressure besides position. +If this channel is missing, pressure will be ignored and the touchscreen +will only report position. + - iio-channel-names: optional channel named "pressure". + +Example: + + resistive_touch: resistive_touch { + compatible = "resistive-adc-touch"; + touchscreen-min-pressure = <50000>; + io-channels = <&adc 24>, <&adc 25>, <&adc 26>; + io-channel-names = "x", "y", "pressure"; + }; From 23ec2774f1cc168b1f32a2e0ed2709cb473bb94e Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Tue, 22 May 2018 10:52:35 +0300 Subject: [PATCH 014/903] iio: adc: at91-sama5d2_adc: add support for position and pressure channels This implements the support for position and pressure for the included touchscreen support in the SAMA5D2 SOC ADC block. Two position channels are added and one for pressure. They can be read in raw format, or through a buffer. A normal use case is for a consumer driver to register a callback buffer for these channels. When the touchscreen channels are in the active scan mask, the driver will start the touchscreen sampling and push the data to the buffer. Some parts of this patch are based on initial original work by Mohamed Jamsheeth Hajanajubudeen and Bandaru Venkateswara Swamy Signed-off-by: Eugen Hristev Acked-by: Ludovic Desroches Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 617 ++++++++++++++++++++++++++--- 1 file changed, 555 insertions(+), 62 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 8729d6524b4d..58c4c2b4fe11 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -102,14 +102,26 @@ #define AT91_SAMA5D2_LCDR 0x20 /* Interrupt Enable Register */ #define AT91_SAMA5D2_IER 0x24 +/* Interrupt Enable Register - TS X measurement ready */ +#define AT91_SAMA5D2_IER_XRDY BIT(20) +/* Interrupt Enable Register - TS Y measurement ready */ +#define AT91_SAMA5D2_IER_YRDY BIT(21) +/* Interrupt Enable Register - TS pressure measurement ready */ +#define AT91_SAMA5D2_IER_PRDY BIT(22) /* Interrupt Enable Register - general overrun error */ #define AT91_SAMA5D2_IER_GOVRE BIT(25) +/* Interrupt Enable Register - Pen detect */ +#define AT91_SAMA5D2_IER_PEN BIT(29) +/* Interrupt Enable Register - No pen detect */ +#define AT91_SAMA5D2_IER_NOPEN BIT(30) /* Interrupt Disable Register */ #define AT91_SAMA5D2_IDR 0x28 /* Interrupt Mask Register */ #define AT91_SAMA5D2_IMR 0x2c /* Interrupt Status Register */ #define AT91_SAMA5D2_ISR 0x30 +/* Interrupt Status Register - Pen touching sense status */ +#define AT91_SAMA5D2_ISR_PENS BIT(31) /* Last Channel Trigger Mode Register */ #define AT91_SAMA5D2_LCTMR 0x34 /* Last Channel Compare Window Register */ @@ -131,8 +143,38 @@ #define AT91_SAMA5D2_CDR0 0x50 /* Analog Control Register */ #define AT91_SAMA5D2_ACR 0x94 +/* Analog Control Register - Pen detect sensitivity mask */ +#define AT91_SAMA5D2_ACR_PENDETSENS_MASK GENMASK(1, 0) + /* Touchscreen Mode Register */ #define AT91_SAMA5D2_TSMR 0xb0 +/* Touchscreen Mode Register - No touch mode */ +#define AT91_SAMA5D2_TSMR_TSMODE_NONE 0 +/* Touchscreen Mode Register - 4 wire screen, no pressure measurement */ +#define AT91_SAMA5D2_TSMR_TSMODE_4WIRE_NO_PRESS 1 +/* Touchscreen Mode Register - 4 wire screen, pressure measurement */ +#define AT91_SAMA5D2_TSMR_TSMODE_4WIRE_PRESS 2 +/* Touchscreen Mode Register - 5 wire screen */ +#define AT91_SAMA5D2_TSMR_TSMODE_5WIRE 3 +/* Touchscreen Mode Register - Average samples mask */ +#define AT91_SAMA5D2_TSMR_TSAV_MASK GENMASK(5, 4) +/* Touchscreen Mode Register - Average samples */ +#define AT91_SAMA5D2_TSMR_TSAV(x) ((x) << 4) +/* Touchscreen Mode Register - Touch/trigger frequency ratio mask */ +#define AT91_SAMA5D2_TSMR_TSFREQ_MASK GENMASK(11, 8) +/* Touchscreen Mode Register - Touch/trigger frequency ratio */ +#define AT91_SAMA5D2_TSMR_TSFREQ(x) ((x) << 8) +/* Touchscreen Mode Register - Pen Debounce Time mask */ +#define AT91_SAMA5D2_TSMR_PENDBC_MASK GENMASK(31, 28) +/* Touchscreen Mode Register - Pen Debounce Time */ +#define AT91_SAMA5D2_TSMR_PENDBC(x) ((x) << 28) +/* Touchscreen Mode Register - No DMA for touch measurements */ +#define AT91_SAMA5D2_TSMR_NOTSDMA BIT(22) +/* Touchscreen Mode Register - Disable pen detection */ +#define AT91_SAMA5D2_TSMR_PENDET_DIS (0 << 24) +/* Touchscreen Mode Register - Enable pen detection */ +#define AT91_SAMA5D2_TSMR_PENDET_ENA BIT(24) + /* Touchscreen X Position Register */ #define AT91_SAMA5D2_XPOSR 0xb4 /* Touchscreen Y Position Register */ @@ -151,6 +193,12 @@ #define AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_FALL 2 /* Trigger Mode external trigger any edge */ #define AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_ANY 3 +/* Trigger Mode internal periodic */ +#define AT91_SAMA5D2_TRGR_TRGMOD_PERIODIC 5 +/* Trigger Mode - trigger period mask */ +#define AT91_SAMA5D2_TRGR_TRGPER_MASK GENMASK(31, 16) +/* Trigger Mode - trigger period */ +#define AT91_SAMA5D2_TRGR_TRGPER(x) ((x) << 16) /* Correction Select Register */ #define AT91_SAMA5D2_COSR 0xd0 @@ -169,6 +217,22 @@ #define AT91_SAMA5D2_SINGLE_CHAN_CNT 12 #define AT91_SAMA5D2_DIFF_CHAN_CNT 6 +#define AT91_SAMA5D2_TIMESTAMP_CHAN_IDX (AT91_SAMA5D2_SINGLE_CHAN_CNT + \ + AT91_SAMA5D2_DIFF_CHAN_CNT + 1) + +#define AT91_SAMA5D2_TOUCH_X_CHAN_IDX (AT91_SAMA5D2_SINGLE_CHAN_CNT + \ + AT91_SAMA5D2_DIFF_CHAN_CNT * 2) +#define AT91_SAMA5D2_TOUCH_Y_CHAN_IDX (AT91_SAMA5D2_TOUCH_X_CHAN_IDX + 1) +#define AT91_SAMA5D2_TOUCH_P_CHAN_IDX (AT91_SAMA5D2_TOUCH_Y_CHAN_IDX + 1) +#define AT91_SAMA5D2_MAX_CHAN_IDX AT91_SAMA5D2_TOUCH_P_CHAN_IDX + +#define AT91_SAMA5D2_TOUCH_SAMPLE_PERIOD_US 2000 /* 2ms */ +#define AT91_SAMA5D2_TOUCH_PEN_DETECT_DEBOUNCE_US 200 + +#define AT91_SAMA5D2_XYZ_MASK GENMASK(11, 0) + +#define AT91_SAMA5D2_MAX_POS_BITS 12 + /* * Maximum number of bytes to hold conversion from all channels * without the timestamp. @@ -222,6 +286,37 @@ .indexed = 1, \ } +#define AT91_SAMA5D2_CHAN_TOUCH(num, name, mod) \ + { \ + .type = IIO_POSITIONRELATIVE, \ + .modified = 1, \ + .channel = num, \ + .channel2 = mod, \ + .scan_index = num, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 12, \ + .storagebits = 16, \ + }, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\ + .datasheet_name = name, \ + } +#define AT91_SAMA5D2_CHAN_PRESSURE(num, name) \ + { \ + .type = IIO_PRESSURE, \ + .channel = num, \ + .scan_index = num, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 12, \ + .storagebits = 16, \ + }, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\ + .datasheet_name = name, \ + } + #define at91_adc_readl(st, reg) readl_relaxed(st->base + reg) #define at91_adc_writel(st, reg, val) writel_relaxed(val, st->base + reg) @@ -260,6 +355,22 @@ struct at91_adc_dma { s64 dma_ts; }; +/** + * at91_adc_touch - at91-sama5d2 touchscreen information struct + * @sample_period_val: the value for periodic trigger interval + * @touching: is the pen touching the screen or not + * @x_pos: temporary placeholder for pressure computation + * @channels_bitmask: bitmask with the touchscreen channels enabled + * @workq: workqueue for buffer data pushing + */ +struct at91_adc_touch { + u16 sample_period_val; + bool touching; + u16 x_pos; + unsigned long channels_bitmask; + struct work_struct workq; +}; + struct at91_adc_state { void __iomem *base; int irq; @@ -267,6 +378,7 @@ struct at91_adc_state { struct regulator *reg; struct regulator *vref; int vref_uv; + unsigned int current_sample_rate; struct iio_trigger *trig; const struct at91_adc_trigger *selected_trig; const struct iio_chan_spec *chan; @@ -275,6 +387,7 @@ struct at91_adc_state { struct at91_adc_soc_info soc_info; wait_queue_head_t wq_data_available; struct at91_adc_dma dma_st; + struct at91_adc_touch touch_st; u16 buffer[AT91_BUFFER_MAX_HWORDS]; /* * lock to prevent concurrent 'single conversion' requests through @@ -329,8 +442,10 @@ static const struct iio_chan_spec at91_adc_channels[] = { AT91_SAMA5D2_CHAN_DIFF(6, 7, 0x68), AT91_SAMA5D2_CHAN_DIFF(8, 9, 0x70), AT91_SAMA5D2_CHAN_DIFF(10, 11, 0x78), - IIO_CHAN_SOFT_TIMESTAMP(AT91_SAMA5D2_SINGLE_CHAN_CNT - + AT91_SAMA5D2_DIFF_CHAN_CNT + 1), + IIO_CHAN_SOFT_TIMESTAMP(AT91_SAMA5D2_TIMESTAMP_CHAN_IDX), + AT91_SAMA5D2_CHAN_TOUCH(AT91_SAMA5D2_TOUCH_X_CHAN_IDX, "x", IIO_MOD_X), + AT91_SAMA5D2_CHAN_TOUCH(AT91_SAMA5D2_TOUCH_Y_CHAN_IDX, "y", IIO_MOD_Y), + AT91_SAMA5D2_CHAN_PRESSURE(AT91_SAMA5D2_TOUCH_P_CHAN_IDX, "pressure"), }; static int at91_adc_chan_xlate(struct iio_dev *indio_dev, int chan) @@ -354,6 +469,160 @@ at91_adc_chan_get(struct iio_dev *indio_dev, int chan) return indio_dev->channels + index; } +static inline int at91_adc_of_xlate(struct iio_dev *indio_dev, + const struct of_phandle_args *iiospec) +{ + return at91_adc_chan_xlate(indio_dev, iiospec->args[0]); +} + +static int at91_adc_configure_touch(struct at91_adc_state *st, bool state) +{ + u32 clk_khz = st->current_sample_rate / 1000; + int i = 0; + u16 pendbc; + u32 tsmr, acr; + + if (!state) { + /* disabling touch IRQs and setting mode to no touch enabled */ + at91_adc_writel(st, AT91_SAMA5D2_IDR, + AT91_SAMA5D2_IER_PEN | AT91_SAMA5D2_IER_NOPEN); + at91_adc_writel(st, AT91_SAMA5D2_TSMR, 0); + return 0; + } + /* + * debounce time is in microseconds, we need it in milliseconds to + * multiply with kilohertz, so, divide by 1000, but after the multiply. + * round up to make sure pendbc is at least 1 + */ + pendbc = round_up(AT91_SAMA5D2_TOUCH_PEN_DETECT_DEBOUNCE_US * + clk_khz / 1000, 1); + + /* get the required exponent */ + while (pendbc >> i++) + ; + + pendbc = i; + + tsmr = AT91_SAMA5D2_TSMR_TSMODE_4WIRE_PRESS; + + tsmr |= AT91_SAMA5D2_TSMR_TSAV(2) & AT91_SAMA5D2_TSMR_TSAV_MASK; + tsmr |= AT91_SAMA5D2_TSMR_PENDBC(pendbc) & + AT91_SAMA5D2_TSMR_PENDBC_MASK; + tsmr |= AT91_SAMA5D2_TSMR_NOTSDMA; + tsmr |= AT91_SAMA5D2_TSMR_PENDET_ENA; + tsmr |= AT91_SAMA5D2_TSMR_TSFREQ(2) & AT91_SAMA5D2_TSMR_TSFREQ_MASK; + + at91_adc_writel(st, AT91_SAMA5D2_TSMR, tsmr); + + acr = at91_adc_readl(st, AT91_SAMA5D2_ACR); + acr &= ~AT91_SAMA5D2_ACR_PENDETSENS_MASK; + acr |= 0x02 & AT91_SAMA5D2_ACR_PENDETSENS_MASK; + at91_adc_writel(st, AT91_SAMA5D2_ACR, acr); + + /* Sample Period Time = (TRGPER + 1) / ADCClock */ + st->touch_st.sample_period_val = + round_up((AT91_SAMA5D2_TOUCH_SAMPLE_PERIOD_US * + clk_khz / 1000) - 1, 1); + /* enable pen detect IRQ */ + at91_adc_writel(st, AT91_SAMA5D2_IER, AT91_SAMA5D2_IER_PEN); + + return 0; +} + +static u16 at91_adc_touch_pos(struct at91_adc_state *st, int reg) +{ + u32 val; + u32 scale, result, pos; + + /* + * to obtain the actual position we must divide by scale + * and multiply with max, where + * max = 2^AT91_SAMA5D2_MAX_POS_BITS - 1 + */ + /* first half of register is the x or y, second half is the scale */ + val = at91_adc_readl(st, reg); + if (!val) + dev_dbg(&iio_priv_to_dev(st)->dev, "pos is 0\n"); + + pos = val & AT91_SAMA5D2_XYZ_MASK; + result = (pos << AT91_SAMA5D2_MAX_POS_BITS) - pos; + scale = (val >> 16) & AT91_SAMA5D2_XYZ_MASK; + if (scale == 0) { + dev_err(&iio_priv_to_dev(st)->dev, "scale is 0\n"); + return 0; + } + result /= scale; + + return result; +} + +static u16 at91_adc_touch_x_pos(struct at91_adc_state *st) +{ + st->touch_st.x_pos = at91_adc_touch_pos(st, AT91_SAMA5D2_XPOSR); + return st->touch_st.x_pos; +} + +static u16 at91_adc_touch_y_pos(struct at91_adc_state *st) +{ + return at91_adc_touch_pos(st, AT91_SAMA5D2_YPOSR); +} + +static u16 at91_adc_touch_pressure(struct at91_adc_state *st) +{ + u32 val; + u32 z1, z2; + u32 pres; + u32 rxp = 1; + u32 factor = 1000; + + /* calculate the pressure */ + val = at91_adc_readl(st, AT91_SAMA5D2_PRESSR); + z1 = val & AT91_SAMA5D2_XYZ_MASK; + z2 = (val >> 16) & AT91_SAMA5D2_XYZ_MASK; + + if (z1 != 0) + pres = rxp * (st->touch_st.x_pos * factor / 1024) * + (z2 * factor / z1 - factor) / + factor; + else + pres = 0xFFFF; /* no pen contact */ + + /* + * The pressure from device grows down, minimum is 0xFFFF, maximum 0x0. + * We compute it this way, but let's return it in the expected way, + * growing from 0 to 0xFFFF. + */ + return 0xFFFF - pres; +} + +static int at91_adc_read_position(struct at91_adc_state *st, int chan, u16 *val) +{ + *val = 0; + if (!st->touch_st.touching) + return -ENODATA; + if (chan == AT91_SAMA5D2_TOUCH_X_CHAN_IDX) + *val = at91_adc_touch_x_pos(st); + else if (chan == AT91_SAMA5D2_TOUCH_Y_CHAN_IDX) + *val = at91_adc_touch_y_pos(st); + else + return -ENODATA; + + return IIO_VAL_INT; +} + +static int at91_adc_read_pressure(struct at91_adc_state *st, int chan, u16 *val) +{ + *val = 0; + if (!st->touch_st.touching) + return -ENODATA; + if (chan == AT91_SAMA5D2_TOUCH_P_CHAN_IDX) + *val = at91_adc_touch_pressure(st); + else + return -ENODATA; + + return IIO_VAL_INT; +} + static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) { struct iio_dev *indio = iio_trigger_get_drvdata(trig); @@ -375,6 +644,11 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) if (!chan) continue; + /* these channel types cannot be handled by this trigger */ + if (chan->type == IIO_POSITIONRELATIVE || + chan->type == IIO_PRESSURE) + continue; + if (state) { at91_adc_writel(st, AT91_SAMA5D2_CHER, BIT(chan->channel)); @@ -520,7 +794,20 @@ static int at91_adc_dma_start(struct iio_dev *indio_dev) static int at91_adc_buffer_postenable(struct iio_dev *indio_dev) { int ret; + struct at91_adc_state *st = iio_priv(indio_dev); + /* check if we are enabling triggered buffer or the touchscreen */ + if (bitmap_subset(indio_dev->active_scan_mask, + &st->touch_st.channels_bitmask, + AT91_SAMA5D2_MAX_CHAN_IDX + 1)) { + /* touchscreen enabling */ + return at91_adc_configure_touch(st, true); + } + /* if we are not in triggered mode, we cannot enable the buffer. */ + if (!(indio_dev->currentmode & INDIO_ALL_TRIGGERED_MODES)) + return -EINVAL; + + /* we continue with the triggered buffer */ ret = at91_adc_dma_start(indio_dev); if (ret) { dev_err(&indio_dev->dev, "buffer postenable failed\n"); @@ -536,6 +823,18 @@ static int at91_adc_buffer_predisable(struct iio_dev *indio_dev) int ret; u8 bit; + /* check if we are disabling triggered buffer or the touchscreen */ + if (bitmap_subset(indio_dev->active_scan_mask, + &st->touch_st.channels_bitmask, + AT91_SAMA5D2_MAX_CHAN_IDX + 1)) { + /* touchscreen disable */ + return at91_adc_configure_touch(st, false); + } + /* if we are not in triggered mode, nothing to do here */ + if (!(indio_dev->currentmode & INDIO_ALL_TRIGGERED_MODES)) + return -EINVAL; + + /* continue with the triggered buffer */ ret = iio_triggered_buffer_predisable(indio_dev); if (ret < 0) dev_err(&indio_dev->dev, "buffer predisable failed\n"); @@ -558,6 +857,10 @@ static int at91_adc_buffer_predisable(struct iio_dev *indio_dev) if (!chan) continue; + /* these channel types are virtual, no need to do anything */ + if (chan->type == IIO_POSITIONRELATIVE || + chan->type == IIO_PRESSURE) + continue; if (st->dma_st.dma_chan) at91_adc_readl(st, chan->address); } @@ -622,7 +925,22 @@ static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev, if (!chan) continue; - st->buffer[i] = at91_adc_readl(st, chan->address); + /* + * Our external trigger only supports the voltage channels. + * In case someone requested a different type of channel + * just put zeroes to buffer. + * This should not happen because we check the scan mode + * and scan mask when we enable the buffer, and we don't allow + * the buffer to start with a mixed mask (voltage and something + * else). + * Thus, emit a warning. + */ + if (chan->type == IIO_VOLTAGE) { + st->buffer[i] = at91_adc_readl(st, chan->address); + } else { + st->buffer[i] = 0; + WARN(true, "This trigger cannot handle this type of channel"); + } i++; } iio_push_to_buffers_with_timestamp(indio_dev, st->buffer, @@ -688,9 +1006,20 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p) static int at91_adc_buffer_init(struct iio_dev *indio) { - return devm_iio_triggered_buffer_setup(&indio->dev, indio, + struct at91_adc_state *st = iio_priv(indio); + + if (st->selected_trig->hw_trig) { + return devm_iio_triggered_buffer_setup(&indio->dev, indio, &iio_pollfunc_store_time, &at91_adc_trigger_handler, &at91_buffer_setup_ops); + } + /* + * we need to prepare the buffer ops in case we will get + * another buffer attached (like a callback buffer for the touchscreen) + */ + indio->setup_ops = &at91_buffer_setup_ops; + + return 0; } static unsigned at91_adc_startup_time(unsigned startup_time_min, @@ -736,19 +1065,83 @@ static void at91_adc_setup_samp_freq(struct at91_adc_state *st, unsigned freq) dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u\n", freq, startup, prescal); + st->current_sample_rate = freq; } -static unsigned at91_adc_get_sample_freq(struct at91_adc_state *st) +static inline unsigned at91_adc_get_sample_freq(struct at91_adc_state *st) { - unsigned f_adc, f_per = clk_get_rate(st->per_clk); - unsigned mr, prescal; + return st->current_sample_rate; +} - mr = at91_adc_readl(st, AT91_SAMA5D2_MR); - prescal = (mr >> AT91_SAMA5D2_MR_PRESCAL_OFFSET) - & AT91_SAMA5D2_MR_PRESCAL_MAX; - f_adc = f_per / (2 * (prescal + 1)); +static void at91_adc_touch_data_handler(struct iio_dev *indio_dev) +{ + struct at91_adc_state *st = iio_priv(indio_dev); + u8 bit; + u16 val; + int i = 0; - return f_adc; + for_each_set_bit(bit, indio_dev->active_scan_mask, + AT91_SAMA5D2_MAX_CHAN_IDX + 1) { + struct iio_chan_spec const *chan = + at91_adc_chan_get(indio_dev, bit); + + if (chan->type == IIO_POSITIONRELATIVE) + at91_adc_read_position(st, chan->channel, &val); + else if (chan->type == IIO_PRESSURE) + at91_adc_read_pressure(st, chan->channel, &val); + else + continue; + st->buffer[i] = val; + i++; + } + /* + * Schedule work to push to buffers. + * This is intended to push to the callback buffer that another driver + * registered. We are still in a handler from our IRQ. If we push + * directly, it means the other driver has it's callback called + * from our IRQ context. Which is something we better avoid. + * Let's schedule it after our IRQ is completed. + */ + schedule_work(&st->touch_st.workq); +} + +static void at91_adc_pen_detect_interrupt(struct at91_adc_state *st) +{ + at91_adc_writel(st, AT91_SAMA5D2_IDR, AT91_SAMA5D2_IER_PEN); + at91_adc_writel(st, AT91_SAMA5D2_IER, AT91_SAMA5D2_IER_NOPEN | + AT91_SAMA5D2_IER_XRDY | AT91_SAMA5D2_IER_YRDY | + AT91_SAMA5D2_IER_PRDY); + at91_adc_writel(st, AT91_SAMA5D2_TRGR, + AT91_SAMA5D2_TRGR_TRGMOD_PERIODIC | + AT91_SAMA5D2_TRGR_TRGPER(st->touch_st.sample_period_val)); + st->touch_st.touching = true; +} + +static void at91_adc_no_pen_detect_interrupt(struct at91_adc_state *st) +{ + struct iio_dev *indio_dev = iio_priv_to_dev(st); + + at91_adc_writel(st, AT91_SAMA5D2_TRGR, + AT91_SAMA5D2_TRGR_TRGMOD_NO_TRIGGER); + at91_adc_writel(st, AT91_SAMA5D2_IDR, AT91_SAMA5D2_IER_NOPEN | + AT91_SAMA5D2_IER_XRDY | AT91_SAMA5D2_IER_YRDY | + AT91_SAMA5D2_IER_PRDY); + st->touch_st.touching = false; + + at91_adc_touch_data_handler(indio_dev); + + at91_adc_writel(st, AT91_SAMA5D2_IER, AT91_SAMA5D2_IER_PEN); +} + +static void at91_adc_workq_handler(struct work_struct *workq) +{ + struct at91_adc_touch *touch_st = container_of(workq, + struct at91_adc_touch, workq); + struct at91_adc_state *st = container_of(touch_st, + struct at91_adc_state, touch_st); + struct iio_dev *indio_dev = iio_priv_to_dev(st); + + iio_push_to_buffers(indio_dev, st->buffer); } static irqreturn_t at91_adc_interrupt(int irq, void *private) @@ -757,17 +1150,39 @@ static irqreturn_t at91_adc_interrupt(int irq, void *private) struct at91_adc_state *st = iio_priv(indio); u32 status = at91_adc_readl(st, AT91_SAMA5D2_ISR); u32 imr = at91_adc_readl(st, AT91_SAMA5D2_IMR); + u32 rdy_mask = AT91_SAMA5D2_IER_XRDY | AT91_SAMA5D2_IER_YRDY | + AT91_SAMA5D2_IER_PRDY; if (!(status & imr)) return IRQ_NONE; - - if (iio_buffer_enabled(indio) && !st->dma_st.dma_chan) { + if (status & AT91_SAMA5D2_IER_PEN) { + /* pen detected IRQ */ + at91_adc_pen_detect_interrupt(st); + } else if ((status & AT91_SAMA5D2_IER_NOPEN)) { + /* nopen detected IRQ */ + at91_adc_no_pen_detect_interrupt(st); + } else if ((status & AT91_SAMA5D2_ISR_PENS) && + ((status & rdy_mask) == rdy_mask)) { + /* periodic trigger IRQ - during pen sense */ + at91_adc_touch_data_handler(indio); + } else if (status & AT91_SAMA5D2_ISR_PENS) { + /* + * touching, but the measurements are not ready yet. + * read and ignore. + */ + status = at91_adc_readl(st, AT91_SAMA5D2_XPOSR); + status = at91_adc_readl(st, AT91_SAMA5D2_YPOSR); + status = at91_adc_readl(st, AT91_SAMA5D2_PRESSR); + } else if (iio_buffer_enabled(indio) && !st->dma_st.dma_chan) { + /* triggered buffer without DMA */ disable_irq_nosync(irq); iio_trigger_poll(indio->trig); } else if (iio_buffer_enabled(indio) && st->dma_st.dma_chan) { + /* triggered buffer with DMA - should not happen */ disable_irq_nosync(irq); WARN(true, "Unexpected irq occurred\n"); } else if (!iio_buffer_enabled(indio)) { + /* software requested conversion */ st->conversion_value = at91_adc_readl(st, st->chan->address); st->conversion_done = true; wake_up_interruptible(&st->wq_data_available); @@ -775,58 +1190,97 @@ static irqreturn_t at91_adc_interrupt(int irq, void *private) return IRQ_HANDLED; } -static int at91_adc_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, int *val2, long mask) +static int at91_adc_read_info_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val) { struct at91_adc_state *st = iio_priv(indio_dev); u32 cor = 0; int ret; - switch (mask) { - case IIO_CHAN_INFO_RAW: - /* we cannot use software trigger if hw trigger enabled */ + /* + * Keep in mind that we cannot use software trigger or touchscreen + * if external trigger is enabled + */ + if (chan->type == IIO_POSITIONRELATIVE) { ret = iio_device_claim_direct_mode(indio_dev); if (ret) return ret; mutex_lock(&st->lock); - st->chan = chan; - - if (chan->differential) - cor = (BIT(chan->channel) | BIT(chan->channel2)) << - AT91_SAMA5D2_COR_DIFF_OFFSET; - - at91_adc_writel(st, AT91_SAMA5D2_COR, cor); - at91_adc_writel(st, AT91_SAMA5D2_CHER, BIT(chan->channel)); - at91_adc_writel(st, AT91_SAMA5D2_IER, BIT(chan->channel)); - at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_START); - - ret = wait_event_interruptible_timeout(st->wq_data_available, - st->conversion_done, - msecs_to_jiffies(1000)); - if (ret == 0) - ret = -ETIMEDOUT; - - if (ret > 0) { - *val = st->conversion_value; - if (chan->scan_type.sign == 's') - *val = sign_extend32(*val, 11); - ret = IIO_VAL_INT; - st->conversion_done = false; - } - - at91_adc_writel(st, AT91_SAMA5D2_IDR, BIT(chan->channel)); - at91_adc_writel(st, AT91_SAMA5D2_CHDR, BIT(chan->channel)); - - /* Needed to ACK the DRDY interruption */ - at91_adc_readl(st, AT91_SAMA5D2_LCDR); - + ret = at91_adc_read_position(st, chan->channel, + (u16 *)val); mutex_unlock(&st->lock); - iio_device_release_direct_mode(indio_dev); - return ret; + return ret; + } + if (chan->type == IIO_PRESSURE) { + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + mutex_lock(&st->lock); + + ret = at91_adc_read_pressure(st, chan->channel, + (u16 *)val); + mutex_unlock(&st->lock); + iio_device_release_direct_mode(indio_dev); + + return ret; + } + + /* in this case we have a voltage channel */ + + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + mutex_lock(&st->lock); + + st->chan = chan; + + if (chan->differential) + cor = (BIT(chan->channel) | BIT(chan->channel2)) << + AT91_SAMA5D2_COR_DIFF_OFFSET; + + at91_adc_writel(st, AT91_SAMA5D2_COR, cor); + at91_adc_writel(st, AT91_SAMA5D2_CHER, BIT(chan->channel)); + at91_adc_writel(st, AT91_SAMA5D2_IER, BIT(chan->channel)); + at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_START); + + ret = wait_event_interruptible_timeout(st->wq_data_available, + st->conversion_done, + msecs_to_jiffies(1000)); + if (ret == 0) + ret = -ETIMEDOUT; + + if (ret > 0) { + *val = st->conversion_value; + if (chan->scan_type.sign == 's') + *val = sign_extend32(*val, 11); + ret = IIO_VAL_INT; + st->conversion_done = false; + } + + at91_adc_writel(st, AT91_SAMA5D2_IDR, BIT(chan->channel)); + at91_adc_writel(st, AT91_SAMA5D2_CHDR, BIT(chan->channel)); + + /* Needed to ACK the DRDY interruption */ + at91_adc_readl(st, AT91_SAMA5D2_LCDR); + + mutex_unlock(&st->lock); + + iio_device_release_direct_mode(indio_dev); + return ret; +} + +static int at91_adc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct at91_adc_state *st = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + return at91_adc_read_info_raw(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: *val = st->vref_uv / 1000; if (chan->differential) @@ -974,9 +1428,29 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) return 0; } +static int at91_adc_update_scan_mode(struct iio_dev *indio_dev, + const unsigned long *scan_mask) +{ + struct at91_adc_state *st = iio_priv(indio_dev); + + if (bitmap_subset(scan_mask, &st->touch_st.channels_bitmask, + AT91_SAMA5D2_MAX_CHAN_IDX + 1)) + return 0; + /* + * if the new bitmap is a combination of touchscreen and regular + * channels, then we are not fine + */ + if (bitmap_intersects(&st->touch_st.channels_bitmask, scan_mask, + AT91_SAMA5D2_MAX_CHAN_IDX + 1)) + return -EINVAL; + return 0; +} + static const struct iio_info at91_adc_info = { .read_raw = &at91_adc_read_raw, .write_raw = &at91_adc_write_raw, + .update_scan_mode = &at91_adc_update_scan_mode, + .of_xlate = &at91_adc_of_xlate, .hwfifo_set_watermark = &at91_adc_set_watermark, }; @@ -1044,13 +1518,20 @@ static int at91_adc_probe(struct platform_device *pdev) indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); - indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; indio_dev->info = &at91_adc_info; indio_dev->channels = at91_adc_channels; indio_dev->num_channels = ARRAY_SIZE(at91_adc_channels); st = iio_priv(indio_dev); + bitmap_set(&st->touch_st.channels_bitmask, + AT91_SAMA5D2_TOUCH_X_CHAN_IDX, 1); + bitmap_set(&st->touch_st.channels_bitmask, + AT91_SAMA5D2_TOUCH_Y_CHAN_IDX, 1); + bitmap_set(&st->touch_st.channels_bitmask, + AT91_SAMA5D2_TOUCH_P_CHAN_IDX, 1); + ret = of_property_read_u32(pdev->dev.of_node, "atmel,min-sample-rate-hz", &st->soc_info.min_sample_rate); @@ -1100,6 +1581,7 @@ static int at91_adc_probe(struct platform_device *pdev) init_waitqueue_head(&st->wq_data_available); mutex_init(&st->lock); + INIT_WORK(&st->touch_st.workq, at91_adc_workq_handler); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) @@ -1159,13 +1641,13 @@ static int at91_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); - if (st->selected_trig->hw_trig) { - ret = at91_adc_buffer_init(indio_dev); - if (ret < 0) { - dev_err(&pdev->dev, "couldn't initialize the buffer.\n"); - goto per_clk_disable_unprepare; - } + ret = at91_adc_buffer_init(indio_dev); + if (ret < 0) { + dev_err(&pdev->dev, "couldn't initialize the buffer.\n"); + goto per_clk_disable_unprepare; + } + if (st->selected_trig->hw_trig) { ret = at91_adc_trigger_init(indio_dev); if (ret < 0) { dev_err(&pdev->dev, "couldn't setup the triggers.\n"); @@ -1272,9 +1754,20 @@ static __maybe_unused int at91_adc_resume(struct device *dev) at91_adc_hw_init(st); /* reconfiguring trigger hardware state */ - if (iio_buffer_enabled(indio_dev)) - at91_adc_configure_trigger(st->trig, true); + if (!iio_buffer_enabled(indio_dev)) + return 0; + /* check if we are enabling triggered buffer or the touchscreen */ + if (bitmap_subset(indio_dev->active_scan_mask, + &st->touch_st.channels_bitmask, + AT91_SAMA5D2_MAX_CHAN_IDX + 1)) { + /* touchscreen enabling */ + return at91_adc_configure_touch(st, true); + } else { + return at91_adc_configure_trigger(st->trig, true); + } + + /* not needed but more explicit */ return 0; vref_disable_resume: From aa132ffb6b0a188c418f35da0750bdaf7aa34758 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Tue, 22 May 2018 10:52:36 +0300 Subject: [PATCH 015/903] input: touchscreen: resistive-adc-touch: add generic resistive ADC touchscreen This adds a generic resistive touchscreen (GRTS) driver, which is based on an IIO device (an ADC). It must be connected to the channels of an ADC to receive touch data. Then it will feed the data into the input subsystem where it registers an input device. It uses an IIO callback buffer to register to the IIO device Some parts of this patch are based on initial original work by Mohamed Jamsheeth Hajanajubudeen and Bandaru Venkateswara Swamy Signed-off-by: Eugen Hristev Acked-by: Dmitry Torokhov Signed-off-by: Jonathan Cameron --- drivers/input/touchscreen/Kconfig | 13 ++ drivers/input/touchscreen/Makefile | 1 + .../input/touchscreen/resistive-adc-touch.c | 204 ++++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100644 drivers/input/touchscreen/resistive-adc-touch.c diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 32267c1afebc..66d1a220726a 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -92,6 +92,19 @@ config TOUCHSCREEN_AD7879_SPI To compile this driver as a module, choose M here: the module will be called ad7879-spi. +config TOUCHSCREEN_ADC + tristate "Generic ADC based resistive touchscreen" + depends on IIO + select IIO_BUFFER_CB + help + Say Y here if you want to use the generic ADC + resistive touchscreen driver. + + If unsure, say N (but it's safe to say "Y"). + + To compile this driver as a module, choose M here: the + module will be called resistive-adc-touch.ko. + config TOUCHSCREEN_AR1021_I2C tristate "Microchip AR1020/1021 i2c touchscreen" depends on I2C && OF diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index fd4fd32fb73f..35bd0619edf1 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o +obj-$(CONFIG_TOUCHSCREEN_ADC) += resistive-adc-touch.o obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o obj-$(CONFIG_TOUCHSCREEN_AR1021_I2C) += ar1021_i2c.o obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o diff --git a/drivers/input/touchscreen/resistive-adc-touch.c b/drivers/input/touchscreen/resistive-adc-touch.c new file mode 100644 index 000000000000..cfc8bb4553f7 --- /dev/null +++ b/drivers/input/touchscreen/resistive-adc-touch.c @@ -0,0 +1,204 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ADC generic resistive touchscreen (GRTS) + * This is a generic input driver that connects to an ADC + * given the channels in device tree, and reports events to the input + * subsystem. + * + * Copyright (C) 2017,2018 Microchip Technology, + * Author: Eugen Hristev + * + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "resistive-adc-touch" +#define GRTS_DEFAULT_PRESSURE_MIN 50000 +#define GRTS_MAX_POS_MASK GENMASK(11, 0) + +/** + * grts_state - generic resistive touch screen information struct + * @pressure_min: number representing the minimum for the pressure + * @pressure: are we getting pressure info or not + * @iio_chans: list of channels acquired + * @iio_cb: iio_callback buffer for the data + * @input: the input device structure that we register + * @prop: touchscreen properties struct + */ +struct grts_state { + u32 pressure_min; + bool pressure; + struct iio_channel *iio_chans; + struct iio_cb_buffer *iio_cb; + struct input_dev *input; + struct touchscreen_properties prop; +}; + +static int grts_cb(const void *data, void *private) +{ + const u16 *touch_info = data; + struct grts_state *st = private; + unsigned int x, y, press = 0x0; + + /* channel data coming in buffer in the order below */ + x = touch_info[0]; + y = touch_info[1]; + if (st->pressure) + press = touch_info[2]; + + if ((!x && !y) || (st->pressure && (press < st->pressure_min))) { + /* report end of touch */ + input_report_key(st->input, BTN_TOUCH, 0); + input_sync(st->input); + return 0; + } + + /* report proper touch to subsystem*/ + touchscreen_report_pos(st->input, &st->prop, x, y, false); + if (st->pressure) + input_report_abs(st->input, ABS_PRESSURE, press); + input_report_key(st->input, BTN_TOUCH, 1); + input_sync(st->input); + + return 0; +} + +static int grts_open(struct input_dev *dev) +{ + int error; + struct grts_state *st = input_get_drvdata(dev); + + error = iio_channel_start_all_cb(st->iio_cb); + if (error) { + dev_err(dev->dev.parent, "failed to start callback buffer.\n"); + return error; + } + return 0; +} + +static void grts_close(struct input_dev *dev) +{ + struct grts_state *st = input_get_drvdata(dev); + + iio_channel_stop_all_cb(st->iio_cb); +} + +static void grts_disable(void *data) +{ + iio_channel_release_all_cb(data); +} + +static int grts_probe(struct platform_device *pdev) +{ + struct grts_state *st; + struct input_dev *input; + struct device *dev = &pdev->dev; + struct iio_channel *chan; + int error; + + st = devm_kzalloc(dev, sizeof(struct grts_state), GFP_KERNEL); + if (!st) + return -ENOMEM; + + /* get the channels from IIO device */ + st->iio_chans = devm_iio_channel_get_all(dev); + if (IS_ERR(st->iio_chans)) { + error = PTR_ERR(st->iio_chans); + if (error != -EPROBE_DEFER) + dev_err(dev, "can't get iio channels.\n"); + return error; + } + + chan = &st->iio_chans[0]; + st->pressure = false; + while (chan && chan->indio_dev) { + if (!strcmp(chan->channel->datasheet_name, "pressure")) + st->pressure = true; + chan++; + } + + if (st->pressure) { + error = device_property_read_u32(dev, + "touchscreen-min-pressure", + &st->pressure_min); + if (error) { + dev_dbg(dev, "can't get touchscreen-min-pressure property.\n"); + st->pressure_min = GRTS_DEFAULT_PRESSURE_MIN; + } + } + + input = devm_input_allocate_device(dev); + if (!input) { + dev_err(dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + input->name = DRIVER_NAME; + input->id.bustype = BUS_HOST; + input->open = grts_open; + input->close = grts_close; + + input_set_abs_params(input, ABS_X, 0, GRTS_MAX_POS_MASK - 1, 0, 0); + input_set_abs_params(input, ABS_Y, 0, GRTS_MAX_POS_MASK - 1, 0, 0); + if (st->pressure) + input_set_abs_params(input, ABS_PRESSURE, st->pressure_min, + 0xffff, 0, 0); + + input_set_capability(input, EV_KEY, BTN_TOUCH); + + /* parse optional device tree properties */ + touchscreen_parse_properties(input, false, &st->prop); + + st->input = input; + input_set_drvdata(input, st); + + error = input_register_device(input); + if (error) { + dev_err(dev, "failed to register input device."); + return error; + } + + st->iio_cb = iio_channel_get_all_cb(dev, grts_cb, st); + if (IS_ERR(st->iio_cb)) { + dev_err(dev, "failed to allocate callback buffer.\n"); + return PTR_ERR(st->iio_cb); + } + + error = devm_add_action_or_reset(dev, grts_disable, st->iio_cb); + if (error) { + dev_err(dev, "failed to add disable action.\n"); + return error; + } + + return 0; +} + +static const struct of_device_id grts_of_match[] = { + { + .compatible = "resistive-adc-touch", + }, { + /* sentinel */ + }, +}; + +MODULE_DEVICE_TABLE(of, grts_of_match); + +static struct platform_driver grts_driver = { + .probe = grts_probe, + .driver = { + .name = DRIVER_NAME, + .of_match_table = of_match_ptr(grts_of_match), + }, +}; + +module_platform_driver(grts_driver); + +MODULE_AUTHOR("Eugen Hristev "); +MODULE_DESCRIPTION("Generic ADC Resistive Touch Driver"); +MODULE_LICENSE("GPL v2"); From a591525f43e7d17dc5f94f314d30f6e4da753d7b Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Tue, 22 May 2018 10:52:37 +0300 Subject: [PATCH 016/903] dt-bindings: iio: adc: at91-sama5d2_adc: add channel specific consumer info Added defines for channel consumer device-tree binding Signed-off-by: Eugen Hristev Reviewed-by: Rob Herring Acked-by: Ludovic Desroches Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/at91-sama5d2_adc.txt | 9 +++++++++ include/dt-bindings/iio/adc/at91-sama5d2_adc.h | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 include/dt-bindings/iio/adc/at91-sama5d2_adc.h diff --git a/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt b/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt index 6469a4cd2a6d..4a3c1d496e1a 100644 --- a/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt +++ b/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt @@ -21,6 +21,14 @@ Optional properties: - dmas: Phandle to dma channel for the ADC. - dma-names: Must be "rx" when dmas property is being used. See ../../dma/dma.txt for details. + - #io-channel-cells: in case consumer drivers are attached, this must be 1. + See for details. + +Properties for consumer drivers: + - Consumer drivers can be connected to this producer device, as specified + in + - Channels exposed are specified in: + Example: @@ -38,4 +46,5 @@ adc: adc@fc030000 { atmel,trigger-edge-type = ; dmas = <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(25))>; dma-names = "rx"; + #io-channel-cells = <1>; } diff --git a/include/dt-bindings/iio/adc/at91-sama5d2_adc.h b/include/dt-bindings/iio/adc/at91-sama5d2_adc.h new file mode 100644 index 000000000000..70f99dbdbb42 --- /dev/null +++ b/include/dt-bindings/iio/adc/at91-sama5d2_adc.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * This header provides constants for configuring the AT91 SAMA5D2 ADC + */ + +#ifndef _DT_BINDINGS_IIO_ADC_AT91_SAMA5D2_ADC_H +#define _DT_BINDINGS_IIO_ADC_AT91_SAMA5D2_ADC_H + +/* X relative position channel index */ +#define AT91_SAMA5D2_ADC_X_CHANNEL 24 +/* Y relative position channel index */ +#define AT91_SAMA5D2_ADC_Y_CHANNEL 25 +/* pressure channel index */ +#define AT91_SAMA5D2_ADC_P_CHANNEL 26 + +#endif From d8084a048cca85e3316c685415fd15234665b160 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Mon, 4 Jun 2018 17:22:07 +0300 Subject: [PATCH 017/903] iio:dac:ad5686: Add AD5311R support AD5311R is a single channel DAC with 10-bit precision and i2c interface. The device includes a 2.5V internal reference which is enabled by default. This device is similar to AD5691R/AD5692R/AD5693/AD5693R, the only difference is that it has 10-bit precision. Datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/AD5310R_5311R.pdf Signed-off-by: Stefan Popa Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5686.c | 7 +++++++ drivers/iio/dac/ad5686.h | 1 + drivers/iio/dac/ad5696-i2c.c | 1 + 3 files changed, 9 insertions(+) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index e136f0fd38f0..2ddbfc3fdbae 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -221,6 +221,7 @@ static struct iio_chan_spec name[] = { \ AD5868_CHANNEL(7, 7, bits, _shift), \ } +DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4); @@ -231,6 +232,12 @@ DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2); DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4); static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { + [ID_AD5311R] = { + .channels = ad5311r_channels, + .int_vref_mv = 2500, + .num_channels = 1, + .regmap_type = AD5693_REGMAP, + }, [ID_AD5671R] = { .channels = ad5672_channels, .int_vref_mv = 2500, diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index d05cda9f1edd..57b3c61bfb91 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -45,6 +45,7 @@ * ad5686_supported_device_ids: */ enum ad5686_supported_device_ids { + ID_AD5311R, ID_AD5671R, ID_AD5672R, ID_AD5675R, diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index d18735d7d938..7350d9806a11 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -71,6 +71,7 @@ static int ad5686_i2c_remove(struct i2c_client *i2c) } static const struct i2c_device_id ad5686_i2c_id[] = { + {"ad5311r", ID_AD5311R}, {"ad5671r", ID_AD5671R}, {"ad5675r", ID_AD5675R}, {"ad5691r", ID_AD5691R}, From 727198f99e276c7ce8fc63e90489f63ad886ed39 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Sat, 9 Jun 2018 00:13:31 +0200 Subject: [PATCH 018/903] staging: iio: adc: ad7606: fix function pointer parameter names missing. Checkpatch.pl complains about function pointer parameter names missing. Add parameter names. Signed-off-by: Giulio Benetti Reviewed-by: Martin Kelly Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7606.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h index acaed8d5379c..9716ee9d94a7 100644 --- a/drivers/staging/iio/adc/ad7606.h +++ b/drivers/staging/iio/adc/ad7606.h @@ -57,7 +57,7 @@ struct ad7606_state { struct ad7606_bus_ops { /* more methods added in future? */ - int (*read_block)(struct device *, int, void *); + int (*read_block)(struct device *dev, int num, void *data); }; int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, From c660abab5c7edbc9ec9cd3b7b8611e7bac01d0ac Mon Sep 17 00:00:00 2001 From: Karim Eshapa Date: Tue, 12 Jun 2018 18:48:38 +0200 Subject: [PATCH 019/903] staging:iio:accel:adis16203: sign extend function rather code duplication Use sign_extend32 kernel function instead of code duplication. This function is also safe for 16 bits. Signed-off-by: Karim Eshapa Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index b3e4571340ab..5cc96c8086b5 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -168,7 +168,6 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, { struct adis *st = iio_priv(indio_dev); int ret; - int bits; u8 addr; s16 val16; @@ -202,14 +201,11 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, *val = 25000 / -470 - 1278; /* 25 C = 1278 */ return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: - bits = 14; addr = adis16203_addresses[chan->scan_index]; ret = adis_read_reg_16(st, addr, &val16); if (ret) return ret; - val16 &= (1 << bits) - 1; - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); - *val = val16; + *val = sign_extend32(val16, 13); return IIO_VAL_INT; default: return -EINVAL; From b3c16227013f7f24429487cb501390c0f44fba8f Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:50:28 +0200 Subject: [PATCH 020/903] staging: comedi: comedi_fops: make bool bit-field unsigned int bit-fields. Checkpatch complains on bool bitfields to be an int or u8/u16/u32 bitfield. Make bool bit-fields to be unsigned int bit-fields. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index c13772a0df58..1f3b1106f478 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -60,7 +60,7 @@ struct comedi_file { struct comedi_subdevice *read_subdev; struct comedi_subdevice *write_subdev; unsigned int last_detach_count; - bool last_attached:1; + unsigned int last_attached:1; }; #define COMEDI_NUM_MINORS 0x100 From fd02c95fab8bc8ba63299d370f6d5437c62641d1 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:50:29 +0200 Subject: [PATCH 021/903] staging: comedi: comedidev: make bool bit-field unsigned int bit-fields. Checkpatch complains on bool bitfields to be an int or u8/u16/u32 bitfield. Make bool bit-fields to be unsigned int bit-fields. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index c54ac94d89d2..5775a93917f4 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -542,8 +542,8 @@ struct comedi_device { const char *board_name; const void *board_ptr; - bool attached:1; - bool ioenabled:1; + unsigned int attached:1; + unsigned int ioenabled:1; spinlock_t spinlock; /* generic spin-lock for low-level driver */ struct mutex mutex; /* generic mutex for COMEDI core */ struct rw_semaphore attach_lock; From 46fb63b3a12af241269de34b4f9db2516e28a60a Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:50:30 +0200 Subject: [PATCH 022/903] staging: comedi: drivers: amplc_dio200: make bool bit-field unsigned int bit-fields. Checkpatch complains on bool bitfields to be an int or u8/u16/u32 bitfield. Make bool bit-fields to be unsigned int bit-fields. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h index 88c1d1063d5d..4c3e4c37c4c5 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.h +++ b/drivers/staging/comedi/drivers/amplc_dio200.h @@ -32,9 +32,9 @@ struct dio200_board { unsigned short n_subdevs; /* number of subdevices */ unsigned char sdtype[DIO200_MAX_SUBDEVS]; /* enum dio200_sdtype */ unsigned char sdinfo[DIO200_MAX_SUBDEVS]; /* depends on sdtype */ - bool has_int_sce:1; /* has interrupt enable/status reg */ - bool has_clk_gat_sce:1; /* has clock/gate selection registers */ - bool is_pcie:1; /* has enhanced features */ + unsigned int has_int_sce:1; /* has interrupt enable/status reg */ + unsigned int has_clk_gat_sce:1; /* has clock/gate selection registers */ + unsigned int is_pcie:1; /* has enhanced features */ }; int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, From 3164da7b9ccc0b50ce3593e21b7f4be36c9e8cef Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:50:31 +0200 Subject: [PATCH 023/903] staging: comedi: drivers: amplc_dio200_common: make bool bit-field unsigned int bit-fields. Checkpatch complains on bool bitfields to be an int or u8/u16/u32 bitfield. Make bool bit-fields to be unsigned int bit-fields. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 82bd41d92509..8697dc02ffb4 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -96,7 +96,7 @@ struct dio200_subdev_intr { unsigned int ofs; unsigned int valid_isns; unsigned int enabled_isns; - bool active:1; + unsigned int active:1; }; static unsigned char dio200_read8(struct comedi_device *dev, From 904f9d4d3a83ef0eccaea5fe455f2c586c6f5cf0 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:50:32 +0200 Subject: [PATCH 024/903] staging: comedi: drivers: amplc_pci230: make bool bit-field unsigned int bit-fields. Checkpatch complains on bool bitfields to be an int or u8/u16/u32 bitfield. Make bool bit-fields to be unsigned int bit-fields. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 15fc7f19051a..08ffe26c5d43 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -444,7 +444,7 @@ struct pci230_board { unsigned char ai_bits; unsigned char ao_bits; unsigned char min_hwver; /* Minimum hardware version supported. */ - bool have_dio:1; + unsigned int have_dio:1; }; static const struct pci230_board pci230_boards[] = { @@ -490,11 +490,11 @@ struct pci230_private { unsigned short adcg; /* ADCG register value */ unsigned char ier; /* Interrupt enable bits */ unsigned char res_owned[NUM_OWNERS]; /* Owned resources */ - bool intr_running:1; /* Flag set in interrupt routine */ - bool ai_bipolar:1; /* Flag AI range is bipolar */ - bool ao_bipolar:1; /* Flag AO range is bipolar */ - bool ai_cmd_started:1; /* Flag AI command started */ - bool ao_cmd_started:1; /* Flag AO command started */ + unsigned int intr_running:1; /* Flag set in interrupt routine */ + unsigned int ai_bipolar:1; /* Flag AI range is bipolar */ + unsigned int ao_bipolar:1; /* Flag AO range is bipolar */ + unsigned int ai_cmd_started:1; /* Flag AI command started */ + unsigned int ao_cmd_started:1; /* Flag AO command started */ }; /* PCI230 clock source periods in ns */ From 6aa02093936898c4d8c485e702e5b61d9e39f408 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:50:33 +0200 Subject: [PATCH 025/903] staging: comedi: drivers: daqboard2000: make bool bit-field unsigned int bit-fields. Checkpatch complains on bool bitfields to be an int or u8/u16/u32 bitfield. Make bool bit-fields to be unsigned int bit-fields. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 03f98b0287c8..aabcda3f9fc8 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -240,7 +240,7 @@ enum db2k_boardid { struct db2k_boardtype { const char *name; - bool has_2_ao:1; /* false: 4 AO chans; true: 2 AO chans */ + unsigned int has_2_ao:1;/* false: 4 AO chans; true: 2 AO chans */ }; static const struct db2k_boardtype db2k_boardtypes[] = { From d83301c8506cb448a82f52321e0898d202701517 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:54:08 +0200 Subject: [PATCH 026/903] staging: comedi: drivers: cb_pcimdda: fix warning on quoted string split across lines. Checkpatch.pl complains about "quoted string split across lines" for string in MODULE_DESCRIPTION(). Put string on only one line. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcimdda.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index b33203f6a990..21fc7b3c5f60 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -188,7 +188,5 @@ static struct pci_driver cb_pcimdda_driver_pci_driver = { module_comedi_pci_driver(cb_pcimdda_driver, cb_pcimdda_driver_pci_driver); MODULE_AUTHOR("Calin A. Culianu "); -MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA " - "series. Currently only supports PCIM-DDA06-16 (which " - "also happens to be the only board in this series. :) ) "); +MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA series. Currently only supports PCIM-DDA06-16 (which also happens to be the only board in this series. :) ) "); MODULE_LICENSE("GPL"); From fbe1be81b2840f4f5a25405e92cf67b69bafe9c1 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Tue, 12 Jun 2018 16:54:09 +0200 Subject: [PATCH 027/903] staging: comedi: drivers: ni_mio_common: add names to function pointer parameters. Checkpatch.pl complains about packbits function pointer that lacks parameters name. Add parameter names to packbits function pointer. Signed-off-by: Giulio Benetti Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index e40a2c0a9543..b0b05a96c2f0 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4294,7 +4294,7 @@ static int pack_ad8842(int addr, int val, int *bitstring) struct caldac_struct { int n_chans; int n_bits; - int (*packbits)(int, int, int *); + int (*packbits)(int address, int value, int *bitstring); }; static struct caldac_struct caldacs[] = { From 2665df51017b15119987913bfa39d02d71cb7232 Mon Sep 17 00:00:00 2001 From: Chris Opperman Date: Wed, 13 Jun 2018 19:14:35 +0200 Subject: [PATCH 028/903] staging: comedi: Improved readability of function comedi_nsamples_left. Improve readability of comedi_nsamples_left: a) Reduce nesting by using more return statements. b) Declare variables scans_left and samples_left at start of function. c) Change type of scans_Left to unsigned long long to avoid cast. Signed-off-by: Chris Opperman Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 9d733471ca2e..57dd63d548b7 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -473,21 +473,21 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s, { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; + unsigned long long scans_left; + unsigned long long samples_left; - if (cmd->stop_src == TRIG_COUNT) { - unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg); - unsigned int scan_pos = - comedi_bytes_to_samples(s, async->scan_progress); - unsigned long long samples_left = 0; + if (cmd->stop_src != TRIG_COUNT) + return nsamples; - if (scans_left) { - samples_left = ((unsigned long long)scans_left * - cmd->scan_end_arg) - scan_pos; - } + scans_left = __comedi_nscans_left(s, cmd->stop_arg); + if (!scans_left) + return 0; - if (samples_left < nsamples) - nsamples = samples_left; - } + samples_left = scans_left * cmd->scan_end_arg - + comedi_bytes_to_samples(s, async->scan_progress); + + if (samples_left < nsamples) + return samples_left; return nsamples; } EXPORT_SYMBOL_GPL(comedi_nsamples_left); From 456aec73799f6cd31d5162d0814f8c372acffed6 Mon Sep 17 00:00:00 2001 From: Justin Skists Date: Mon, 4 Jun 2018 10:52:12 +0100 Subject: [PATCH 029/903] staging: speakup: refactor synths array to use a list The synths[] array is a collection of synths acting like a list. There is no need for synths to be an array, so refactor synths[] to use standard kernel list_head API, instead, and modify the usages to suit. As a side-effect, the maximum number of synths has also become redundant. Signed-off-by: Justin Skists Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/spk_types.h | 2 ++ drivers/staging/speakup/synth.c | 40 ++++++++++------------------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/drivers/staging/speakup/spk_types.h b/drivers/staging/speakup/spk_types.h index 3e082dc3d45c..a2fc72c29894 100644 --- a/drivers/staging/speakup/spk_types.h +++ b/drivers/staging/speakup/spk_types.h @@ -160,6 +160,8 @@ struct spk_io_ops { }; struct spk_synth { + struct list_head node; + const char *name; const char *version; const char *long_name; diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c index 7deeb7061018..25f259ee4ffc 100644 --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -18,8 +18,7 @@ #include "speakup.h" #include "serialio.h" -#define MAXSYNTHS 16 /* Max number of synths in array. */ -static struct spk_synth *synths[MAXSYNTHS + 1]; +static LIST_HEAD(synths); struct spk_synth *synth; char spk_pitch_buff[32] = ""; static int module_status; @@ -355,9 +354,8 @@ struct var_t synth_time_vars[] = { /* called by: speakup_init() */ int synth_init(char *synth_name) { - int i; int ret = 0; - struct spk_synth *synth = NULL; + struct spk_synth *tmp, *synth = NULL; if (!synth_name) return 0; @@ -371,9 +369,10 @@ int synth_init(char *synth_name) mutex_lock(&spk_mutex); /* First, check if we already have it loaded. */ - for (i = 0; i < MAXSYNTHS && synths[i]; i++) - if (strcmp(synths[i]->name, synth_name) == 0) - synth = synths[i]; + list_for_each_entry(tmp, &synths, node) { + if (strcmp(tmp->name, synth_name) == 0) + synth = tmp; + } /* If we got one, initialize it now. */ if (synth) @@ -448,29 +447,23 @@ void synth_release(void) /* called by: all_driver_init() */ int synth_add(struct spk_synth *in_synth) { - int i; int status = 0; + struct spk_synth *tmp; mutex_lock(&spk_mutex); - for (i = 0; i < MAXSYNTHS && synths[i]; i++) - /* synth_remove() is responsible for rotating the array down */ - if (in_synth == synths[i]) { + + list_for_each_entry(tmp, &synths, node) { + if (tmp == in_synth) { mutex_unlock(&spk_mutex); return 0; } - if (i == MAXSYNTHS) { - pr_warn("Error: attempting to add a synth past end of array\n"); - mutex_unlock(&spk_mutex); - return -1; } if (in_synth->startup) status = do_synth_init(in_synth); - if (!status) { - synths[i++] = in_synth; - synths[i] = NULL; - } + if (!status) + list_add_tail(&in_synth->node, &synths); mutex_unlock(&spk_mutex); return status; @@ -479,17 +472,10 @@ EXPORT_SYMBOL_GPL(synth_add); void synth_remove(struct spk_synth *in_synth) { - int i; - mutex_lock(&spk_mutex); if (synth == in_synth) synth_release(); - for (i = 0; synths[i]; i++) { - if (in_synth == synths[i]) - break; - } - for ( ; synths[i]; i++) /* compress table */ - synths[i] = synths[i + 1]; + list_del(&in_synth->node); module_status = 0; mutex_unlock(&spk_mutex); } From c0f784ba92e051d0de33ca7e1fd192317cfdb738 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 7 Jun 2018 08:04:20 +1000 Subject: [PATCH 030/903] staging: mt7621-pci: use rt_sysc_?32() to access system-control register. This driver currently has internal knowledge ofthe address of system-control registers and accesses them by dereferencing a constant pointer. It is cleaner to use rt_sysc_r32(), rt_sysc_w32(), rt_sysc_m32() which is a more standard interface. So change the defined names to offsets instead of pointers, and use these functions. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 57 ++++++++++++------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 17f2105ec698..5957205feb46 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -55,6 +55,7 @@ #include #include +#include /* * These functions and structures provide the BIOS scan and mapping of the PCI @@ -72,7 +73,6 @@ #define RALINK_PCIE0_RST (1<<24) #define RALINK_PCIE1_RST (1<<25) #define RALINK_PCIE2_RST (1<<26) -#define RALINK_SYSCTL_BASE 0xBE000000 #define RALINK_PCI_PCICFG_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x0000) #define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x000C) @@ -133,31 +133,28 @@ #define RALINK_PCI_MM_MAP_BASE 0x60000000 #define RALINK_PCI_IO_MAP_BASE 0x1e160000 -#define RALINK_SYSTEM_CONTROL_BASE 0xbe000000 - #define ASSERT_SYSRST_PCIE(val) \ do { \ - if (*(unsigned int *)(0xbe00000c) == 0x00030101) \ - RALINK_RSTCTRL |= val; \ + if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101) \ + rt_sysc_m32(0, val, RALINK_RSTCTRL); \ else \ - RALINK_RSTCTRL &= ~val; \ + rt_sysc_m32(val, 0, RALINK_RSTCTRL); \ } while(0) #define DEASSERT_SYSRST_PCIE(val) \ do { \ - if (*(unsigned int *)(0xbe00000c) == 0x00030101) \ - RALINK_RSTCTRL &= ~val; \ + if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101) \ + rt_sysc_m32(val, 0, RALINK_RSTCTRL); \ else \ - RALINK_RSTCTRL |= val; \ + rt_sysc_m32(0, val, RALINK_RSTCTRL); \ } while(0) -#define RALINK_SYSCFG1 *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x14) -#define RALINK_CLKCFG1 *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x30) -#define RALINK_RSTCTRL *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x34) -#define RALINK_GPIOMODE *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x60) -#define RALINK_PCIE_CLK_GEN *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x7c) -#define RALINK_PCIE_CLK_GEN1 *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x80) -#define PPLL_CFG1 *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0x9c) -#define PPLL_DRV *(unsigned int *)(RALINK_SYSTEM_CONTROL_BASE + 0xa0) -//RALINK_SYSCFG1 bit +#define RALINK_CLKCFG1 0x30 +#define RALINK_RSTCTRL 0x34 +#define RALINK_GPIOMODE 0x60 +#define RALINK_PCIE_CLK_GEN 0x7c +#define RALINK_PCIE_CLK_GEN1 0x80 +#define PPLL_CFG1 0x9c +#define PPLL_DRV 0xa0 +/* SYSC_REG_SYSTEM_CONFIG1 bits */ #define RALINK_PCI_HOST_MODE_EN (1<<7) #define RALINK_PCIE_RC_MODE_EN (1<<8) //RALINK_RSTCTRL bit @@ -383,7 +380,7 @@ bypass_pipe_rst(void) void set_phy_for_ssc(void) { - unsigned long reg = (*(volatile u32 *)(RALINK_SYSCTL_BASE + 0x10)); + unsigned long reg = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG0); reg = (reg >> 6) & 0x7; /* Set PCIe Port0 & Port1 PHY to disable SSC */ @@ -521,15 +518,15 @@ static int mt7621_pci_probe(struct platform_device *pdev) read_config(0, 2, 0, 0x70c, &val); printk("Port 2 N_FTS = %x\n", (unsigned int)val); - RALINK_RSTCTRL = (RALINK_RSTCTRL | RALINK_PCIE_RST); - RALINK_SYSCFG1 &= ~(0x30); - RALINK_SYSCFG1 |= (2<<4); - RALINK_PCIE_CLK_GEN &= 0x7fffffff; - RALINK_PCIE_CLK_GEN1 &= 0x80ffffff; - RALINK_PCIE_CLK_GEN1 |= 0xa << 24; - RALINK_PCIE_CLK_GEN |= 0x80000000; + rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); + rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1); + + rt_sysc_m32(0x80000000, 0, RALINK_PCIE_CLK_GEN); + rt_sysc_m32(0x7f000000, 0xa << 24, RALINK_PCIE_CLK_GEN1); + rt_sysc_m32(0, 0x80000000, RALINK_PCIE_CLK_GEN); + mdelay(50); - RALINK_RSTCTRL = (RALINK_RSTCTRL & ~RALINK_PCIE_RST); + rt_sysc_m32(RALINK_PCIE_RST, 0, RALINK_RSTCTRL); /* Use GPIO control instead of PERST_N */ *(unsigned int *)(0xbe000620) |= 0x1<<19 | 0x1<<8 | 0x1<<7; // set DATA @@ -539,7 +536,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) { printk("PCIE0 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST); - RALINK_CLKCFG1 = (RALINK_CLKCFG1 & ~RALINK_PCIE0_CLK_EN); + rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1); pcie_link_status &= ~(1<<0); } else { pcie_link_status |= 1<<0; @@ -550,7 +547,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) { printk("PCIE1 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE1_RST); - RALINK_CLKCFG1 = (RALINK_CLKCFG1 & ~RALINK_PCIE1_CLK_EN); + rt_sysc_m32(RALINK_PCIE1_CLK_EN, 0, RALINK_CLKCFG1); pcie_link_status &= ~(1<<1); } else { pcie_link_status |= 1<<1; @@ -560,7 +557,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) if (( RALINK_PCI2_STATUS & 0x1) == 0) { printk("PCIE2 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE2_RST); - RALINK_CLKCFG1 = (RALINK_CLKCFG1 & ~RALINK_PCIE2_CLK_EN); + rt_sysc_m32(RALINK_PCIE2_CLK_EN, 0, RALINK_CLKCFG1); pcie_link_status &= ~(1<<2); } else { pcie_link_status |= 1<<2; From a83834c1c9ba446f694c0bc29bce25687bf06582 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 7 Jun 2018 08:04:21 +1000 Subject: [PATCH 031/903] staging: mt7621-spi: change mt7621_spi_wait_till_ready to take struct mt7621_spi All callers have a 'struct mt7621_spi' and that is all mt7621_spi_wait_till_ready() needs. So just pass it instead of the spi_device. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index 37f299080410..d43576d2a3f9 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -155,9 +155,8 @@ static int mt7621_spi_prepare(struct spi_device *spi, unsigned int speed) return 0; } -static inline int mt7621_spi_wait_till_ready(struct spi_device *spi) +static inline int mt7621_spi_wait_till_ready(struct mt7621_spi *rs) { - struct mt7621_spi *rs = spidev_to_mt7621_spi(spi); int i; for (i = 0; i < RALINK_SPI_WAIT_MAX_LOOP; i++) { @@ -187,7 +186,7 @@ static int mt7621_spi_transfer_half_duplex(struct spi_master *master, u32 data[9] = { 0 }; u32 val; - mt7621_spi_wait_till_ready(spi); + mt7621_spi_wait_till_ready(rs); list_for_each_entry(t, &m->transfers, transfer_list) { const u8 *buf = t->tx_buf; @@ -238,7 +237,7 @@ static int mt7621_spi_transfer_half_duplex(struct spi_master *master, val |= SPI_CTL_START; mt7621_spi_write(rs, MT7621_SPI_TRANS, val); - mt7621_spi_wait_till_ready(spi); + mt7621_spi_wait_till_ready(rs); mt7621_spi_set_cs(spi, 0); @@ -278,7 +277,7 @@ static int mt7621_spi_transfer_full_duplex(struct spi_master *master, u32 data[9] = { 0 }; u32 val = 0; - mt7621_spi_wait_till_ready(spi); + mt7621_spi_wait_till_ready(rs); list_for_each_entry(t, &m->transfers, transfer_list) { const u8 *buf = t->tx_buf; @@ -323,7 +322,7 @@ static int mt7621_spi_transfer_full_duplex(struct spi_master *master, val |= SPI_CTL_START; mt7621_spi_write(rs, MT7621_SPI_TRANS, val); - mt7621_spi_wait_till_ready(spi); + mt7621_spi_wait_till_ready(rs); mt7621_spi_set_cs(spi, 0); From bf732c6bff5b5767a1c2ec6495dccd76d71c05eb Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 7 Jun 2018 08:04:21 +1000 Subject: [PATCH 032/903] staging: mt7621-spi: revised half-duplex message handling The mt7621 SPI engine has a 32 byte buffer and the driver currently only allows 32-byte read requests and 36 bytes writes (there is a 4byte op/addr buffer). This is an unnecessary limitation. As the SPI clock is controlled by the host it is quite acceptable to send a larger message in multiple smaller transactions. As long as Chip Select is kept asserted the whole time, the SPI engine can be run multiple times for a single SPI message. This patch factors out the transaction logic and calls for each transfer in the message. A write transfer might leave bytes in the buffer to be combined with a following read transfer, as this is a common pattern. With this in place, we can remove the current max_transfer_size limit. In testing, this increases the read throughput for a NOR flash chip from 1.4MB/s to 2.3MB/s, a 50% improvement. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 167 ++++++++++++++---------- 1 file changed, 99 insertions(+), 68 deletions(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index d43576d2a3f9..11474e6ad01b 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -65,6 +65,7 @@ struct mt7621_spi { unsigned int sys_freq; unsigned int speed; struct clk *clk; + int pending_write; struct mt7621_spi_ops *ops; }; @@ -96,6 +97,7 @@ static void mt7621_spi_reset(struct mt7621_spi *rs, int duplex) master &= ~(1 << 10); mt7621_spi_write(rs, MT7621_SPI_MASTER, master); + rs->pending_write = 0; } static void mt7621_spi_set_cs(struct spi_device *spi, int enable) @@ -173,6 +175,92 @@ static inline int mt7621_spi_wait_till_ready(struct mt7621_spi *rs) return -ETIMEDOUT; } +static void mt7621_spi_read_half_duplex(struct mt7621_spi *rs, + int rx_len, u8 *buf) +{ + /* Combine with any pending write, and perform one or + * more half-duplex transactions reading 'len' bytes. + * Data to be written is already in MT7621_SPI_DATA* + */ + int tx_len = rs->pending_write; + + rs->pending_write = 0; + + while (rx_len || tx_len) { + int i; + u32 val = (min(tx_len, 4) * 8) << 24; + int rx = min(rx_len, 32); + + if (tx_len > 4) + val |= (tx_len - 4) * 8; + val |= (rx * 8) << 12; + mt7621_spi_write(rs, MT7621_SPI_MOREBUF, val); + + tx_len = 0; + + val = mt7621_spi_read(rs, MT7621_SPI_TRANS); + val |= SPI_CTL_START; + mt7621_spi_write(rs, MT7621_SPI_TRANS, val); + + mt7621_spi_wait_till_ready(rs); + + for (i = 0; i < rx; i++) { + if ((i % 4) == 0) + val = mt7621_spi_read(rs, MT7621_SPI_DATA0 + i); + *buf++ = val & 0xff; + val >>= 8; + } + rx_len -= i; + } +} + +static inline void mt7621_spi_flush(struct mt7621_spi *rs) +{ + mt7621_spi_read_half_duplex(rs, 0, NULL); +} + +static void mt7621_spi_write_half_duplex(struct mt7621_spi *rs, + int tx_len, const u8 *buf) +{ + int val = 0; + int len = rs->pending_write; + + if (len & 3) { + val = mt7621_spi_read(rs, MT7621_SPI_OPCODE + (len & ~3)); + if (len < 4) { + val <<= (4 - len) * 8; + val = swab32(val); + } + } + + while (tx_len > 0) { + if (len >= 36) { + rs->pending_write = len; + mt7621_spi_flush(rs); + len = 0; + } + + val |= *buf++ << (8 * (len & 3)); + len++; + if ((len & 3) == 0) { + if (len == 4) + /* The byte-order of the opcode is weird! */ + val = swab32(val); + mt7621_spi_write(rs, MT7621_SPI_OPCODE + len - 4, val); + val = 0; + } + tx_len -= 1; + } + if (len & 3) { + if (len < 4) { + val = swab32(val); + val >>= (4 - len) * 8; + } + mt7621_spi_write(rs, MT7621_SPI_OPCODE + (len & ~3), val); + } + rs->pending_write = len; +} + static int mt7621_spi_transfer_half_duplex(struct spi_master *master, struct spi_message *m) { @@ -181,82 +269,30 @@ static int mt7621_spi_transfer_half_duplex(struct spi_master *master, unsigned int speed = spi->max_speed_hz; struct spi_transfer *t = NULL; int status = 0; - int i, len = 0; - int rx_len = 0; - u32 data[9] = { 0 }; - u32 val; mt7621_spi_wait_till_ready(rs); - list_for_each_entry(t, &m->transfers, transfer_list) { - const u8 *buf = t->tx_buf; - - if (t->rx_buf) - rx_len += t->len; - - if (!buf) - continue; - + list_for_each_entry(t, &m->transfers, transfer_list) if (t->speed_hz < speed) speed = t->speed_hz; - if (WARN_ON(len + t->len > 36)) { - status = -EIO; - goto msg_done; - } - - for (i = 0; i < t->len; i++, len++) - data[len / 4] |= buf[i] << (8 * (len & 3)); - } - - if (WARN_ON(rx_len > 32)) { - status = -EIO; - goto msg_done; - } - if (mt7621_spi_prepare(spi, speed)) { status = -EIO; goto msg_done; } - data[0] = swab32(data[0]); - if (len < 4) - data[0] >>= (4 - len) * 8; - - for (i = 0; i < len; i += 4) - mt7621_spi_write(rs, MT7621_SPI_OPCODE + i, data[i / 4]); - - val = (min_t(int, len, 4) * 8) << 24; - if (len > 4) - val |= (len - 4) * 8; - val |= (rx_len * 8) << 12; - mt7621_spi_write(rs, MT7621_SPI_MOREBUF, val); mt7621_spi_set_cs(spi, 1); - - val = mt7621_spi_read(rs, MT7621_SPI_TRANS); - val |= SPI_CTL_START; - mt7621_spi_write(rs, MT7621_SPI_TRANS, val); - - mt7621_spi_wait_till_ready(rs); + m->actual_length = 0; + list_for_each_entry(t, &m->transfers, transfer_list) { + if (t->rx_buf) + mt7621_spi_read_half_duplex(rs, t->len, t->rx_buf); + else if (t->tx_buf) + mt7621_spi_write_half_duplex(rs, t->len, t->tx_buf); + m->actual_length += t->len; + } + mt7621_spi_flush(rs); mt7621_spi_set_cs(spi, 0); - - for (i = 0; i < rx_len; i += 4) - data[i / 4] = mt7621_spi_read(rs, MT7621_SPI_DATA0 + i); - - m->actual_length = len + rx_len; - - len = 0; - list_for_each_entry(t, &m->transfers, transfer_list) { - u8 *buf = t->rx_buf; - - if (!buf) - continue; - - for (i = 0; i < t->len; i++, len++) - buf[i] = data[len / 4] >> (8 * (len & 3)); - } - msg_done: m->status = status; spi_finalize_current_message(master); @@ -383,11 +419,6 @@ static const struct of_device_id mt7621_spi_match[] = { }; MODULE_DEVICE_TABLE(of, mt7621_spi_match); -static size_t max_transfer_size(struct spi_device *spi) -{ - return 32; -} - static int mt7621_spi_probe(struct platform_device *pdev) { const struct of_device_id *match; @@ -433,7 +464,6 @@ static int mt7621_spi_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_MASK(8); master->dev.of_node = pdev->dev.of_node; master->num_chipselect = 2; - master->max_transfer_size = max_transfer_size; dev_set_drvdata(&pdev->dev, master); @@ -443,6 +473,7 @@ static int mt7621_spi_probe(struct platform_device *pdev) rs->master = master; rs->sys_freq = clk_get_rate(rs->clk); rs->ops = ops; + rs->pending_write = 0; dev_info(&pdev->dev, "sys_freq: %u\n", rs->sys_freq); device_reset(&pdev->dev); From 97738374a310b9116f9c33832737e517226d3722 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 7 Jun 2018 08:04:21 +1000 Subject: [PATCH 033/903] staging: mt7621-dts: correct various clock frequencies. The MT7621 documentation says that the sys clock - also known as OCP clock for the Open Core Protocol - can be configured to 1/3 or 1/4 of the CPU clock. Testing on my hardware, using the fact that the SPI clock is based on the OCP clock and measuring transfer rates, shows a clock of a little over 200MHz with a CPU clock of 900MHz. So assume 1/4 is the default. Also, the nor-flash in the gbpc1 is documented as accepting 50MHz for request requests, and higher for other requests. So set maximum to 50MHz. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/gbpc1.dts | 5 +++-- drivers/staging/mt7621-dts/mt7621.dtsi | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index 6b13d85d9d34..47bcee51e016 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts @@ -74,7 +74,7 @@ #size-cells = <1>; compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <10000000>; + spi-max-frequency = <50000000>; partition@0 { label = "u-boot"; @@ -104,7 +104,8 @@ &sysclock { compatible = "fixed-clock"; - clock-frequency = <90000000>; + /* This is normally 1/4 of cpuclock */ + clock-frequency = <225000000>; }; &cpuclock { diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index eb3966b7f033..4a58e94c2060 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -38,8 +38,8 @@ #clock-cells = <0>; compatible = "fixed-clock"; - /* FIXME: there should be way to detect this */ - clock-frequency = <50000000>; + /* This is normally 1/4 of cpuclock */ + clock-frequency = <220000000>; }; palmbus: palmbus@1E000000 { From 1112b5b1c1936b69e801b42e8a22a79eac836ba8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 7 Jun 2018 08:04:21 +1000 Subject: [PATCH 034/903] staging: mt7621-dts: convert to gpio-keys Now that gpio-interrupts work correctly, we can use gpio-keys instead of gpio-keys-polled for the single push-button on the gbpc-1. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/gbpc1.dts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index 47bcee51e016..570d59e847bf 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts @@ -24,11 +24,8 @@ }; }; - gpio-keys-polled { - compatible = "gpio-keys-polled"; - #address-cells = <1>; - #size-cells = <0>; - poll-interval = <20>; + gpio-keys { + compatible = "gpio-keys"; reset { label = "reset"; From d42fd96ac281c348e87b57b0bc73b28b426a9761 Mon Sep 17 00:00:00 2001 From: Sankalp Negi Date: Sun, 3 Jun 2018 00:07:27 +0530 Subject: [PATCH 035/903] staging: mt7621-spi: Indent case labels and switch at the same level. The patch fixes following checkpatch.pl issue: ERROR : switch and case should be at the same indent Signed-off-by: Sankalp Negi Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index 11474e6ad01b..a28bbb87bebe 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -140,17 +140,17 @@ static int mt7621_spi_prepare(struct spi_device *spi, unsigned int speed) reg &= ~(MT7621_CPHA | MT7621_CPOL); switch(spi->mode & (SPI_CPOL | SPI_CPHA)) { - case SPI_MODE_0: - break; - case SPI_MODE_1: - reg |= MT7621_CPHA; - break; - case SPI_MODE_2: - reg |= MT7621_CPOL; - break; - case SPI_MODE_3: - reg |= MT7621_CPOL | MT7621_CPHA; - break; + case SPI_MODE_0: + break; + case SPI_MODE_1: + reg |= MT7621_CPHA; + break; + case SPI_MODE_2: + reg |= MT7621_CPOL; + break; + case SPI_MODE_3: + reg |= MT7621_CPOL | MT7621_CPHA; + break; } mt7621_spi_write(rs, MT7621_SPI_MASTER, reg); From b8a952784969fc0a5e25710fef7f26359b89d4ab Mon Sep 17 00:00:00 2001 From: Sankalp Negi Date: Sun, 3 Jun 2018 00:07:28 +0530 Subject: [PATCH 036/903] staging: mt7621-spi: Fix line over 80 characters by refactoring. The patch fixes following checkpatch.pl issue: WARNING : line over 80 characters Signed-off-by: Sankalp Negi Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index a28bbb87bebe..314e00520c6c 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -55,7 +55,8 @@ #define MT7621_CPOL BIT(4) #define MT7621_LSB_FIRST BIT(3) -#define RT2880_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | SPI_CS_HIGH) +#define RT2880_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | \ + SPI_LSB_FIRST | SPI_CS_HIGH) struct mt7621_spi; From 6781e751049c0bb7ccd1f684ca73da5c92c01e48 Mon Sep 17 00:00:00 2001 From: Sankalp Negi Date: Sun, 3 Jun 2018 00:07:29 +0530 Subject: [PATCH 037/903] staging: mt7621-spi: Use tabs for indentation instead of spaces. The patch fixes following checkpatch.pl issue: ERROR : code indent should use tabs where possible Signed-off-by: Sankalp Negi Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index 314e00520c6c..be892836b9ea 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -107,7 +107,7 @@ static void mt7621_spi_set_cs(struct spi_device *spi, int enable) int cs = spi->chip_select; u32 polar = 0; - mt7621_spi_reset(rs, cs); + mt7621_spi_reset(rs, cs); if (enable) polar = BIT(cs); mt7621_spi_write(rs, MT7621_SPI_POLAR, polar); From 6e89217cdb28809a039dad9c5cb321d408ca2473 Mon Sep 17 00:00:00 2001 From: Sankalp Negi Date: Sun, 3 Jun 2018 00:07:30 +0530 Subject: [PATCH 038/903] staging: mt7621-spi: Add a space before open paranthesis. The patch fixes following checkpatch.pl issue: ERROR : space required before the open parenthesis Signed-off-by: Sankalp Negi Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index be892836b9ea..e8cccb87a13f 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -140,7 +140,7 @@ static int mt7621_spi_prepare(struct spi_device *spi, unsigned int speed) reg |= MT7621_LSB_FIRST; reg &= ~(MT7621_CPHA | MT7621_CPOL); - switch(spi->mode & (SPI_CPOL | SPI_CPHA)) { + switch (spi->mode & (SPI_CPOL | SPI_CPHA)) { case SPI_MODE_0: break; case SPI_MODE_1: From 9c562d8411a54f6731cdc587c29968d9e8610c85 Mon Sep 17 00:00:00 2001 From: Sankalp Negi Date: Sun, 3 Jun 2018 00:07:31 +0530 Subject: [PATCH 039/903] staging: mt7621-spi: Remove unnecessary braces {} from single statement if block. The patch fixes following checkpatch.pl issue: WARNING : braces {} are not necessary for single statement blocks Signed-off-by: Sankalp Negi Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index e8cccb87a13f..d045b5568e0f 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -166,9 +166,8 @@ static inline int mt7621_spi_wait_till_ready(struct mt7621_spi *rs) u32 status; status = mt7621_spi_read(rs, MT7621_SPI_TRANS); - if ((status & SPITRANS_BUSY) == 0) { + if ((status & SPITRANS_BUSY) == 0) return 0; - } cpu_relax(); udelay(1); } From 0d6485282a2eb8839ecb98d4da2dc1c35aab7223 Mon Sep 17 00:00:00 2001 From: Abdun Nihaal Date: Sat, 9 Jun 2018 18:37:42 +0530 Subject: [PATCH 040/903] staging: mt7621-pci: Fix coding style error This patch removes space after * to fix the following checkpatch error: ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Abdun Nihaal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 5957205feb46..b373d761312a 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -181,7 +181,7 @@ static int pcie_link_status = 0; #define PCI_ACCESS_WRITE_4 5 static int config_access(unsigned char access_type, struct pci_bus *bus, - unsigned int devfn, unsigned int where, u32 * data) + unsigned int devfn, unsigned int where, u32 *data) { unsigned int slot = PCI_SLOT(devfn); u8 func = PCI_FUNC(devfn); @@ -222,19 +222,19 @@ static int config_access(unsigned char access_type, struct pci_bus *bus, } static int -read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 * val) +read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 *val) { return config_access(PCI_ACCESS_READ_1, bus, devfn, (unsigned int)where, (u32 *)val); } static int -read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 * val) +read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 *val) { return config_access(PCI_ACCESS_READ_2, bus, devfn, (unsigned int)where, (u32 *)val); } static int -read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 * val) +read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val) { return config_access(PCI_ACCESS_READ_4, bus, devfn, (unsigned int)where, (u32 *)val); } @@ -267,7 +267,7 @@ write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val) } static int -pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val) +pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { switch (size) { case 1: From 6de4ef65a8c6f53ce7eef06666410bc3b6e4b624 Mon Sep 17 00:00:00 2001 From: Hugo Lefeuvre Date: Wed, 13 Jun 2018 21:04:38 -0400 Subject: [PATCH 041/903] staging: pi433: fix race condition in pi433_ioctl In the PI433_IOC_WR_TX_CFG case in pi433_ioctl, instance->tx_cfg is modified via copy_from_user(&instance->tx_cfg, argp, sizeof(struct pi433_tx_cfg))) without any kind of synchronization. In the case where two threads would execute this same command concurrently the tx_cfg field might enter in an inconsistent state. Additionally: if ioctl(PI433_IOC_WR_TX_CFG) and write() execute concurrently the tx config might be modified while it is being copied to the fifo, resulting in potential data corruption. Fix: Get instance->tx_cfg_lock before modifying tx config in the PI433_IOC_WR_TX_CFG case in pi433_ioctl. Also, do not copy data directly from user space to instance->tx_cfg. Instead use a temporary buffer allowing future checks for correctness of copied data and simpler code. Signed-off-by: Hugo Lefeuvre Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index b061f77dda41..94e0bfcec991 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -880,6 +880,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) int retval = 0; struct pi433_instance *instance; struct pi433_device *device; + struct pi433_tx_cfg tx_cfg; void __user *argp = (void __user *)arg; /* Check type and command number */ @@ -902,9 +903,11 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return -EFAULT; break; case PI433_IOC_WR_TX_CFG: - if (copy_from_user(&instance->tx_cfg, argp, - sizeof(struct pi433_tx_cfg))) + if (copy_from_user(&tx_cfg, argp, sizeof(struct pi433_tx_cfg))) return -EFAULT; + mutex_lock(&device->tx_fifo_lock); + memcpy(&instance->tx_cfg, &tx_cfg, sizeof(struct pi433_tx_cfg)); + mutex_unlock(&device->tx_fifo_lock); break; case PI433_IOC_RD_RX_CFG: if (copy_to_user(argp, &device->rx_cfg, From 7695ff3084878aac6c7eec801cca6ea0a4735dda Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 6 Jun 2018 12:39:56 +0100 Subject: [PATCH 042/903] staging: rtl8192e: Add and remove blank lines - Coding style Simple addition & removal of blank lines as required Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_HTProc.c | 64 +++++-------------- 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 1b61a8de1edf..47b6add256d0 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -111,9 +111,8 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee) pHTInfo->UsbRxFwAggrPacketNum = 8; pHTInfo->UsbRxFwAggrTimeout = 16; ////usb rx FW aggregation timeout threshold.It's in units of 64us #endif - - } + /******************************************************************************************************************** *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq) * input: u8* CapIE //Capability IE to be printed out @@ -124,7 +123,6 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee) * *****************************************************************************************************************/ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) { - static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily PHT_CAPABILITY_ELE pCapELE; @@ -148,8 +146,8 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\ pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); return; - } + /******************************************************************************************************************** *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp) * input: u8* InfoIE //Capability IE to be printed out @@ -160,7 +158,6 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) * *****************************************************************************************************************/ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) { - static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily PHT_INFORMATION_ELE pHTInfoEle; @@ -261,7 +258,6 @@ static bool IsHTHalfNmodeSGI(struct ieee80211_device *ieee, bool is40MHz) u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) { - u8 is40MHz; u8 isShortGI; @@ -271,7 +267,6 @@ u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; } - u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -326,12 +321,11 @@ u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate) } } - - bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee) { bool retValue = false; struct ieee80211_network *net = &ieee->current_network; + if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || (memcmp(net->bssid, PCI_RALINK, 3) == 0) || @@ -364,6 +358,7 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; struct ieee80211_network *net = &ieee->current_network; + if (net->bssht.bdRT2RTAggregation) pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; else if (net->broadcom_cap_exist) @@ -389,6 +384,7 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer); } + /******************************************************************************************************************** *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good * at receiving MCS14~15 frame from some AP. @@ -402,7 +398,6 @@ static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 *PeerMacAddr) return 0; } - /** * Function: HTIOTActIsDisableMCS15 * @@ -496,6 +491,7 @@ static u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network) static u8 HTIOTActIsCCDFsync(u8 *PeerMacAddr) { u8 retValue = 0; + if ((memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3) == 0) || (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) == 0) || (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) == 0)) @@ -512,7 +508,6 @@ void HTResetIOTSetting( pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; } - /******************************************************************************************************************** *function: Construct Capablility Element in Beacon... if HTEnable is turned on * input: struct ieee80211_device* ieee @@ -536,13 +531,13 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u memset(posHTCap, 0, *len); if (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC) { u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily + memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]); } else { pCapELE = (PHT_CAPABILITY_ELE)posHTCap; } - //HT capability info pCapELE->AdvCoding = 0; // This feature is not supported now!! if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { @@ -566,7 +561,6 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u pCapELE->PSMP = 0; // Do not support now!! pCapELE->LSigTxopProtect = 0; // Do not support now!! - //MAC HT parameters info // TODO: Nedd to take care of this part IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); @@ -594,6 +588,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7. if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { int i; + for (i = 1; i < 16; i++) pCapELE->MCS[i] = 0; } @@ -601,7 +596,6 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u //Extended HT Capability Info memset(&pCapELE->ExtHTCapInfo, 0, 2); - //TXBF Capabilities memset(pCapELE->TxBFCap, 0, 4); @@ -613,15 +607,13 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u else *len = 26 + 2; - - // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTCap, *len -2); //Print each field in detail. Driver should not print out this message by default // HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()"); return; - } + /******************************************************************************************************************** *function: Construct Information Element in Beacon... if HTEnable is turned on * input: struct ieee80211_device* ieee @@ -636,6 +628,7 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le { PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo; + if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); return; @@ -661,9 +654,7 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le memset(pHTInfoEle->BasicMSC, 0, 16); - *len = 22 + 2; //same above - } else { //STA should not generate High Throughput Information Element *len = 0; @@ -733,20 +724,14 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, posRT2RTAgg->Octet[5] &= 0xfb; } */ - #else // Do Nothing #endif posRT2RTAgg->Length = 6; #endif - - - - } - /******************************************************************************************************************** *function: Pick the right Rate Adaptive table to use * input: struct ieee80211_device* ieee @@ -757,6 +742,7 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) { u8 i; + if (pOperateMCS == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); return false; @@ -787,9 +773,7 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) //should never reach here default: - break; - } return true; @@ -820,6 +804,7 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF u8 bitMap; u8 mcsRate = 0; u8 availableMcsRate[16]; + if (pMCSRateSet == NULL || pMCSFilter == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); return false; @@ -849,8 +834,6 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF return (mcsRate|0x80); } - - /* ** **1.Filter our operation rate set with AP's rate set @@ -863,7 +846,6 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, u8 *pOperateMCS) { - u8 i = 0; // filter out operational rate set not supported by AP, the length of it is 16 @@ -871,7 +853,6 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i]; } - // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet @@ -891,6 +872,7 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, return true; } + void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); void HTOnAssocRsp(struct ieee80211_device *ieee) { @@ -924,7 +906,6 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) else pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf); - //////////////////////////////////////////////////////// // Configurations: //////////////////////////////////////////////////////// @@ -957,7 +938,6 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK && (pPeerHTCap->DssCCk == 1); - // // Config and configure A-MSDU setting // @@ -969,8 +949,6 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize; else pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; - - // // Config A-MPDU setting // @@ -985,7 +963,6 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - } else { // Set MPDU density to 2 to Realtek AP, and set it to 0 for others // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily @@ -1056,9 +1033,6 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) // Config current operation mode. // pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - - - } void HTSetConnectBwModeCallback(struct ieee80211_device *ieee); @@ -1103,8 +1077,6 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - - // Initialize all of the parameters related to 11n memset((void *)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap)); memset((void *)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo)); @@ -1126,11 +1098,13 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) //MCS rate initialized here { u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); + RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7 RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15 RegHTSuppRateSets[4] = 0x01; //support MCS 32 } } + /******************************************************************************************************************** *function: initialize Bss HT structure(struct PBSS_HT) * input: PBSS_HT pBssHT //to be initialized @@ -1140,7 +1114,6 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) ********************************************************************************************************************/ void HTInitializeBssDesc(PBSS_HT pBssHT) { - pBssHT->bdSupportHT = false; memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf)); pBssHT->bdHTCapLen = 0; @@ -1152,6 +1125,7 @@ void HTInitializeBssDesc(PBSS_HT pBssHT) pBssHT->bdRT2RTAggregation = false; pBssHT->bdRT2RTLongSlotTime = false; } + /******************************************************************************************************************** *function: initialize Bss HT structure(struct PBSS_HT) * input: struct ieee80211_device *ieee @@ -1213,7 +1187,6 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802 if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS; - bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; @@ -1225,8 +1198,6 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802 bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC; - - } else { pHTInfo->bCurrentHTSupport = false; pHTInfo->bCurrentRT2RTAggregation = false; @@ -1234,7 +1205,6 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802 pHTInfo->IOTAction = 0; } - } void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork) @@ -1287,8 +1257,6 @@ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidt if (!pHTInfo->bRegBW40MHz) return; - - // To reduce dummy operation // if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) || // (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset)) From 4c53614f39431838674c6a9fbca4eedf9119f1ed Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 6 Jun 2018 12:39:57 +0100 Subject: [PATCH 043/903] staging: rtl8192e: Addition of prefered spacing - Coding style Added spaces around various operators, as preferred by coding style. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_HTProc.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 47b6add256d0..0db98c77a8e9 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -264,7 +264,7 @@ u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) is40MHz = (IsHTHalfNmode40Bandwidth(ieee)) ? 1 : 0; isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz)) ? 1 : 0; - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) @@ -275,7 +275,7 @@ u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) u8 isShortGI = (pHTInfo->bCurBW40MHz) ? ((pHTInfo->bCurShortGI40MHz) ? 1 : 0) : ((pHTInfo->bCurShortGI20MHz) ? 1 : 0); - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } /******************************************************************************************************************** @@ -317,7 +317,7 @@ u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate) //nDataRate = nDataRate - 60; } - return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf]; + return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate & 0xf]; } } @@ -823,15 +823,15 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF if (availableMcsRate[i] != 0) { bitMap = availableMcsRate[i]; for (j = 0; j < 8; j++) { - if ((bitMap%2) != 0) { - if (HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate)) - mcsRate = (8*i+j); + if ((bitMap % 2) != 0) { + if (HTMcsToDataRate(ieee, (8 * i + j)) > HTMcsToDataRate(ieee, mcsRate)) + mcsRate = (8 * i + j); } bitMap >>= 1; } } } - return (mcsRate|0x80); + return (mcsRate | 0x80); } /* @@ -850,7 +850,7 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, // filter out operational rate set not supported by AP, the length of it is 16 for (i = 0; i <= 15; i++) { - pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i]; + pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i] & pSupportMCS[i]; } // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number @@ -909,7 +909,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) //////////////////////////////////////////////////////// // Configurations: //////////////////////////////////////////////////////// - IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE)); + IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE)); // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE)); // Config Supported Channel Width setting // @@ -1303,9 +1303,9 @@ void HTSetConnectBwModeCallback(struct ieee80211_device *ieee) if (pHTInfo->bCurBW40MHz) { if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER) - ieee->set_chan(ieee->dev, ieee->current_network.channel+2); + ieee->set_chan(ieee->dev, ieee->current_network.channel + 2); else if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_LOWER) - ieee->set_chan(ieee->dev, ieee->current_network.channel-2); + ieee->set_chan(ieee->dev, ieee->current_network.channel - 2); else ieee->set_chan(ieee->dev, ieee->current_network.channel); From 3218202de96fef499dfa3ec17e031119bff38901 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 6 Jun 2018 12:39:58 +0100 Subject: [PATCH 044/903] staging: rtl8192e: Remove unnecessary return statements - Coding style Return statments from void functions are not required by the coding standard. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 0db98c77a8e9..65b2cd692ec8 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -145,7 +145,6 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity); IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\ pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); - return; } /******************************************************************************************************************** @@ -207,7 +206,6 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\ pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]); - return; } /* @@ -611,7 +609,6 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u //Print each field in detail. Driver should not print out this message by default // HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()"); - return; } /******************************************************************************************************************** @@ -661,7 +658,6 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le } //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTInfo, *len - 2); //HTDebugHTInfo(posHTInfo, "HTConstructInforElement"); - return; } /* From 355654ef2c0e74f2b6bd3e5178b743e1c81259a0 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 6 Jun 2018 12:39:59 +0100 Subject: [PATCH 045/903] staging: rtl8192e: Correct alignment of if statements - Coding Style Function HTIOTPeerDetermine used incorrect indentation in if statements. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 65b2cd692ec8..10d9c58680a2 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -362,16 +362,16 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) else if (net->broadcom_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3) == 0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) == 0) || - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) == 0) || - (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3) == 0)) + (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) == 0) || + (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) == 0) || + (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3) == 0)) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || - (memcmp(net->bssid, PCI_RALINK, 3) == 0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || - net->ralink_cap_exist) + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || + (memcmp(net->bssid, PCI_RALINK, 3) == 0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || + net->ralink_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_RALINK; else if (net->atheros_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS; From 786fe3b545b0afae5a7a49fb702b14cfc57e1a48 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 6 Jun 2018 12:40:00 +0100 Subject: [PATCH 046/903] staging: rtl8192e: Remove unrequired space at start of line - Coding Style Function HTIOTActIsDisableMCS14 contained spurious space at start of line. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 10d9c58680a2..981433f6c4f2 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -394,7 +394,7 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 *PeerMacAddr) { return 0; - } +} /** * Function: HTIOTActIsDisableMCS15 From 1247b2327762d6b4e32300b6ee15cc1f7458de26 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 6 Jun 2018 12:40:01 +0100 Subject: [PATCH 047/903] staging: rtl8192e: Correct declaration of HTResetIOTSetting - Coding Style Declaration of function was spread over three lines. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 981433f6c4f2..7ea516609d4c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -498,9 +498,7 @@ static u8 HTIOTActIsCCDFsync(u8 *PeerMacAddr) return retValue; } -void HTResetIOTSetting( - PRT_HIGH_THROUGHPUT pHTInfo -) +void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo) { pHTInfo->IOTAction = 0; pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; From 4b22ca814e700d5eec617bd3760d7044d097180b Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 6 Jun 2018 12:40:02 +0100 Subject: [PATCH 048/903] staging: rtl8192e: Optimise Comparison to NULL tests - Coding Style Change comparison to NULL to better adhere to coding standard. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 7ea516609d4c..9cca4a8f1cf5 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -520,7 +520,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u PHT_CAPABILITY_ELE pCapELE = NULL; //u8 bIsDeclareMCS13; - if ((posHTCap == NULL) || (pHT == NULL)) { + if (!posHTCap || !pHT) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); return; } @@ -624,7 +624,7 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo; - if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { + if (!posHTInfo || !pHTInfoEle) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); return; } @@ -687,7 +687,7 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le * *****************************************************************************************************************/ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len) { - if (posRT2RTAgg == NULL) { + if (!posRT2RTAgg) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); return; } @@ -737,7 +737,7 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) { u8 i; - if (pOperateMCS == NULL) { + if (!pOperateMCS) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); return false; } @@ -799,7 +799,7 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF u8 mcsRate = 0; u8 availableMcsRate[16]; - if (pMCSRateSet == NULL || pMCSFilter == NULL) { + if (!pMCSRateSet || !pMCSFilter) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); return false; } From 8df6d28548918be9573ce0b7b7df29250716676d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 8 Jun 2018 14:01:37 +0100 Subject: [PATCH 049/903] staging: rtl8192e: remove unnecessary parentheses - Coding Style Remove unneccessary parentheses, and removed unnecessary (void *) cast Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 9cca4a8f1cf5..5a48693e2cf3 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -529,7 +529,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); - pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]); + pCapELE = (PHT_CAPABILITY_ELE)&posHTCap[4]; } else { pCapELE = (PHT_CAPABILITY_ELE)posHTCap; } @@ -1072,10 +1072,10 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; // Initialize all of the parameters related to 11n - memset((void *)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap)); - memset((void *)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo)); - memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf)); - memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf)); + memset(&pHTInfo->SelfHTCap, 0, sizeof(pHTInfo->SelfHTCap)); + memset(&pHTInfo->SelfHTInfo, 0, sizeof(pHTInfo->SelfHTInfo)); + memset(&pHTInfo->PeerHTCapBuf, 0, sizeof(pHTInfo->PeerHTCapBuf)); + memset(&pHTInfo->PeerHTInfoBuf, 0, sizeof(pHTInfo->PeerHTInfoBuf)); pHTInfo->bSwBwInProgress = false; pHTInfo->ChnlOp = CHNLOP_NONE; @@ -1091,7 +1091,7 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) //MCS rate initialized here { - u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); + u8 *RegHTSuppRateSets = &ieee->RegHTSuppRateSet[0]; RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7 RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15 From e9d93154e59ebffdf536d40bee6001afd285daa2 Mon Sep 17 00:00:00 2001 From: Kenneth Lu Date: Sun, 10 Jun 2018 16:17:52 +0800 Subject: [PATCH 050/903] staging: rtl8192u: remove redundant variables Clean up W=1 warning: variable set but not used. Signed-off-by: Kenneth Lu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 -- drivers/staging/rtl8192u/r8192U_core.c | 7 +------ drivers/staging/rtl8192u/r8192U_dm.c | 3 +-- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index f2cdcc2bcab4..172165f4461a 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -894,7 +894,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, u16 fc, type, stype, sc; struct net_device_stats *stats; unsigned int frag; - u8 *payload; u16 ethertype; //added by amy for reorder u8 TID = 0; @@ -1275,7 +1274,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } //added by amy for reorder /* skb: hdr + (possible reassembled) full plaintext payload */ - payload = skb->data + hdrlen; //ethertype = (payload[6] << 8) | payload[7]; rxb = kmalloc(sizeof(struct ieee80211_rxb), GFP_ATOMIC); if (!rxb) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 8b17400f6c13..74c5865cf8c8 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3932,11 +3932,10 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, struct rtl_80211_hdr_3addr *hdr; u16 sc; - unsigned int frag, seq; + unsigned int seq; hdr = (struct rtl_80211_hdr_3addr *)buffer; sc = le16_to_cpu(hdr->seq_ctl); - frag = WLAN_GET_SEQ_FRAG(sc); seq = WLAN_GET_SEQ_SEQ(sc); /* to record the sequence number */ pcurrent_stats->Seq_Num = seq; @@ -4772,14 +4771,10 @@ static void rtl819xusb_process_received_packet( struct net_device *dev, struct ieee80211_rx_stats *pstats) { - u8 *frame; - u16 frame_len = 0; struct r8192_priv *priv = ieee80211_priv(dev); /* Get shifted bytes of Starting address of 802.11 header. */ pstats->virtual_address += get_rxpacket_shiftbytes_819xusb(pstats); - frame = pstats->virtual_address; - frame_len = pstats->packetlength; #ifdef TODO /* about HCT */ if (!Adapter->bInHctTest) CountRxErrStatistics(Adapter, pRfd); diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index e25b058dec26..c4e4e3ba394b 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -509,7 +509,7 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - bool bHighpowerstate, viviflag = false; + bool viviflag = false; DCMD_TXCMD_T tx_cmd; u8 powerlevelOFDM24G; int i = 0, j = 0, k = 0; @@ -524,7 +524,6 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) write_nic_byte(dev, 0x1ba, 0); priv->ieee80211->bdynamic_txpower_enable = false; - bHighpowerstate = priv->bDynamicTxHighPower; powerlevelOFDM24G = (u8)(priv->Pwr_Track>>24); RF_Type = priv->rf_type; From 3a29f43cc3160c3f5cde7b1779fc05ebe68a56e5 Mon Sep 17 00:00:00 2001 From: Kyle Buzby Date: Sun, 10 Jun 2018 22:09:30 -0500 Subject: [PATCH 051/903] staging: clocking-wizard: prefer 'help' in Kconfig Fixes the checkpatch warning: WARNING: prefer 'help' over '---help---' for new help texts +config COMMON_CLK_XLNX_CLKWZRD Signed-off-by: Kyle Buzby Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/clocking-wizard/Kconfig b/drivers/staging/clocking-wizard/Kconfig index 357af02c562c..aa57a5865556 100644 --- a/drivers/staging/clocking-wizard/Kconfig +++ b/drivers/staging/clocking-wizard/Kconfig @@ -5,5 +5,5 @@ config COMMON_CLK_XLNX_CLKWZRD tristate "Xilinx Clocking Wizard" depends on COMMON_CLK && OF - ---help--- + help Support for the Xilinx Clocking Wizard IP core clock generator. From 70ce2440e20833d1b08222749cba780291a66e30 Mon Sep 17 00:00:00 2001 From: Anton Vasilyev Date: Wed, 13 Jun 2018 20:34:43 +0300 Subject: [PATCH 052/903] staging: rts5208: add error handling into rtsx_probe If rtsx_probe() fails to allocate dev->chip, then release_everything() will crash on uninitialized dev->cmnd_ready complete. Patch adds error handling into rtsx_probe. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 38 +++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 70e0b8623110..69e6abe14abf 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -857,7 +857,7 @@ static int rtsx_probe(struct pci_dev *pci, dev->chip = kzalloc(sizeof(*dev->chip), GFP_KERNEL); if (!dev->chip) { err = -ENOMEM; - goto errout; + goto chip_alloc_fail; } spin_lock_init(&dev->reg_lock); @@ -879,7 +879,7 @@ static int rtsx_probe(struct pci_dev *pci, if (!dev->remap_addr) { dev_err(&pci->dev, "ioremap error\n"); err = -ENXIO; - goto errout; + goto ioremap_fail; } /* @@ -894,7 +894,7 @@ static int rtsx_probe(struct pci_dev *pci, if (!dev->rtsx_resv_buf) { dev_err(&pci->dev, "alloc dma buffer fail\n"); err = -ENXIO; - goto errout; + goto dma_alloc_fail; } dev->chip->host_cmds_ptr = dev->rtsx_resv_buf; dev->chip->host_cmds_addr = dev->rtsx_resv_buf_addr; @@ -915,7 +915,7 @@ static int rtsx_probe(struct pci_dev *pci, if (rtsx_acquire_irq(dev) < 0) { err = -EBUSY; - goto errout; + goto irq_acquire_fail; } pci_set_master(pci); @@ -935,14 +935,14 @@ static int rtsx_probe(struct pci_dev *pci, if (IS_ERR(th)) { dev_err(&pci->dev, "Unable to start control thread\n"); err = PTR_ERR(th); - goto errout; + goto control_thread_fail; } dev->ctl_thread = th; err = scsi_add_host(host, &pci->dev); if (err) { dev_err(&pci->dev, "Unable to add the scsi host\n"); - goto errout; + goto scsi_add_host_fail; } /* Start up the thread for delayed SCSI-device scanning */ @@ -950,18 +950,16 @@ static int rtsx_probe(struct pci_dev *pci, if (IS_ERR(th)) { dev_err(&pci->dev, "Unable to start the device-scanning thread\n"); complete(&dev->scanning_done); - quiesce_and_remove_host(dev); err = PTR_ERR(th); - goto errout; + goto scan_thread_fail; } /* Start up the thread for polling thread */ th = kthread_run(rtsx_polling_thread, dev, "rtsx-polling"); if (IS_ERR(th)) { dev_err(&pci->dev, "Unable to start the device-polling thread\n"); - quiesce_and_remove_host(dev); err = PTR_ERR(th); - goto errout; + goto scan_thread_fail; } dev->polling_thread = th; @@ -970,9 +968,25 @@ static int rtsx_probe(struct pci_dev *pci, return 0; /* We come here if there are any problems */ -errout: +scan_thread_fail: + quiesce_and_remove_host(dev); +scsi_add_host_fail: + complete(&dev->cmnd_ready); + wait_for_completion(&dev->control_exit); +control_thread_fail: + free_irq(dev->irq, (void *)dev); + rtsx_release_chip(dev->chip); +irq_acquire_fail: + dev->chip->host_cmds_ptr = NULL; + dev->chip->host_sg_tbl_ptr = NULL; + if (dev->chip->msi_en) + pci_disable_msi(dev->pci); +dma_alloc_fail: + iounmap(dev->remap_addr); +ioremap_fail: + kfree(dev->chip); +chip_alloc_fail: dev_err(&pci->dev, "%s failed\n", __func__); - release_everything(dev); return err; } From e986b667ea6a4af33e28997f950e4ff196ec8f36 Mon Sep 17 00:00:00 2001 From: Yisheng Xie Date: Wed, 6 Jun 2018 10:21:11 +0800 Subject: [PATCH 053/903] Staging: gdm724x: use match_string() helper match_string() returns the index of an array for a matching string, which can be used instead of open coded variant. Cc: Greg Kroah-Hartman Cc: Quytelda Kahja Cc: devel@driverdev.osuosl.org Signed-off-by: Yisheng Xie Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_tty.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index bf554f7c56ca..6e813693a766 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -33,7 +33,7 @@ static struct tty_driver *gdm_driver[TTY_MAX_COUNT]; static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR]; static DEFINE_MUTEX(gdm_table_lock); -static char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; +static const char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"}; static void gdm_port_destruct(struct tty_port *port) @@ -55,22 +55,14 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty) { struct gdm *gdm = NULL; int ret; - int i; - int j; - j = GDM_TTY_MINOR; - for (i = 0; i < TTY_MAX_COUNT; i++) { - if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) { - j = tty->index; - break; - } - } - - if (j == GDM_TTY_MINOR) + ret = match_string(DRIVER_STRING, TTY_MAX_COUNT, + tty->driver->driver_name); + if (ret < 0) return -ENODEV; mutex_lock(&gdm_table_lock); - gdm = gdm_table[i][j]; + gdm = gdm_table[ret][tty->index]; if (!gdm) { mutex_unlock(&gdm_table_lock); return -ENODEV; From 3d9241d652748cd94f333562da45e8bd85ff6a47 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 4 Jun 2018 10:59:07 +0530 Subject: [PATCH 054/903] staging: wilc1000: use list_head to maintain 'txq_entry_t' elements of tx queue Use list_head data structure for the doubly linked list instead of own implementation. Only 'txq_head' is required, so removed the txq_tail pointer from 'wilc' structure. Following functions are modified to provide data using list_head API's wilc_wlan_txq_remove() wilc_wlan_txq_remove_from_head() wilc_wlan_txq_add_to_tail() wilc_wlan_txq_add_to_head() wilc_wlan_txq_get_first() wilc_wlan_txq_get_next() Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 1 + drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +- drivers/staging/wilc1000/wilc_wlan.c | 61 +++++-------------- drivers/staging/wilc1000/wilc_wlan.h | 3 +- 4 files changed, 19 insertions(+), 49 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 02e6b1338440..eac719b5ad70 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1118,6 +1118,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, wl->io_type = io_type; wl->gpio = gpio; wl->hif_func = ops; + INIT_LIST_HEAD(&wl->txq_head.list); register_inetaddr_notifier(&g_dev_notifier); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index f2b07e8aedd7..e1fab734c82a 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -157,8 +157,7 @@ struct wilc { unsigned long txq_spinlock_flags; - struct txq_entry_t *txq_head; - struct txq_entry_t *txq_tail; + struct txq_entry_t txq_head; int txq_entries; int txq_exit; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index d4ebbf67e50b..857cc382b2d3 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -20,25 +20,14 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release) static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe) { - if (tqe == wilc->txq_head) { - wilc->txq_head = tqe->next; - if (wilc->txq_head) - wilc->txq_head->prev = NULL; - } else if (tqe == wilc->txq_tail) { - wilc->txq_tail = (tqe->prev); - if (wilc->txq_tail) - wilc->txq_tail->next = NULL; - } else { - tqe->prev->next = tqe->next; - tqe->next->prev = tqe->prev; - } + list_del(&tqe->list); wilc->txq_entries -= 1; } static struct txq_entry_t * wilc_wlan_txq_remove_from_head(struct net_device *dev) { - struct txq_entry_t *tqe; + struct txq_entry_t *tqe = NULL; unsigned long flags; struct wilc_vif *vif; struct wilc *wilc; @@ -47,15 +36,12 @@ wilc_wlan_txq_remove_from_head(struct net_device *dev) wilc = vif->wilc; spin_lock_irqsave(&wilc->txq_spinlock, flags); - if (wilc->txq_head) { - tqe = wilc->txq_head; - wilc->txq_head = tqe->next; - if (wilc->txq_head) - wilc->txq_head->prev = NULL; + if (!list_empty(&wilc->txq_head.list)) { + tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, + list); + list_del(&tqe->list); wilc->txq_entries -= 1; - } else { - tqe = NULL; } spin_unlock_irqrestore(&wilc->txq_spinlock, flags); return tqe; @@ -73,17 +59,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, spin_lock_irqsave(&wilc->txq_spinlock, flags); - if (!wilc->txq_head) { - tqe->next = NULL; - tqe->prev = NULL; - wilc->txq_head = tqe; - wilc->txq_tail = tqe; - } else { - tqe->next = NULL; - tqe->prev = wilc->txq_tail; - wilc->txq_tail->next = tqe; - wilc->txq_tail = tqe; - } + list_add_tail(&tqe->list, &wilc->txq_head.list); wilc->txq_entries += 1; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -101,17 +77,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, spin_lock_irqsave(&wilc->txq_spinlock, flags); - if (!wilc->txq_head) { - tqe->next = NULL; - tqe->prev = NULL; - wilc->txq_head = tqe; - wilc->txq_tail = tqe; - } else { - tqe->next = wilc->txq_head; - tqe->prev = NULL; - wilc->txq_head->prev = tqe; - wilc->txq_head = tqe; - } + list_add(&tqe->list, &wilc->txq_head.list); wilc->txq_entries += 1; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -402,12 +368,14 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc) { - struct txq_entry_t *tqe; + struct txq_entry_t *tqe = NULL; unsigned long flags; spin_lock_irqsave(&wilc->txq_spinlock, flags); - tqe = wilc->txq_head; + if (!list_empty(&wilc->txq_head.list)) + tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, + list); spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -421,7 +389,10 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, spin_lock_irqsave(&wilc->txq_spinlock, flags); - tqe = tqe->next; + if (!list_is_last(&tqe->list, &wilc->txq_head.list)) + tqe = list_next_entry(tqe, list); + else + tqe = NULL; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); return tqe; diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index a5b9c68e1b9c..e0ff3e8c0836 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -207,8 +207,7 @@ ********************************************/ struct txq_entry_t { - struct txq_entry_t *next; - struct txq_entry_t *prev; + struct list_head list; int type; int tcp_pending_ack_idx; u8 *buffer; From 6adc35d973018a13076b36e85a2774fdcc24608b Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 4 Jun 2018 10:59:08 +0530 Subject: [PATCH 055/903] staging: wilc1000: use list_head to maintain 'rxq_entry_t elements in rx queue Make use of 'list_head' data structure to maintain the rx buffer queue. Modified wilc_wlan_rxq_add() to add the element at the tail by using list_head API and wilc_wlan_rxq_remove() to remove the element from head. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 1 + drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +-- drivers/staging/wilc1000/wilc_wlan.c | 26 +++++++------------ drivers/staging/wilc1000/wilc_wlan.h | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index eac719b5ad70..0019bb8df6c1 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1119,6 +1119,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, wl->gpio = gpio; wl->hif_func = ops; INIT_LIST_HEAD(&wl->txq_head.list); + INIT_LIST_HEAD(&wl->rxq_head.list); register_inetaddr_notifier(&g_dev_notifier); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index e1fab734c82a..ba57f42755f5 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -161,8 +161,7 @@ struct wilc { int txq_entries; int txq_exit; - struct rxq_entry_t *rxq_head; - struct rxq_entry_t *rxq_tail; + struct rxq_entry_t rxq_head; int rxq_entries; int rxq_exit; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 857cc382b2d3..059c5c73ee68 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -404,15 +404,7 @@ static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) return 0; mutex_lock(&wilc->rxq_cs); - if (!wilc->rxq_head) { - rqe->next = NULL; - wilc->rxq_head = rqe; - wilc->rxq_tail = rqe; - } else { - wilc->rxq_tail->next = rqe; - rqe->next = NULL; - wilc->rxq_tail = rqe; - } + list_add_tail(&rqe->list, &wilc->rxq_head.list); wilc->rxq_entries += 1; mutex_unlock(&wilc->rxq_cs); return wilc->rxq_entries; @@ -420,17 +412,17 @@ static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) { - if (wilc->rxq_head) { - struct rxq_entry_t *rqe; + struct rxq_entry_t *rqe = NULL; - mutex_lock(&wilc->rxq_cs); - rqe = wilc->rxq_head; - wilc->rxq_head = wilc->rxq_head->next; + mutex_lock(&wilc->rxq_cs); + if (!list_empty(&wilc->rxq_head.list)) { + rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t, + list); + list_del(&rqe->list); wilc->rxq_entries -= 1; - mutex_unlock(&wilc->rxq_cs); - return rqe; } - return NULL; + mutex_unlock(&wilc->rxq_cs); + return rqe; } void chip_allow_sleep(struct wilc *wilc) diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index e0ff3e8c0836..dbdebf009024 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -218,7 +218,7 @@ struct txq_entry_t { }; struct rxq_entry_t { - struct rxq_entry_t *next; + struct list_head list; u8 *buffer; int buffer_size; }; From 42e4a3adb0e211f4c222cd9297095a51a78769e2 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 4 Jun 2018 10:59:09 +0530 Subject: [PATCH 056/903] staging: wilc1000: remove 'rxq_entries' from 'wilc' struct Removed unnecessary 'rxq_entries' element from 'wilc' struct, as its value is not used. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 - drivers/staging/wilc1000/wilc_wlan.c | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index ba57f42755f5..afba37296346 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -162,7 +162,6 @@ struct wilc { int txq_exit; struct rxq_entry_t rxq_head; - int rxq_entries; int rxq_exit; unsigned char eth_src_address[NUM_CONCURRENT_IFC][6]; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 059c5c73ee68..26252d15f56a 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -398,16 +398,14 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, return tqe; } -static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) +static void wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) { if (wilc->quit) - return 0; + return; mutex_lock(&wilc->rxq_cs); list_add_tail(&rqe->list, &wilc->rxq_head.list); - wilc->rxq_entries += 1; mutex_unlock(&wilc->rxq_cs); - return wilc->rxq_entries; } static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) @@ -419,7 +417,6 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t, list); list_del(&rqe->list); - wilc->rxq_entries -= 1; } mutex_unlock(&wilc->rxq_cs); return rqe; From 089a137ad23a7b970b2c05bdb25937b96eab1700 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 4 Jun 2018 10:59:10 +0530 Subject: [PATCH 057/903] staging: wilc1000: move 'txq_spinlock_flags' from 'wilc' structure to local variable Cleanup patch to remove 'txq_spinlock_flags' element in 'wilc' and used local variable 'flag' in wilc_wlan_txq_filter_dup_tcp_ack(). Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 -- drivers/staging/wilc1000/wilc_wlan.c | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index afba37296346..fe18ae9843db 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -155,8 +155,6 @@ struct wilc { u32 rx_buffer_offset; u8 *tx_buffer; - unsigned long txq_spinlock_flags; - struct txq_entry_t txq_head; int txq_entries; int txq_exit; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 26252d15f56a..55755d7fbb30 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -219,11 +219,12 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) struct wilc *wilc; u32 i = 0; u32 dropped = 0; + unsigned long flags; vif = netdev_priv(dev); wilc = vif->wilc; - spin_lock_irqsave(&wilc->txq_spinlock, wilc->txq_spinlock_flags); + spin_lock_irqsave(&wilc->txq_spinlock, flags); for (i = pending_base; i < (pending_base + pending_acks); i++) { u32 session_index; u32 bigger_ack_num; @@ -261,7 +262,7 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) else pending_base = 0; - spin_unlock_irqrestore(&wilc->txq_spinlock, wilc->txq_spinlock_flags); + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); while (dropped > 0) { wait_for_completion_timeout(&wilc->txq_event, From 1daddbc8dec56e3c656ade8e5e6ef20a1be68823 Mon Sep 17 00:00:00 2001 From: Fabio Rafael da Rosa Date: Sun, 3 Jun 2018 23:24:45 -0300 Subject: [PATCH 058/903] staging: vboxvideo: Update driver to use drm_dev_register. The use of load and unload hooks is deprecated. DRM drivers should use drm_dev_alloc|drm_dev_init and drm_dev_register for initialization and publishing. Signed-off-by: Fabio Rafael da Rosa Reviewed-by: Nicholas Mc Guire Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/TODO | 1 - drivers/staging/vboxvideo/vbox_drv.c | 34 +++++++++++++++++++++++---- drivers/staging/vboxvideo/vbox_drv.h | 2 +- drivers/staging/vboxvideo/vbox_main.c | 2 +- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vboxvideo/TODO b/drivers/staging/vboxvideo/TODO index bd381d861ab3..468eea856ca6 100644 --- a/drivers/staging/vboxvideo/TODO +++ b/drivers/staging/vboxvideo/TODO @@ -1,6 +1,5 @@ TODO: -Move the driver over to the atomic API --Stop using old load / unload drm_driver hooks -Get a full review from the drm-maintainers on dri-devel done on this driver -Extend this TODO with the results of that review diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index f6d26beffa54..da92c493f157 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -51,14 +51,42 @@ MODULE_DEVICE_TABLE(pci, pciidlist); static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - return drm_get_pci_dev(pdev, ent, &driver); + struct drm_device *dev = NULL; + int ret = 0; + + dev = drm_dev_alloc(&driver, &pdev->dev); + if (IS_ERR(dev)) { + ret = PTR_ERR(dev); + goto err_drv_alloc; + } + dev->pdev = pdev; + pci_set_drvdata(pdev, dev); + + ret = vbox_driver_load(dev); + if (ret) + goto err_vbox_driver_load; + + ret = drm_dev_register(dev, 0); + if (ret) + goto err_drv_dev_register; + + return ret; + + err_drv_dev_register: + vbox_driver_unload(dev); + err_vbox_driver_load: + drm_dev_put(dev); + err_drv_alloc: + return ret; } static void vbox_pci_remove(struct pci_dev *pdev) { struct drm_device *dev = pci_get_drvdata(pdev); - drm_put_dev(dev); + drm_dev_unregister(dev); + vbox_driver_unload(dev); + drm_dev_put(dev); } static int vbox_drm_freeze(struct drm_device *dev) @@ -227,8 +255,6 @@ static struct drm_driver driver = { DRIVER_PRIME, .dev_priv_size = 0, - .load = vbox_driver_load, - .unload = vbox_driver_unload, .lastclose = vbox_driver_lastclose, .master_set = vbox_master_set, .master_drop = vbox_master_drop, diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index eeac4f0cb2c6..594f84272957 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -126,7 +126,7 @@ struct vbox_private { #undef CURSOR_PIXEL_COUNT #undef CURSOR_DATA_SIZE -int vbox_driver_load(struct drm_device *dev, unsigned long flags); +int vbox_driver_load(struct drm_device *dev); void vbox_driver_unload(struct drm_device *dev); void vbox_driver_lastclose(struct drm_device *dev); diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index 9d2018cd544e..429f6a453619 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -350,7 +350,7 @@ static void vbox_hw_fini(struct vbox_private *vbox) pci_iounmap(vbox->dev->pdev, vbox->guest_heap); } -int vbox_driver_load(struct drm_device *dev, unsigned long flags) +int vbox_driver_load(struct drm_device *dev) { struct vbox_private *vbox; int ret = 0; From ca707dcadecff31ee5e1bda474018d68ae9c6fc1 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 6 Jun 2018 09:06:00 +0100 Subject: [PATCH 059/903] staging: vc04_services: make a couple of pointers static The pointers vchiq_dbg_dir and vchiq_dbg_clients are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnings: warning: symbol 'vchiq_dbg_dir' was not declared. Should it be static? warning: symbol 'vchiq_dbg_clients' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c index 38805504d462..6a9e71a61142 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -52,8 +52,8 @@ #define VCHIQ_LOG_TRACE_STR "trace" /* Global 'vchiq' debugfs and clients entry used by all instances */ -struct dentry *vchiq_dbg_dir; -struct dentry *vchiq_dbg_clients; +static struct dentry *vchiq_dbg_dir; +static struct dentry *vchiq_dbg_clients; /* Log category debugfs entries */ struct vchiq_debugfs_log_entry { From dba1b8ac7391f056019e419c9ba4f76dcc46aa96 Mon Sep 17 00:00:00 2001 From: Sabin Mihai Rapan Date: Sat, 2 Jun 2018 11:04:12 +0200 Subject: [PATCH 060/903] staging: rtlwifi: Fix "Trafic"->"Traffic" Trivial fix to spelling mistake in comment text. Signed-off-by: Sabin Mihai Rapan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm.c b/drivers/staging/rtlwifi/phydm/phydm.c index 985978d3decc..27635feedba2 100644 --- a/drivers/staging/rtlwifi/phydm/phydm.c +++ b/drivers/staging/rtlwifi/phydm/phydm.c @@ -149,7 +149,7 @@ static void phydm_traffic_load_decision(void *dm_void) { struct phy_dm_struct *dm = (struct phy_dm_struct *)dm_void; - /*---TP & Trafic-load calculation---*/ + /*---TP & Traffic-load calculation---*/ if (dm->last_tx_ok_cnt > *dm->num_tx_bytes_unicast) dm->last_tx_ok_cnt = *dm->num_tx_bytes_unicast; From 971f3f119d30ce3cdbe58de74768a445893f9d20 Mon Sep 17 00:00:00 2001 From: Sabin Mihai Rapan Date: Sat, 2 Jun 2018 11:04:13 +0200 Subject: [PATCH 061/903] staging: rtlwifi: Fix "writen"->"written" Trivial fix to spelling mistake in comment text. Signed-off-by: Sabin Mihai Rapan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/rtl8822be/fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c b/drivers/staging/rtlwifi/rtl8822be/fw.c index efec7281511c..a40396614814 100644 --- a/drivers/staging/rtlwifi/rtl8822be/fw.c +++ b/drivers/staging/rtlwifi/rtl8822be/fw.c @@ -82,7 +82,7 @@ static void _rtl8822be_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id, } while (!bwrite_success) { - /* 2. Find the last BOX number which has been writen. */ + /* 2. Find the last BOX number which has been written. */ boxnum = rtlhal->last_hmeboxnum; switch (boxnum) { case 0: From 91c458b435df86d733754b3d50d8a5d1848c51dc Mon Sep 17 00:00:00 2001 From: Sabin Mihai Rapan Date: Sat, 2 Jun 2018 11:04:14 +0200 Subject: [PATCH 062/903] staging: rtlwifi: Fix "Alwyas"->"Always" Trivial fix to spelling mistake in comment text. Signed-off-by: Sabin Mihai Rapan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/rtl8822be/sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/rtl8822be/sw.c b/drivers/staging/rtlwifi/rtl8822be/sw.c index 7825e85ed091..a2ab19fa94f2 100644 --- a/drivers/staging/rtlwifi/rtl8822be/sw.c +++ b/drivers/staging/rtlwifi/rtl8822be/sw.c @@ -43,7 +43,7 @@ static void rtl8822be_init_aspm_vars(struct ieee80211_hw *hw) * 0 - Disable ASPM, * 1 - Enable ASPM without Clock Req, * 2 - Enable ASPM with Clock Req, - * 3 - Alwyas Enable ASPM with Clock Req, + * 3 - Always Enable ASPM with Clock Req, * 4 - Always Enable ASPM without Clock Req. * set default to RTL8822BE:3 RTL8822B:2 * From 5df204016c36a175829e6579f01244a8e2351480 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 7 Jun 2018 01:34:02 +0200 Subject: [PATCH 063/903] staging: rtl8723bs: drop test The test selects between two identical values, so it doesn't look useful. It turns out that the tested expression can only be true anyway, so drop the test, the corresponding parameter, and the corresponding argument at the only call site. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression e,e1; @@ * e ? e1 : e1 // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c index 2ee25b2471de..53d3bdf21a6f 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c @@ -1352,7 +1352,6 @@ static void _PHY_ReloadMACRegisters8723B( static void _PHY_PathADDAOn8723B( struct adapter *padapter, u32 *ADDAReg, - bool isPathAOn, bool is2T ) { @@ -1363,7 +1362,7 @@ static void _PHY_PathADDAOn8723B( ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n")); - pathOn = isPathAOn ? 0x01c00014 : 0x01c00014; + pathOn = 0x01c00014; if (false == is2T) { pathOn = 0x01c00014; PHY_SetBBReg(pDM_Odm->Adapter, ADDAReg[0], bMaskDWord, 0x01c00014); @@ -1556,7 +1555,7 @@ static void phy_IQCalibrate_8723B( } ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2T ? "2T2R" : "1T1R"), t)); - _PHY_PathADDAOn8723B(padapter, ADDA_REG, true, is2T); + _PHY_PathADDAOn8723B(padapter, ADDA_REG, is2T); /* no serial mode */ From a75647d1e72f0af686b19940b864f35b9be631d6 Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Mon, 4 Jun 2018 14:08:19 -0700 Subject: [PATCH 064/903] staging: goldfish: Replace read and write macros with functions Functions are less error-prone and generate cleaner compilation. Signed-off-by: Roman Kiryanov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 46 +++++++++++++++-------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index bd559956f199..3a4715cd362b 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -61,11 +61,6 @@ struct goldfish_audio { #define COMBINED_BUFFER_SIZE ((2 * READ_BUFFER_SIZE) + \ (2 * WRITE_BUFFER_SIZE)) -#define AUDIO_READ(data, addr) (readl(data->reg_base + addr)) -#define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr)) -#define AUDIO_WRITE64(data, addr, addr2, x) \ - (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base + addr2)) - /* * temporary variable used between goldfish_audio_probe() and * goldfish_audio_open() @@ -112,6 +107,25 @@ enum { static atomic_t open_count = ATOMIC_INIT(0); +static unsigned int audio_read(const struct goldfish_audio *data, int addr) +{ + return readl(data->reg_base + addr); +} + +static void audio_write(const struct goldfish_audio *data, + int addr, unsigned int x) +{ + writel(x, data->reg_base + addr); +} + +static void audio_write64(const struct goldfish_audio *data, + int addr_lo, int addr_hi, unsigned int x) +{ + char __iomem *reg_base = data->reg_base; + + gf_write_dma_addr(x, reg_base + addr_lo, reg_base + addr_hi); +} + static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, size_t count, loff_t *pos) { @@ -124,12 +138,12 @@ static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, while (count > 0) { length = (count > READ_BUFFER_SIZE ? READ_BUFFER_SIZE : count); - AUDIO_WRITE(data, AUDIO_START_READ, length); + audio_write(data, AUDIO_START_READ, length); wait_event_interruptible(data->wait, data->buffer_status & AUDIO_INT_READ_BUFFER_FULL); - length = AUDIO_READ(data, AUDIO_READ_BUFFER_AVAILABLE); + length = audio_read(data, AUDIO_READ_BUFFER_AVAILABLE); /* copy data to user space */ if (copy_to_user(buf, data->read_buffer, length)) @@ -177,10 +191,10 @@ static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf, */ if (kbuf == data->write_buffer1) { data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_1_EMPTY; - AUDIO_WRITE(data, AUDIO_WRITE_BUFFER_1, copy); + audio_write(data, AUDIO_WRITE_BUFFER_1, copy); } else { data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_2_EMPTY; - AUDIO_WRITE(data, AUDIO_WRITE_BUFFER_2, copy); + audio_write(data, AUDIO_WRITE_BUFFER_2, copy); } spin_unlock_irqrestore(&data->lock, irq_flags); @@ -200,7 +214,7 @@ static int goldfish_audio_open(struct inode *ip, struct file *fp) fp->private_data = audio_data; audio_data->buffer_status = (AUDIO_INT_WRITE_BUFFER_1_EMPTY | AUDIO_INT_WRITE_BUFFER_2_EMPTY); - AUDIO_WRITE(audio_data, AUDIO_INT_ENABLE, AUDIO_INT_MASK); + audio_write(audio_data, AUDIO_INT_ENABLE, AUDIO_INT_MASK); return 0; } @@ -212,7 +226,7 @@ static int goldfish_audio_release(struct inode *ip, struct file *fp) { atomic_dec(&open_count); /* FIXME: surely this is wrong for the multi-opened case */ - AUDIO_WRITE(audio_data, AUDIO_INT_ENABLE, 0); + audio_write(audio_data, AUDIO_INT_ENABLE, 0); return 0; } @@ -235,7 +249,7 @@ static irqreturn_t goldfish_audio_interrupt(int irq, void *dev_id) spin_lock_irqsave(&data->lock, irq_flags); /* read buffer status flags */ - status = AUDIO_READ(data, AUDIO_INT_STATUS); + status = audio_read(data, AUDIO_INT_STATUS); status &= AUDIO_INT_MASK; /* * if buffers are newly empty, wake up blocked @@ -320,18 +334,18 @@ static int goldfish_audio_probe(struct platform_device *pdev) return ret; } - AUDIO_WRITE64(data, AUDIO_SET_WRITE_BUFFER_1, + audio_write64(data, AUDIO_SET_WRITE_BUFFER_1, AUDIO_SET_WRITE_BUFFER_1_HIGH, buf_addr); buf_addr += WRITE_BUFFER_SIZE; - AUDIO_WRITE64(data, AUDIO_SET_WRITE_BUFFER_2, + audio_write64(data, AUDIO_SET_WRITE_BUFFER_2, AUDIO_SET_WRITE_BUFFER_2_HIGH, buf_addr); buf_addr += WRITE_BUFFER_SIZE; - data->read_supported = AUDIO_READ(data, AUDIO_READ_SUPPORTED); + data->read_supported = audio_read(data, AUDIO_READ_SUPPORTED); if (data->read_supported) - AUDIO_WRITE64(data, AUDIO_SET_READ_BUFFER, + audio_write64(data, AUDIO_SET_READ_BUFFER, AUDIO_SET_READ_BUFFER_HIGH, buf_addr); audio_data = data; From 06e526f49b7a8280c62710265b699254a7cf3344 Mon Sep 17 00:00:00 2001 From: Yu Ning Date: Mon, 4 Jun 2018 14:08:21 -0700 Subject: [PATCH 065/903] staging: goldfish: Enable ACPI-based enumeration for goldfish audio Add an ACPI id to make goldfish audio to support ACPI enumeration. Signed-off-by: Yu Ning Signed-off-by: Roman Kiryanov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 3a4715cd362b..14e962ddfc3d 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -28,6 +28,7 @@ #include #include #include +#include MODULE_AUTHOR("Google, Inc."); MODULE_DESCRIPTION("Android QEMU Audio Driver"); @@ -365,12 +366,21 @@ static const struct of_device_id goldfish_audio_of_match[] = { }; MODULE_DEVICE_TABLE(of, goldfish_audio_of_match); +#ifdef CONFIG_ACPI +static const struct acpi_device_id goldfish_audio_acpi_match[] = { + { "GFSH0005", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, goldfish_audio_acpi_match); +#endif + static struct platform_driver goldfish_audio_driver = { .probe = goldfish_audio_probe, .remove = goldfish_audio_remove, .driver = { .name = "goldfish_audio", .of_match_table = goldfish_audio_of_match, + .acpi_match_table = ACPI_PTR(goldfish_audio_acpi_match), } }; From 3053339b17f8f3bf0e4f5350adb7097266cd6f1a Mon Sep 17 00:00:00 2001 From: Joshua Lang Date: Mon, 4 Jun 2018 14:08:22 -0700 Subject: [PATCH 066/903] staging: goldfish: Clear audio read buffer status after each read The buffer_status field is interrupt updated. After every read request, the buffer_status read field should be reset so that on the next loop iteration we don't read a stale value and read data before the device is ready. Signed-off-by: Joshua Lang Signed-off-by: Roman Kiryanov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 14e962ddfc3d..0b7c49c4dcb0 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -131,6 +131,7 @@ static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, size_t count, loff_t *pos) { struct goldfish_audio *data = fp->private_data; + unsigned long irq_flags; int length; int result = 0; @@ -144,6 +145,10 @@ static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, wait_event_interruptible(data->wait, data->buffer_status & AUDIO_INT_READ_BUFFER_FULL); + spin_lock_irqsave(&data->lock, irq_flags); + data->buffer_status &= ~AUDIO_INT_READ_BUFFER_FULL; + spin_unlock_irqrestore(&data->lock, irq_flags); + length = audio_read(data, AUDIO_READ_BUFFER_AVAILABLE); /* copy data to user space */ From eee222db377e19c708f821e2d9074f00979e2478 Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Fri, 15 Jun 2018 15:57:21 -0700 Subject: [PATCH 067/903] staging: goldfish: Fix checkpatch CHECK in goldfish_audio.c Fix "CHECK: Alignment should match open parenthesis" Signed-off-by: Roman Kiryanov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 0b7c49c4dcb0..b7004edd3ce2 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -315,7 +315,8 @@ static int goldfish_audio_probe(struct platform_device *pdev) return -ENODEV; } data->buffer_virt = dmam_alloc_coherent(&pdev->dev, - COMBINED_BUFFER_SIZE, &buf_addr, GFP_KERNEL); + COMBINED_BUFFER_SIZE, + &buf_addr, GFP_KERNEL); if (!data->buffer_virt) { dev_err(&pdev->dev, "allocate buffer failed\n"); return -ENOMEM; From 50b1cf85b12d36891582cd56929ee83038f1405b Mon Sep 17 00:00:00 2001 From: ankit patel Date: Fri, 15 Jun 2018 13:42:12 -0500 Subject: [PATCH 068/903] Staging: comedi: comedi.h: fixed missing or malformed SPDX-License-Identifier Fixed SPDX-License-Identifier comment on first line Signed-off-by: ankit patel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index c0bc413f7fe0..bb961ac79b7e 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: LGPL-2.0+ +/* SPDX-License-Identifier: LGPL-2.0+ */ /* * comedi.h * header file for COMEDI user API From be932c686bb0a0cfe99c37a38c0675c106bfba1b Mon Sep 17 00:00:00 2001 From: ankit patel Date: Fri, 15 Jun 2018 13:42:16 -0500 Subject: [PATCH 069/903] Staging: comedi: comedilib.h: fixed missing or malformed SPDX-License-Identifier Fixed SPDX-License-Identifier comment on first line Signed-off-by: ankit patel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index e98cb9752dbc..0223c9cd9215 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedilib.h * Header file for kcomedilib From 46c851a92872ae32810f774c6aa439fdc23bb5fa Mon Sep 17 00:00:00 2001 From: ankit patel Date: Fri, 15 Jun 2018 13:42:15 -0500 Subject: [PATCH 070/903] Staging: comedi: comedi_pcmcia.h: fixed missing or malformed SPDX-License-Identifier Fixed SPDX-License-Identifier comment on first line Signed-off-by: ankit patel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_pcmcia.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_pcmcia.h b/drivers/staging/comedi/comedi_pcmcia.h index c7d37b38e730..f2f6e779645b 100644 --- a/drivers/staging/comedi/comedi_pcmcia.h +++ b/drivers/staging/comedi/comedi_pcmcia.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedi_pcmcia.h * header file for Comedi PCMCIA drivers From aa4c8dc649a046e523880f3ef2b1addc7ce45c9b Mon Sep 17 00:00:00 2001 From: ankit patel Date: Fri, 15 Jun 2018 13:42:14 -0500 Subject: [PATCH 071/903] Staging: comedi: comedi_pci.h: fixed missing or malformed SPDX-License-Identifier Fixed SPDX-License-Identifier comment on first line Signed-off-by: ankit patel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_pci.h b/drivers/staging/comedi/comedi_pci.h index 647a72441b8a..4e069440cbdc 100644 --- a/drivers/staging/comedi/comedi_pci.h +++ b/drivers/staging/comedi/comedi_pci.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedi_pci.h * header file for Comedi PCI drivers From 6557dd49369c2a9cfc21988bc0f793fa7ed54c01 Mon Sep 17 00:00:00 2001 From: ankit patel Date: Fri, 15 Jun 2018 13:42:13 -0500 Subject: [PATCH 072/903] Staging: comedi: comedi_compat32.h: fixed missing or malformed SPDX-License-Identifier Fixed SPDX-License-Identifier comment on first line Signed-off-by: ankit patel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_compat32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_compat32.h b/drivers/staging/comedi/comedi_compat32.h index 3980e6e1bd0d..dc3e2a9442c7 100644 --- a/drivers/staging/comedi/comedi_compat32.h +++ b/drivers/staging/comedi/comedi_compat32.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedi/comedi_compat32.h * 32-bit ioctl compatibility for 64-bit comedi kernel module. From 67cc414e6474eeee6f7c948cc420e4b247a7e0e3 Mon Sep 17 00:00:00 2001 From: Andreas Klinger Date: Sat, 23 Jun 2018 20:55:18 +0200 Subject: [PATCH 073/903] iio: hx711: add maintainer for driver add a maintainer for driver hx711 Signed-off-by: Andreas Klinger Signed-off-by: Jonathan Cameron --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8db4875b1fa9..00e9670717f4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2545,6 +2545,13 @@ S: Maintained F: drivers/auxdisplay/ F: include/linux/cfag12864b.h +AVIA HX711 ANALOG DIGITAL CONVERTER IIO DRIVER +M: Andreas Klinger +L: linux-iio@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/iio/adc/avia-hx711.txt +F: drivers/iio/adc/hx711.c + AX.25 NETWORK LAYER M: Ralf Baechle L: linux-hams@vger.kernel.org From 5126aec542fecf68dac877ea9da47d3777edcbfb Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 22 Jun 2018 13:05:01 +0200 Subject: [PATCH 074/903] iio: adc: Remove depends on HAS_DMA in case of platform dependency Remove dependencies on HAS_DMA where a Kconfig symbol depends on another symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST". In most cases this other symbol is an architecture or platform specific symbol, or PCI. Generic symbols and drivers without platform dependencies keep their dependencies on HAS_DMA, to prevent compiling subsystems or drivers that cannot work anyway. This simplifies the dependencies, and allows to improve compile-testing. Signed-off-by: Geert Uytterhoeven Reviewed-by: Mark Brown Acked-by: Robin Murphy Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 13922b595503..084638e4ddf2 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -157,7 +157,6 @@ config AT91_SAMA5D2_ADC tristate "Atmel AT91 SAMA5D2 ADC" depends on ARCH_AT91 || COMPILE_TEST depends on HAS_IOMEM - depends on HAS_DMA select IIO_BUFFER select IIO_TRIGGERED_BUFFER help @@ -647,7 +646,6 @@ config SD_ADC_MODULATOR config STM32_ADC_CORE tristate "STMicroelectronics STM32 adc core" depends on ARCH_STM32 || COMPILE_TEST - depends on HAS_DMA depends on OF depends on REGULATOR select IIO_BUFFER From 5f1d651fbfa7d9de678c58329c645727261e5cb8 Mon Sep 17 00:00:00 2001 From: Karim Eshapa Date: Mon, 18 Jun 2018 19:44:50 +0200 Subject: [PATCH 075/903] staging:iio:accel:adis16240: sign extend function replace hard code duplication Use sign_extend32 kernel function instead of code duplication, Safe also for 16 bit. and remove declaration of bits variable not needed. Signed-off-by: Karim Eshapa Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16240.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index fff6d99089cc..24e525f1ef25 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -250,7 +250,6 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, { struct adis *st = iio_priv(indio_dev); int ret; - int bits; u8 addr; s16 val16; @@ -287,24 +286,18 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, *val = 25000 / 244 - 0x133; /* 25 C = 0x133 */ return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: - bits = 10; addr = adis16240_addresses[chan->scan_index][0]; ret = adis_read_reg_16(st, addr, &val16); if (ret) return ret; - val16 &= (1 << bits) - 1; - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); - *val = val16; + *val = sign_extend32(val16, 9); return IIO_VAL_INT; case IIO_CHAN_INFO_PEAK: - bits = 10; addr = adis16240_addresses[chan->scan_index][1]; ret = adis_read_reg_16(st, addr, &val16); if (ret) return ret; - val16 &= (1 << bits) - 1; - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); - *val = val16; + *val = sign_extend32(val16, 9); return IIO_VAL_INT; } return -EINVAL; From 45e7f5d2889a35b6e1b0eecdcc2e0a1ebac071bf Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 18 Jun 2018 17:31:36 +0200 Subject: [PATCH 076/903] iio: use timespec64 based interfaces for iio_get_time_ns() We have replacements for all the deprecated timespec based interfaces now, so this can finally convert iio_get_time_ns() to consistently use the nanosecond or timespec64 based interfaces instead, avoiding the y2038 overflow. Signed-off-by: Arnd Bergmann Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 14bf3d243cb1..ed1b3ebade94 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -208,35 +208,27 @@ static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id) */ s64 iio_get_time_ns(const struct iio_dev *indio_dev) { - struct timespec tp; + struct timespec64 tp; switch (iio_device_get_clock(indio_dev)) { case CLOCK_REALTIME: - ktime_get_real_ts(&tp); - break; + return ktime_get_real_ns(); case CLOCK_MONOTONIC: - ktime_get_ts(&tp); - break; + return ktime_get_ns(); case CLOCK_MONOTONIC_RAW: - getrawmonotonic(&tp); - break; + return ktime_get_raw_ns(); case CLOCK_REALTIME_COARSE: - tp = current_kernel_time(); - break; + return ktime_to_ns(ktime_get_coarse_real()); case CLOCK_MONOTONIC_COARSE: - tp = get_monotonic_coarse(); - break; + ktime_get_coarse_ts64(&tp); + return timespec64_to_ns(&tp); case CLOCK_BOOTTIME: - get_monotonic_boottime(&tp); - break; + return ktime_get_boot_ns(); case CLOCK_TAI: - timekeeping_clocktai(&tp); - break; + return ktime_get_tai_ns(); default: BUG(); } - - return timespec_to_ns(&tp); } EXPORT_SYMBOL(iio_get_time_ns); From 6794e23fa3fed82b1e71f730359618b40cbf7d66 Mon Sep 17 00:00:00 2001 From: Eugen Hristev Date: Thu, 21 Jun 2018 10:56:21 +0300 Subject: [PATCH 077/903] iio: adc: at91-sama5d2_adc: add support for oversampling resolution This implements oversampling support for the SAMA5d2 ADC device. Enabling oversampling : OSR can improve resolution from 12 bits to 13 or 14 bits. Changing the channel specification to have 14 bits, and we shift the value 1 bit to the left if we have oversampling for just one extra bit, and two bits to the left if we have no oversampling (old support). From this commit on, the converted values for all the voltage channels change to 14 bits real data, with most insignificant two bits always zero if oversampling is not enabled. sysfs object oversampling_ratio has been enabled and oversampling_ratio_available will list possible values (1 or 4 or 16) having 1 as default (no oversampling, 1 sample for each conversion). Special care was required for the triggered buffer scenario (+ DMA), to adjust the values accordingly. Touchscreen measurements supported by this driver are not affected by oversampling, they are still on 12 bits (scale handing is already included in the driver). Signed-off-by: Eugen Hristev Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 191 +++++++++++++++++++++++++---- 1 file changed, 164 insertions(+), 27 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 58c4c2b4fe11..e02f7d1c86bc 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -130,6 +130,15 @@ #define AT91_SAMA5D2_OVER 0x3c /* Extended Mode Register */ #define AT91_SAMA5D2_EMR 0x40 +/* Extended Mode Register - Oversampling rate */ +#define AT91_SAMA5D2_EMR_OSR(V) ((V) << 16) +#define AT91_SAMA5D2_EMR_OSR_MASK GENMASK(17, 16) +#define AT91_SAMA5D2_EMR_OSR_1SAMPLES 0 +#define AT91_SAMA5D2_EMR_OSR_4SAMPLES 1 +#define AT91_SAMA5D2_EMR_OSR_16SAMPLES 2 + +/* Extended Mode Register - Averaging on single trigger event */ +#define AT91_SAMA5D2_EMR_ASTE(V) ((V) << 20) /* Compare Window Register */ #define AT91_SAMA5D2_CWR 0x44 /* Channel Gain Register */ @@ -248,6 +257,11 @@ #define AT91_HWFIFO_MAX_SIZE_STR "128" #define AT91_HWFIFO_MAX_SIZE 128 +/* Possible values for oversampling ratio */ +#define AT91_OSR_1SAMPLES 1 +#define AT91_OSR_4SAMPLES 4 +#define AT91_OSR_16SAMPLES 16 + #define AT91_SAMA5D2_CHAN_SINGLE(num, addr) \ { \ .type = IIO_VOLTAGE, \ @@ -256,12 +270,13 @@ .scan_index = num, \ .scan_type = { \ .sign = 'u', \ - .realbits = 12, \ + .realbits = 14, \ .storagebits = 16, \ }, \ .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),\ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ)|\ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ .datasheet_name = "CH"#num, \ .indexed = 1, \ } @@ -276,12 +291,13 @@ .scan_index = num + AT91_SAMA5D2_SINGLE_CHAN_CNT, \ .scan_type = { \ .sign = 's', \ - .realbits = 12, \ + .realbits = 14, \ .storagebits = 16, \ }, \ .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),\ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ)|\ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ .datasheet_name = "CH"#num"-CH"#num2, \ .indexed = 1, \ } @@ -299,7 +315,8 @@ .storagebits = 16, \ }, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ)|\ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ .datasheet_name = name, \ } #define AT91_SAMA5D2_CHAN_PRESSURE(num, name) \ @@ -313,7 +330,8 @@ .storagebits = 16, \ }, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ)|\ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ .datasheet_name = name, \ } @@ -384,6 +402,7 @@ struct at91_adc_state { const struct iio_chan_spec *chan; bool conversion_done; u32 conversion_value; + unsigned int oversampling_ratio; struct at91_adc_soc_info soc_info; wait_queue_head_t wq_data_available; struct at91_adc_dma dma_st; @@ -475,6 +494,77 @@ static inline int at91_adc_of_xlate(struct iio_dev *indio_dev, return at91_adc_chan_xlate(indio_dev, iiospec->args[0]); } +static void at91_adc_config_emr(struct at91_adc_state *st) +{ + /* configure the extended mode register */ + unsigned int emr = at91_adc_readl(st, AT91_SAMA5D2_EMR); + + /* select oversampling per single trigger event */ + emr |= AT91_SAMA5D2_EMR_ASTE(1); + + /* delete leftover content if it's the case */ + emr &= ~AT91_SAMA5D2_EMR_OSR_MASK; + + /* select oversampling ratio from configuration */ + switch (st->oversampling_ratio) { + case AT91_OSR_1SAMPLES: + emr |= AT91_SAMA5D2_EMR_OSR(AT91_SAMA5D2_EMR_OSR_1SAMPLES) & + AT91_SAMA5D2_EMR_OSR_MASK; + break; + case AT91_OSR_4SAMPLES: + emr |= AT91_SAMA5D2_EMR_OSR(AT91_SAMA5D2_EMR_OSR_4SAMPLES) & + AT91_SAMA5D2_EMR_OSR_MASK; + break; + case AT91_OSR_16SAMPLES: + emr |= AT91_SAMA5D2_EMR_OSR(AT91_SAMA5D2_EMR_OSR_16SAMPLES) & + AT91_SAMA5D2_EMR_OSR_MASK; + break; + } + + at91_adc_writel(st, AT91_SAMA5D2_EMR, emr); +} + +static int at91_adc_adjust_val_osr(struct at91_adc_state *st, int *val) +{ + if (st->oversampling_ratio == AT91_OSR_1SAMPLES) { + /* + * in this case we only have 12 bits of real data, but channel + * is registered as 14 bits, so shift left two bits + */ + *val <<= 2; + } else if (st->oversampling_ratio == AT91_OSR_4SAMPLES) { + /* + * in this case we have 13 bits of real data, but channel + * is registered as 14 bits, so left shift one bit + */ + *val <<= 1; + } + + return IIO_VAL_INT; +} + +static void at91_adc_adjust_val_osr_array(struct at91_adc_state *st, void *buf, + int len) +{ + int i = 0, val; + u16 *buf_u16 = (u16 *) buf; + + /* + * We are converting each two bytes (each sample). + * First convert the byte based array to u16, and convert each sample + * separately. + * Each value is two bytes in an array of chars, so to not shift + * more than we need, save the value separately. + * len is in bytes, so divide by two to get number of samples. + */ + while (i < len / 2) { + val = buf_u16[i]; + at91_adc_adjust_val_osr(st, &val); + buf_u16[i] = val; + i++; + } +} + static int at91_adc_configure_touch(struct at91_adc_state *st, bool state) { u32 clk_khz = st->current_sample_rate / 1000; @@ -916,6 +1006,7 @@ static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev, { struct at91_adc_state *st = iio_priv(indio_dev); int i = 0; + int val; u8 bit; for_each_set_bit(bit, indio_dev->active_scan_mask, @@ -936,7 +1027,9 @@ static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev, * Thus, emit a warning. */ if (chan->type == IIO_VOLTAGE) { - st->buffer[i] = at91_adc_readl(st, chan->address); + val = at91_adc_readl(st, chan->address); + at91_adc_adjust_val_osr(st, &val); + st->buffer[i] = val; } else { st->buffer[i] = 0; WARN(true, "This trigger cannot handle this type of channel"); @@ -972,6 +1065,14 @@ static void at91_adc_trigger_handler_dma(struct iio_dev *indio_dev) interval = div_s64((ns - st->dma_st.dma_ts), sample_count); while (transferred_len >= sample_size) { + /* + * for all the values in the current sample, + * adjust the values inside the buffer for oversampling + */ + at91_adc_adjust_val_osr_array(st, + &st->dma_st.rx_buf[st->dma_st.buf_idx], + sample_size); + iio_push_to_buffers_with_timestamp(indio_dev, (st->dma_st.rx_buf + st->dma_st.buf_idx), (st->dma_st.dma_ts + interval * sample_index)); @@ -1212,7 +1313,7 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, mutex_unlock(&st->lock); iio_device_release_direct_mode(indio_dev); - return ret; + return at91_adc_adjust_val_osr(st, val); } if (chan->type == IIO_PRESSURE) { ret = iio_device_claim_direct_mode(indio_dev); @@ -1225,7 +1326,7 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, mutex_unlock(&st->lock); iio_device_release_direct_mode(indio_dev); - return ret; + return at91_adc_adjust_val_osr(st, val); } /* in this case we have a voltage channel */ @@ -1254,9 +1355,9 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, if (ret > 0) { *val = st->conversion_value; + ret = at91_adc_adjust_val_osr(st, val); if (chan->scan_type.sign == 's') *val = sign_extend32(*val, 11); - ret = IIO_VAL_INT; st->conversion_done = false; } @@ -1292,6 +1393,10 @@ static int at91_adc_read_raw(struct iio_dev *indio_dev, *val = at91_adc_get_sample_freq(st); return IIO_VAL_INT; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *val = st->oversampling_ratio; + return IIO_VAL_INT; + default: return -EINVAL; } @@ -1303,16 +1408,28 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev, { struct at91_adc_state *st = iio_priv(indio_dev); - if (mask != IIO_CHAN_INFO_SAMP_FREQ) + switch (mask) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + if ((val != AT91_OSR_1SAMPLES) && (val != AT91_OSR_4SAMPLES) && + (val != AT91_OSR_16SAMPLES)) + return -EINVAL; + /* if no change, optimize out */ + if (val == st->oversampling_ratio) + return 0; + st->oversampling_ratio = val; + /* update ratio */ + at91_adc_config_emr(st); + return 0; + case IIO_CHAN_INFO_SAMP_FREQ: + if (val < st->soc_info.min_sample_rate || + val > st->soc_info.max_sample_rate) + return -EINVAL; + + at91_adc_setup_samp_freq(st, val); + return 0; + default: return -EINVAL; - - if (val < st->soc_info.min_sample_rate || - val > st->soc_info.max_sample_rate) - return -EINVAL; - - at91_adc_setup_samp_freq(st, val); - - return 0; + }; } static void at91_adc_dma_init(struct platform_device *pdev) @@ -1446,14 +1563,6 @@ static int at91_adc_update_scan_mode(struct iio_dev *indio_dev, return 0; } -static const struct iio_info at91_adc_info = { - .read_raw = &at91_adc_read_raw, - .write_raw = &at91_adc_write_raw, - .update_scan_mode = &at91_adc_update_scan_mode, - .of_xlate = &at91_adc_of_xlate, - .hwfifo_set_watermark = &at91_adc_set_watermark, -}; - static void at91_adc_hw_init(struct at91_adc_state *st) { at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST); @@ -1466,6 +1575,9 @@ static void at91_adc_hw_init(struct at91_adc_state *st) AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH); at91_adc_setup_samp_freq(st, st->soc_info.min_sample_rate); + + /* configure extended mode register */ + at91_adc_config_emr(st); } static ssize_t at91_adc_get_fifo_state(struct device *dev, @@ -1496,6 +1608,20 @@ static IIO_DEVICE_ATTR(hwfifo_watermark, 0444, static IIO_CONST_ATTR(hwfifo_watermark_min, "2"); static IIO_CONST_ATTR(hwfifo_watermark_max, AT91_HWFIFO_MAX_SIZE_STR); +static IIO_CONST_ATTR(oversampling_ratio_available, + __stringify(AT91_OSR_1SAMPLES) " " + __stringify(AT91_OSR_4SAMPLES) " " + __stringify(AT91_OSR_16SAMPLES)); + +static struct attribute *at91_adc_attributes[] = { + &iio_const_attr_oversampling_ratio_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group at91_adc_attribute_group = { + .attrs = at91_adc_attributes, +}; + static const struct attribute *at91_adc_fifo_attributes[] = { &iio_const_attr_hwfifo_watermark_min.dev_attr.attr, &iio_const_attr_hwfifo_watermark_max.dev_attr.attr, @@ -1504,6 +1630,15 @@ static const struct attribute *at91_adc_fifo_attributes[] = { NULL, }; +static const struct iio_info at91_adc_info = { + .attrs = &at91_adc_attribute_group, + .read_raw = &at91_adc_read_raw, + .write_raw = &at91_adc_write_raw, + .update_scan_mode = &at91_adc_update_scan_mode, + .of_xlate = &at91_adc_of_xlate, + .hwfifo_set_watermark = &at91_adc_set_watermark, +}; + static int at91_adc_probe(struct platform_device *pdev) { struct iio_dev *indio_dev; @@ -1532,6 +1667,8 @@ static int at91_adc_probe(struct platform_device *pdev) bitmap_set(&st->touch_st.channels_bitmask, AT91_SAMA5D2_TOUCH_P_CHAN_IDX, 1); + st->oversampling_ratio = AT91_OSR_1SAMPLES; + ret = of_property_read_u32(pdev->dev.of_node, "atmel,min-sample-rate-hz", &st->soc_info.min_sample_rate); From f44426346289fee0a5c4bb366583fea71da0b95d Mon Sep 17 00:00:00 2001 From: Jia-Ju Bai Date: Wed, 20 Jun 2018 18:01:19 +0800 Subject: [PATCH 078/903] staging: rtl8188eu: Fix a possible sleep-in-atomic-context bug in rtw_disassoc_cmd() The driver may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16.7 are: [FUNC] kzalloc(GFP_KERNEL) drivers/staging/rtl8188eu/core/rtw_cmd.c, 502: kzalloc in rtw_disassoc_cmd drivers/staging/rtl8188eu/core/rtw_ioctl_set.c, 256: rtw_disassoc_cmd in rtw_set_802_11_ssid drivers/staging/rtl8188eu/core/rtw_ioctl_set.c, 235: spin_lock_bh in rtw_set_802_11_ssid [FUNC] kzalloc(GFP_KERNEL) drivers/staging/rtl8188eu/core/rtw_cmd.c, 502: kzalloc in rtw_disassoc_cmd drivers/staging/rtl8188eu/core/rtw_ioctl_set.c, 352: rtw_disassoc_cmd in rtw_set_802_11_infrastructure_mode drivers/staging/rtl8188eu/core/rtw_ioctl_set.c, 336: spin_lock_bh in rtw_set_802_11_infrastructure_mode To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool (DSAC-2) and checked by my code review. Signed-off-by: Jia-Ju Bai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 72099f5d6915..a4654c85ca78 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -499,7 +499,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+%s\n", __func__)); /* prepare cmd parameter */ - param = kzalloc(sizeof(*param), GFP_KERNEL); + param = kzalloc(sizeof(*param), GFP_ATOMIC); if (!param) { res = _FAIL; goto exit; From 40a596e64f856b3d70bb859725742e830e5a0947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= Date: Sun, 17 Jun 2018 23:02:30 +0200 Subject: [PATCH 079/903] rtl8192u/rtl819x_Qos.h: Adjust spaces to coding guidelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch improves spacing according to the coding guidelines, mainly around braces. This patch fixes errors reported by checkpatch. Signed-off-by: Fabian Bläse Signed-off-by: Maximilian Ott Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 71df9d9e2e99..96e9621e9887 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -31,7 +31,7 @@ typedef u32 QOS_MODE, *PQOS_MODE; // QoS ACK Policy Field Values // Ref: WMM spec 2.1.6: QoS Control Field, p.10. // -typedef enum _ACK_POLICY{ +typedef enum _ACK_POLICY { eAckPlc0_ACK = 0x00, eAckPlc1_NoACK = 0x01, } ACK_POLICY, *PACK_POLICY; @@ -44,7 +44,7 @@ typedef enum _ACK_POLICY{ // 1. WMM spec 2.1.6: QoS Control Field, p.9. // 2. 802.11e/D13.0 7.1.3.5, p.26. // -typedef union _QOS_CTRL_FIELD{ +typedef union _QOS_CTRL_FIELD { u8 charData[2]; u16 shortData; @@ -56,7 +56,7 @@ typedef union _QOS_CTRL_FIELD{ u8 AckPolicy:2; u8 usRsvd2:1; u8 ucRsvdByte; - }WMM; + } WMM; // 802.11e: QoS data type frame sent by non-AP QSTAs. struct { @@ -65,7 +65,7 @@ typedef union _QOS_CTRL_FIELD{ u8 AckPolicy:2; u8 usRsvd:1; u8 TxopOrQsize; // (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size. - }BySta; + } BySta; // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC. struct { @@ -74,7 +74,7 @@ typedef union _QOS_CTRL_FIELD{ u8 AckPolicy:2; u8 usRsvd:1; u8 PSBufState; // QAP PS Buffer State. - }ByHc_Data; + } ByHc_Data; // 802.11e: QoS (+) CF-Poll frames sent by HC. struct { @@ -83,9 +83,9 @@ typedef union _QOS_CTRL_FIELD{ u8 AckPolicy:2; u8 usRsvd:1; u8 TxopLimit; // TXOP Limit. - }ByHc_CFP; + } ByHc_CFP; -}QOS_CTRL_FIELD, *PQOS_CTRL_FIELD; +} QOS_CTRL_FIELD, *PQOS_CTRL_FIELD; // @@ -94,13 +94,13 @@ typedef union _QOS_CTRL_FIELD{ // 1. WMM spec 2.2.1: WME Information Element, p.11. // 2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h] // -typedef union _QOS_INFO_FIELD{ +typedef union _QOS_INFO_FIELD { u8 charData; struct { u8 ucParameterSetCount:4; u8 ucReserved:4; - }WMM; + } WMM; struct { //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah @@ -112,14 +112,14 @@ typedef union _QOS_INFO_FIELD{ u8 ucMaxSPLen:2; u8 ucReserved2:1; - }ByWmmPsSta; + } ByWmmPsSta; struct { //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah u8 ucParameterSetCount:4; u8 ucReserved:3; u8 ucApUapsd:1; - }ByWmmPsAp; + } ByWmmPsAp; struct { u8 ucAC3_UAPSD:1; @@ -172,7 +172,7 @@ typedef union _QOS_INFO_FIELD{ u8 ucApUapsd:1; } ByAllAp; -}QOS_INFO_FIELD, *PQOS_INFO_FIELD; +} QOS_INFO_FIELD, *PQOS_INFO_FIELD; // // ACI to AC coding. @@ -198,7 +198,7 @@ typedef u32 AC_CODING; // ACI/AIFSN Field. // Ref: WMM spec 2.2.2: WME Parameter Element, p.12. // -typedef union _ACI_AIFSN{ +typedef union _ACI_AIFSN { u8 charData; struct { @@ -206,26 +206,26 @@ typedef union _ACI_AIFSN{ u8 ACM:1; u8 ACI:2; u8 Reserved:1; - }f; // Field -}ACI_AIFSN, *PACI_AIFSN; + } f; // Field +} ACI_AIFSN, *PACI_AIFSN; // // ECWmin/ECWmax field. // Ref: WMM spec 2.2.2: WME Parameter Element, p.13. // -typedef union _ECW{ +typedef union _ECW { u8 charData; struct { u8 ECWmin:4; u8 ECWmax:4; - }f; // Field -}ECW, *PECW; + } f; // Field +} ECW, *PECW; // // AC Parameters Record Format. // Ref: WMM spec 2.2.2: WME Parameter Element, p.12. // -typedef union _AC_PARAM{ +typedef union _AC_PARAM { u32 longData; u8 charData[4]; @@ -233,15 +233,15 @@ typedef union _AC_PARAM{ ACI_AIFSN AciAifsn; ECW Ecw; u16 TXOPLimit; - }f; // Field -}AC_PARAM, *PAC_PARAM; + } f; // Field +} AC_PARAM, *PAC_PARAM; // // QoS element subtype // -typedef enum _QOS_ELE_SUBTYPE{ +typedef enum _QOS_ELE_SUBTYPE { QOSELE_TYPE_INFO = 0x00, // 0x00: Information element QOSELE_TYPE_PARAM = 0x01, // 0x01: parameter element } QOS_ELE_SUBTYPE, *PQOS_ELE_SUBTYPE; @@ -251,7 +251,7 @@ typedef enum _QOS_ELE_SUBTYPE{ // Direction Field Values. // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. // -typedef enum _DIRECTION_VALUE{ +typedef enum _DIRECTION_VALUE { DIR_UP = 0, // 0x00 // UpLink DIR_DOWN = 1, // 0x01 // DownLink DIR_DIRECT = 2, // 0x10 // DirectLink @@ -265,7 +265,7 @@ typedef enum _DIRECTION_VALUE{ // 1. WMM spec 2.2.11: WME TSPEC Element, p.18. // 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h] // -typedef union _QOS_TSINFO{ +typedef union _QOS_TSINFO { u8 charData[3]; struct { u8 ucTrafficType:1; //WMM is reserved @@ -278,14 +278,14 @@ typedef union _QOS_TSINFO{ u8 ucTSInfoAckPolicy:2; //WMM is reserved u8 ucSchedule:1; //WMM is reserved u8 ucReserved:7; - }field; -}QOS_TSINFO, *PQOS_TSINFO; + } field; +} QOS_TSINFO, *PQOS_TSINFO; // // WMM TSPEC Body. // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16. // -typedef union _TSPEC_BODY{ +typedef union _TSPEC_BODY { u8 charData[55]; struct { @@ -306,14 +306,14 @@ typedef union _TSPEC_BODY{ u16 SurplusBandwidthAllowance; u16 MediumTime; } f; // Field -}TSPEC_BODY, *PTSPEC_BODY; +} TSPEC_BODY, *PTSPEC_BODY; // // WMM TSPEC Element. // Ref: WMM spec 2.2.11: WME TSPEC Element, p.16. // -typedef struct _WMM_TSPEC{ +typedef struct _WMM_TSPEC { u8 ID; u8 Length; u8 OUI[3]; @@ -327,19 +327,19 @@ typedef struct _WMM_TSPEC{ // ACM implementation method. // Annie, 2005-12-13. // -typedef enum _ACM_METHOD{ +typedef enum _ACM_METHOD { eAcmWay0_SwAndHw = 0, // By SW and HW. eAcmWay1_HW = 1, // By HW. eAcmWay2_SW = 2, // By SW. } ACM_METHOD, *PACM_METHOD; -typedef struct _ACM{ +typedef struct _ACM { // u8 RegEnableACM; u64 UsedTime; u64 MediumTime; u8 HwAcmCtl; // TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B). -}ACM, *PACM; +} ACM, *PACM; typedef u8 AC_UAPSD, *PAC_UAPSD; @@ -359,15 +359,15 @@ typedef u8 AC_UAPSD, *PAC_UAPSD; //typedef struct _TCLASS{ // TODO //} TCLASS, *PTCLASS; -typedef union _QOS_TCLAS{ +typedef union _QOS_TCLAS { - struct _TYPE_GENERAL{ + struct _TYPE_GENERAL { u8 Priority; u8 ClassifierType; u8 Mask; } TYPE_GENERAL; - struct _TYPE0_ETH{ + struct _TYPE0_ETH { u8 Priority; u8 ClassifierType; u8 Mask; @@ -376,7 +376,7 @@ typedef union _QOS_TCLAS{ u16 Type; } TYPE0_ETH; - struct _TYPE1_IPV4{ + struct _TYPE1_IPV4 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -390,7 +390,7 @@ typedef union _QOS_TCLAS{ u8 Reserved; } TYPE1_IPV4; - struct _TYPE1_IPV6{ + struct _TYPE1_IPV6 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -402,7 +402,7 @@ typedef union _QOS_TCLAS{ u8 FlowLabel[3]; } TYPE1_IPV6; - struct _TYPE2_8021Q{ + struct _TYPE2_8021Q { u8 Priority; u8 ClassifierType; u8 Mask; @@ -415,7 +415,7 @@ typedef union _QOS_TCLAS{ //- TSPEC //- AC (which to mapping) //} WMM_TSTREAM, *PWMM_TSTREAM; -typedef struct _QOS_TSTREAM{ +typedef struct _QOS_TSTREAM { u8 AC; WMM_TSPEC TSpec; QOS_TCLAS TClass; @@ -439,16 +439,16 @@ typedef struct _QOS_TSTREAM{ //---------------------------------------------------------------------------- // 802.11 Management frame Status Code field //---------------------------------------------------------------------------- -typedef struct _OCTET_STRING{ +typedef struct _OCTET_STRING { u8 *Octet; u16 Length; -}OCTET_STRING, *POCTET_STRING; +} OCTET_STRING, *POCTET_STRING; // // STA QoS data. // Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h] // -typedef struct _STA_QOS{ +typedef struct _STA_QOS { //DECLARE_RT_OBJECT(STA_QOS); u8 WMMIEBuf[MAX_WMMELE_LENGTH]; u8 *WMMIE; @@ -495,13 +495,13 @@ typedef struct _STA_QOS{ // Enable/Disable Rx immediate BA capability. u8 bEnableRxImmBA; -}STA_QOS, *PSTA_QOS; +} STA_QOS, *PSTA_QOS; // // BSS QOS data. // Ref: BssDscr in 8185 code. [def. in BssDscr.h] // -typedef struct _BSS_QOS{ +typedef struct _BSS_QOS { QOS_MODE bdQoSMode; u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; @@ -514,7 +514,7 @@ typedef struct _BSS_QOS{ QOS_INFO_FIELD QosInfoField; AC_PARAM AcParameter[4]; -}BSS_QOS, *PBSS_QOS; +} BSS_QOS, *PBSS_QOS; // @@ -522,12 +522,12 @@ typedef struct _BSS_QOS{ //#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0) // #define sQoSCtlLng 2 -#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0) +#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE) ? sQoSCtlLng : 0) //Added by joseph //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP //#define UP2AC(up) ((up<3)?((up==0)?1:0):(up>>1)) -#define IsACValid(ac) ((ac<=7 )?true:false ) +#define IsACValid(ac) ((ac <= 7) ? true : false) #endif // #ifndef __INC_QOS_TYPE_H From 9ca7a85582424098f73b402afa5420808745de68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= Date: Sun, 17 Jun 2018 23:02:31 +0200 Subject: [PATCH 080/903] rtl8192u/rtl819x_BAProc.c: Adjust spaces to coding guidelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch improves spacing according to the coding guidelines, mainly around braces. This patch fixes errors reported by checkpatch. Signed-off-by: Fabian Bläse Signed-off-by: Maximilian Ott Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 71 ++++++++----------- 1 file changed, 31 insertions(+), 40 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 86c73570e88a..2dc4d0e93948 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -19,7 +19,7 @@ static void ActivateBAEntry(struct ieee80211_device *ieee, PBA_RECORD pBA, u16 Time) { pBA->bValid = true; - if(Time != 0) + if (Time != 0) mod_timer(&pBA->Timer, jiffies + msecs_to_jiffies(Time)); } @@ -117,13 +117,13 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA is NULL\n"); return NULL; } - skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME + skb = dev_alloc_skb(len + sizeof(struct rtl_80211_hdr_3addr)); //need to add something others? FIXME if (!skb) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } - memset(skb->data, 0, sizeof( struct rtl_80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. + memset(skb->data, 0, sizeof(struct rtl_80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. skb_reserve(skb, ieee->tx_headroom); BAReq = skb_put(skb, sizeof(struct rtl_80211_hdr_3addr)); @@ -137,10 +137,10 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P //tag += sizeof( struct rtl_80211_hdr_3addr); //move to action field tag = skb_put(skb, 9); - *tag ++= ACT_CAT_BA; - *tag ++= type; + *tag++ = ACT_CAT_BA; + *tag++ = type; // Dialog Token - *tag ++= pBA->DialogToken; + *tag++ = pBA->DialogToken; if (ACT_ADDBARSP == type) { // Status Code @@ -201,10 +201,10 @@ static struct sk_buff *ieee80211_DELBA( memset(&DelbaParamSet, 0, 2); - DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; + DelbaParamSet.field.Initiator = (TxRxSelect == TX_DIR) ? 1 : 0; DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; - skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME + skb = dev_alloc_skb(len + sizeof(struct rtl_80211_hdr_3addr)); //need to add something others? FIXME if (!skb) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; @@ -221,8 +221,8 @@ static struct sk_buff *ieee80211_DELBA( tag = skb_put(skb, 6); - *tag ++= ACT_CAT_BA; - *tag ++= ACT_DELBA; + *tag++ = ACT_CAT_BA; + *tag++ = ACT_DELBA; // DELBA Parameter Set @@ -258,8 +258,7 @@ static void ieee80211_send_ADDBAReq(struct ieee80211_device *ieee, //add statistic needed here. //and skb will be freed in softmac_mgmt_xmit(), so omit all dev_kfree_skb_any() outside softmac_mgmt_xmit() //WB - } - else { + } else { IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__); } } @@ -280,8 +279,7 @@ static void ieee80211_send_ADDBARsp(struct ieee80211_device *ieee, u8 *dst, if (skb) { softmac_mgmt_xmit(skb, ieee); //same above - } - else { + } else { IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__); } @@ -307,8 +305,7 @@ static void ieee80211_send_DELBA(struct ieee80211_device *ieee, u8 *dst, if (skb) { softmac_mgmt_xmit(skb, ieee); //same above - } - else { + } else { IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__); } } @@ -367,7 +364,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) dst, (u8)(pBaParamSet->field.TID), RX_DIR, - true) ) { + true)) { rc = ADDBA_STATUS_REFUSED; IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __func__); goto OnADDBAReq_Fail; @@ -450,7 +447,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) if (ieee->current_network.qos_data.active == 0 || !ieee->pHTInfo->bCurrentHTSupport || !ieee->pHTInfo->bCurrentAMPDUEnable) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } @@ -466,7 +463,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) dst, (u8)(pBaParamSet->field.TID), TX_DIR, - false) ) { + false)) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __func__); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; @@ -485,19 +482,17 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) // Since BA is already setup, we ignore all other ADDBA Response. IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"); return -1; - } - else if((!pPendingBA->bValid) ||(*pDialogToken != pPendingBA->DialogToken)) { + } else if ((!pPendingBA->bValid) || (*pDialogToken != pPendingBA->DialogToken)) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; - } - else { + } else { IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode); DeActivateBAEntry(ieee, pPendingBA); } - if(*pStatusCode == ADDBA_STATUS_SUCCESS) { + if (*pStatusCode == ADDBA_STATUS_SUCCESS) { // // Determine ADDBA Rsp content here. // We can compare the value of BA parameter set that Peer returned and Self sent. @@ -521,8 +516,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) pAdmittedBA->BaParamSet = *pBaParamSet; DeActivateBAEntry(ieee, pAdmittedBA); ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal); - } - else { + } else { // Delay next ADDBA process. pTS->bAddBaReqDelayed = true; } @@ -562,7 +556,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) if (ieee->current_network.qos_data.active == 0 || !ieee->pHTInfo->bCurrentHTSupport) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); return -1; } @@ -571,7 +565,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) dst = &delba->addr2[0]; pDelBaParamSet = (PDELBA_PARAM_SET)&delba->payload[2]; - if(pDelBaParamSet->field.Initiator == 1) { + if (pDelBaParamSet->field.Initiator == 1) { PRX_TS_RECORD pRxTs; if (!GetTs( @@ -580,14 +574,13 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) dst, (u8)pDelBaParamSet->field.TID, RX_DIR, - false) ) { + false)) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __func__); return -1; } RxTsDeleteBA(ieee, pRxTs); - } - else { + } else { PTX_TS_RECORD pTxTs; if (!GetTs( @@ -596,7 +589,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) dst, (u8)pDelBaParamSet->field.TID, TX_DIR, - false) ) { + false)) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __func__); return -1; } @@ -645,29 +638,27 @@ TsInitAddBA( } void -TsInitDelBA( struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect) +TsInitDelBA(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect) { - - if(TxRxSelect == TX_DIR) { + if (TxRxSelect == TX_DIR) { PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo; - if(TxTsDeleteBA(ieee, pTxTs)) + if (TxTsDeleteBA(ieee, pTxTs)) ieee80211_send_DELBA( ieee, pTsCommonInfo->Addr, (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), TxRxSelect, DELBA_REASON_END_BA); - } - else if(TxRxSelect == RX_DIR) { + } else if (TxRxSelect == RX_DIR) { PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo; - if(RxTsDeleteBA(ieee, pRxTs)) + if (RxTsDeleteBA(ieee, pRxTs)) ieee80211_send_DELBA( ieee, pTsCommonInfo->Addr, &pRxTs->RxAdmittedBARecord, TxRxSelect, - DELBA_REASON_END_BA ); + DELBA_REASON_END_BA); } } /******************************************************************************************************************** From 6b6da6228c646d00567a631bfe7ee10ce61ba50b Mon Sep 17 00:00:00 2001 From: Janani Sankara Babu Date: Mon, 18 Jun 2018 12:05:09 -0400 Subject: [PATCH 081/903] Staging:rtl8192e Fix Comparison to False is error prone This patch removes comparison to False and boolean values in the code which can be written as !var Signed-off-by: Janani Sankara Babu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index c466a5e7e3bd..f19470552ffd 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -257,8 +257,8 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) pBaStartSeqCtrl = (union sequence_control *)(req + 7); RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from : %pM\n", dst); - if (ieee->current_network.qos_data.active == 0 || - (ieee->pHTInfo->bCurrentHTSupport == false) || + if (!ieee->current_network.qos_data.active || + !ieee->pHTInfo->bCurrentHTSupport || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { rc = ADDBA_STATUS_REFUSED; netdev_warn(ieee->dev, @@ -340,9 +340,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) pBaTimeoutVal = (u16 *)(tag + 7); RT_TRACE(COMP_DBG, "====>rx ADDBARSP from : %pM\n", dst); - if (ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false || - ieee->pHTInfo->bCurrentAMPDUEnable == false) { + if (!ieee->current_network.qos_data.active || + !ieee->pHTInfo->bCurrentHTSupport || + !ieee->pHTInfo->bCurrentAMPDUEnable) { netdev_warn(ieee->dev, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n", ieee->current_network.qos_data.active, @@ -369,7 +369,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n", __func__); return -1; - } else if ((pPendingBA->bValid == false) || + } else if (!pPendingBA->bValid || (*pDialogToken != pPendingBA->DialogToken)) { netdev_warn(ieee->dev, "%s(): ADDBA Rsp. BA invalid, DELBA!\n", @@ -431,8 +431,8 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) return -1; } - if (ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false) { + if (!ieee->current_network.qos_data.active || + !ieee->pHTInfo->bCurrentHTSupport) { netdev_warn(ieee->dev, "received DELBA while QOS or HT is not supported(%d, %d)\n", ieee->current_network. qos_data.active, From 4eff3e9d971e75cc2f822596b842e2af181986a1 Mon Sep 17 00:00:00 2001 From: Janani Sankara Babu Date: Mon, 18 Jun 2018 12:05:29 -0400 Subject: [PATCH 082/903] Staging:rtl8192e Fix Comparison to true is error prone This patch removes the comaprison to bool value in the code Signed-off-by: Janani Sankara Babu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index f19470552ffd..95ca5f49890a 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -365,7 +365,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) pAdmittedBA = &pTS->TxAdmittedBARecord; - if (pAdmittedBA->bValid == true) { + if (pAdmittedBA->bValid) { netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n", __func__); return -1; @@ -485,7 +485,7 @@ void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, { struct ba_record *pBA = &pTS->TxPendingBARecord; - if (pBA->bValid == true && bOverwritePending == false) + if (pBA->bValid && !bOverwritePending) return; DeActivateBAEntry(ieee, pBA); From 997e66741413a304e3337dd0f904e54ed50b3cbe Mon Sep 17 00:00:00 2001 From: Janani Sankara Babu Date: Mon, 18 Jun 2018 12:05:45 -0400 Subject: [PATCH 083/903] Staging:rtl8192e Cleanup comparison to NULL This patch replaces the comparison of var to NULL with !var Signed-off-by: Janani Sankara Babu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 95ca5f49890a..687dbb04ed2e 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -83,7 +83,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, netdev_dbg(ieee->dev, "%s(): frame(%d) sentd to: %pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev); - if (pBA == NULL) { + if (!pBA) { netdev_warn(ieee->dev, "pBA is NULL\n"); return NULL; } From 9b468c7e0216330b8b6a5020cdf9ef395a56ed95 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 24 Jun 2018 16:34:47 +0100 Subject: [PATCH 084/903] staging: rtl8192u: change block comments to prefered style - Coding Style Some of the comment blocks are commening out code so have been left for the moment. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_HTProc.c | 366 ++++++++++-------- 1 file changed, 195 insertions(+), 171 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 5a48693e2cf3..54c48747f5fa 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -41,17 +41,18 @@ static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e}; static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; //static u8 DLINK_ATHEROS[3] = {0x00, 0x1c, 0xf0}; static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; - -// 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Should we put the -// code in other place?? -//static u8 WIFI_CISCO_G_AP[3] = {0x00, 0x40, 0x96}; -/******************************************************************************************************************** +/* + * 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Should we put the + * code in other place?? + * static u8 WIFI_CISCO_G_AP[3] = {0x00, 0x40, 0x96}; + */ +/* *function: This function update default settings in pHTInfo structure * input: PRT_HIGH_THROUGHPUT pHTInfo * output: none * return: none * notice: These value need be modified if any changes. - * *****************************************************************************************************************/ + */ void HTUpdateDefaultSetting(struct ieee80211_device *ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -93,8 +94,10 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee) // 8190 only. Assign duration operation mode to firmware pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur; #endif - // 8190 only, Realtek proprietary aggregation mode - // Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others + /* + * 8190 only, Realtek proprietary aggregation mode + * Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others + */ pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others // For Rx Reorder Control @@ -113,14 +116,14 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee) #endif } -/******************************************************************************************************************** +/* *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq) * input: u8* CapIE //Capability IE to be printed out * u8* TitleString //mainly print out caller function * output: none * return: none * notice: Driver should not print out this message by default. - * *****************************************************************************************************************/ + */ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) { static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily @@ -147,14 +150,14 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); } -/******************************************************************************************************************** +/* *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp) * input: u8* InfoIE //Capability IE to be printed out * u8* TitleString //mainly print out caller function * output: none * return: none * notice: Driver should not print out this message by default. - * *****************************************************************************************************************/ + */ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) { static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily @@ -209,8 +212,8 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) } /* -* Return: true if station in half n mode and AP supports 40 bw -*/ + * Return: true if station in half n mode and AP supports 40 bw + */ static bool IsHTHalfNmode40Bandwidth(struct ieee80211_device *ieee) { bool retValue = false; @@ -276,14 +279,14 @@ u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } -/******************************************************************************************************************** +/* *function: This function returns current datarate. * input: struct ieee80211_device* ieee * u8 nDataRate * output: none * return: tx rate * notice: quite unsure about how to use this function //wb - * *****************************************************************************************************************/ + */ u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate) { //PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -345,13 +348,13 @@ bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee) return retValue; } -/******************************************************************************************************************** +/* *function: This function returns peer IOT. * input: struct ieee80211_device* ieee * output: none * return: * notice: - * *****************************************************************************************************************/ + */ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -383,31 +386,31 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer); } -/******************************************************************************************************************** +/* *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good * at receiving MCS14~15 frame from some AP. * input: struct ieee80211_device* ieee * u8 * PeerMacAddr * output: none * return: return 1 if driver should declare MCS13 only(otherwise return 0) - * *****************************************************************************************************************/ + */ static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 *PeerMacAddr) { return 0; } -/** -* Function: HTIOTActIsDisableMCS15 -* -* Overview: Check whether driver should declare capability of receiving MCS15 -* -* Input: -* PADAPTER Adapter, -* -* Output: None -* Return: true if driver should disable MCS15 -* 2008.04.15 Emily -*/ +/* + * Function: HTIOTActIsDisableMCS15 + * + * Overview: Check whether driver should declare capability of receiving MCS15 + * + * Input: + * PADAPTER Adapter, + * + * Output: None + * Return: true if driver should disable MCS15 + * 2008.04.15 Emily + */ static bool HTIOTActIsDisableMCS15(struct ieee80211_device *ieee) { bool retValue = false; @@ -433,18 +436,18 @@ static bool HTIOTActIsDisableMCS15(struct ieee80211_device *ieee) return retValue; } -/** -* Function: HTIOTActIsDisableMCSTwoSpatialStream -* -* Overview: Check whether driver should declare capability of receiving All 2 ss packets -* -* Input: -* PADAPTER Adapter, -* -* Output: None -* Return: true if driver should disable all two spatial stream packet -* 2008.04.21 Emily -*/ +/* + * Function: HTIOTActIsDisableMCSTwoSpatialStream + * + * Overview: Check whether driver should declare capability of receiving All 2 ss packets + * + * Input: + * PADAPTER Adapter, + * + * Output: None + * Return: true if driver should disable all two spatial stream packet + * 2008.04.21 Emily + */ static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee, u8 *PeerMacAddr) { @@ -454,25 +457,25 @@ static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee, return false; } -/******************************************************************************************************************** +/* *function: Check whether driver should disable EDCA turbo mode * input: struct ieee80211_device* ieee * u8* PeerMacAddr * output: none * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0) - * *****************************************************************************************************************/ + */ static u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device *ieee, u8 *PeerMacAddr) { /* default enable EDCA Turbo mode. */ return false; } -/******************************************************************************************************************** +/* *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP * input: struct ieee80211_network *network //current network we live * output: none * return: return 1 if true - * *****************************************************************************************************************/ + */ static u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network) { u8 retValue = 0; @@ -504,7 +507,7 @@ void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo) pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; } -/******************************************************************************************************************** +/* *function: Construct Capablility Element in Beacon... if HTEnable is turned on * input: struct ieee80211_device* ieee * u8* posHTCap //pointer to store Capability Ele @@ -513,7 +516,7 @@ void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo) * output: none * return: none * notice: posHTCap can't be null and should be initialized before. - * *****************************************************************************************************************/ + */ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 IsEncrypt) { PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; @@ -557,8 +560,10 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u pCapELE->PSMP = 0; // Do not support now!! pCapELE->LSigTxopProtect = 0; // Do not support now!! - //MAC HT parameters info - // TODO: Nedd to take care of this part + /* + * MAC HT parameters info + * TODO: Nedd to take care of this part + */ IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); if (IsEncrypt) { @@ -580,8 +585,10 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u if (pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS) pCapELE->MCS[1] &= 0x00; - // 2008.06.12 - // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7. + /* + * 2008.06.12 + * For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7. + */ if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { int i; @@ -609,7 +616,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u // HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()"); } -/******************************************************************************************************************** +/* *function: Construct Information Element in Beacon... if HTEnable is turned on * input: struct ieee80211_device* ieee * u8* posHTCap //pointer to store Information Ele @@ -618,7 +625,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u * output: none * return: none * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this - * *****************************************************************************************************************/ + */ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *len, u8 IsEncrypt) { PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; @@ -659,24 +666,24 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le } /* - * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance - * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2 - * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set - * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP - * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently - * at the same time. - * - * Frame Format - * Element ID Length OUI Type1 Reserved - * 1 byte 1 byte 3 bytes 1 byte 1 byte - * - * OUI = 0x00, 0xe0, 0x4c, - * Type = 0x02 - * Reserved = 0x00 - * - * 2007.8.21 by Emily -*/ -/******************************************************************************************************************** + * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance + * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2 + * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set + * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP + * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently + * at the same time. + * + * Frame Format + * Element ID Length OUI Type1 Reserved + * 1 byte 1 byte 3 bytes 1 byte 1 byte + * + * OUI = 0x00, 0xe0, 0x4c, + * Type = 0x02 + * Reserved = 0x00 + * + * 2007.8.21 by Emily + */ +/* *function: Construct Information Element in Beacon... in RT2RT condition * input: struct ieee80211_device* ieee * u8* posRT2RTAgg //pointer to store Information Ele @@ -684,7 +691,7 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le * output: none * return: none * notice: - * *****************************************************************************************************************/ + */ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len) { if (!posRT2RTAgg) { @@ -726,13 +733,13 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, #endif } -/******************************************************************************************************************** +/* *function: Pick the right Rate Adaptive table to use * input: struct ieee80211_device* ieee * u8* pOperateMCS //A pointer to MCS rate bitmap * return: always we return true * notice: - * *****************************************************************************************************************/ + */ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) { u8 i; @@ -774,24 +781,24 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) } /* -* Description: -* This function will get the highest speed rate in input MCS set. -* -* /param Adapter Pionter to Adapter entity -* pMCSRateSet Pointer to MCS rate bitmap -* pMCSFilter Pointer to MCS rate filter -* -* /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter. -* -*/ -/******************************************************************************************************************** + * Description: + * This function will get the highest speed rate in input MCS set. + * + * /param Adapter Pionter to Adapter entity + * pMCSRateSet Pointer to MCS rate bitmap + * pMCSFilter Pointer to MCS rate filter + * + * /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter. + * + */ +/* *function: This function will get the highest speed rate in input MCS set. * input: struct ieee80211_device* ieee * u8* pMCSRateSet //Pointer to MCS rate bitmap * u8* pMCSFilter //Pointer to MCS rate filter * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter * notice: - * *****************************************************************************************************************/ + */ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSFilter) { u8 i, j; @@ -829,14 +836,13 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF } /* -** -**1.Filter our operation rate set with AP's rate set -**2.shall reference channel bandwidth, STBC, Antenna number -**3.generate rate adative table for firmware -**David 20060906 -** -** \pHTSupportedCap: the connected STA's supported rate Capability element -*/ + * 1.Filter our operation rate set with AP's rate set + * 2.shall reference channel bandwidth, STBC, Antenna number + * 3.generate rate adative table for firmware + * David 20060906 + * + * \pHTSupportedCap: the connected STA's supported rate Capability element + */ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, u8 *pOperateMCS) { @@ -849,18 +855,20 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number - // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet - // we also shall suggested the first start rate set according to our singal strength + /* + * TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet + * we also shall suggested the first start rate set according to our singal strength + */ HT_PickMCSRate(ieee, pOperateMCS); // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7. if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pOperateMCS[1] = 0; - // - // For RTL819X, we support only MCS0~15. - // And also, we do not know how to use MCS32 now. - // + /* + * For RTL819X, we support only MCS0~15. + * And also, we do not know how to use MCS32 now. + */ for (i = 2; i <= 15; i++) pOperateMCS[i] = 0; @@ -911,30 +919,33 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1); - // - // Update short GI/ long GI setting - // - // TODO: + /* + * Update short GI/ long GI setting + * + * TODO: + */ pHTInfo->bCurShortGI20MHz = pHTInfo->bRegShortGI20MHz && (pPeerHTCap->ShortGI20Mhz == 1); pHTInfo->bCurShortGI40MHz = pHTInfo->bRegShortGI40MHz && (pPeerHTCap->ShortGI40Mhz == 1); - // - // Config TX STBC setting - // - // TODO: + /* + * Config TX STBC setting + * + * TODO: + */ - // - // Config DSSS/CCK mode in 40MHz mode - // - // TODO: + /* + * Config DSSS/CCK mode in 40MHz mode + * + * TODO: + */ pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK && (pPeerHTCap->DssCCk == 1); - // - // Config and configure A-MSDU setting - // + /* + * Config and configure A-MSDU setting + */ pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935; @@ -943,14 +954,15 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize; else pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; - // - // Config A-MPDU setting - // + /* + * Config A-MPDU setting + */ pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; - // <1> Decide AMPDU Factor - - // By Emily + /* + * <1> Decide AMPDU Factor + * By Emily + */ if (!pHTInfo->bRegRT2RTAggregation) { // Decide AMPDU Factor according to protocol handshake if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor) @@ -958,8 +970,10 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) else pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; } else { - // Set MPDU density to 2 to Realtek AP, and set it to 0 for others - // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily + /* + * Set MPDU density to 2 to Realtek AP, and set it to 0 for others + * Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily + */ if (ieee->current_network.bssht.bdRT2RTAggregation) { if (ieee->pairwise_key_type != KEY_TYPE_NA) // Realtek may set 32k in security mode and 64k for others @@ -974,8 +988,10 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) } } - // <2> Set AMPDU Minimum MPDU Start Spacing - // 802.11n 3.0 section 9.7d.3 + /* + * <2> Set AMPDU Minimum MPDU Start Spacing + * 802.11n 3.0 section 9.7d.3 + */ if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; else @@ -997,22 +1013,24 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) // Rx Reorder Setting pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable; - // - // Filter out unsupported HT rate for this AP - // Update RATR table - // This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism. - // + /* + * Filter out unsupported HT rate for this AP + * Update RATR table + * This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism. + */ - // Handle Ralink AP bad MCS rate set condition. Joseph. - // This fix the bug of Ralink AP. This may be removed in the future. + /* + * Handle Ralink AP bad MCS rate set condition. Joseph. + * This fix the bug of Ralink AP. This may be removed in the future. + */ if (pPeerHTCap->MCS[0] == 0) pPeerHTCap->MCS[0] = 0xff; HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet); - // - // Config MIMO Power Save setting - // + /* + * Config MIMO Power Save setting + */ pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave; if (pHTInfo->PeerMimoPs == MIMO_PS_STATIC) pMcsFilter = MCS_FILTER_1SS; @@ -1023,28 +1041,28 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; - // - // Config current operation mode. - // + /* + * Config current operation mode. + */ pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; } void HTSetConnectBwModeCallback(struct ieee80211_device *ieee); -/******************************************************************************************************************** +/* *function: initialize HT info(struct PRT_HIGH_THROUGHPUT) * input: struct ieee80211_device* ieee * output: none * return: none * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP -********************************************************************************************************************/ + */ // TODO: Should this funciton be called when receiving of Disassociation? void HTInitializeHTInfo(struct ieee80211_device *ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - // - // These parameters will be reset when receiving deauthentication packet - // + /* + * These parameters will be reset when receiving deauthentication packet + */ IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __func__); pHTInfo->bCurrentHTSupport = false; @@ -1057,10 +1075,12 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) pHTInfo->bCurShortGI40MHz = false; pHTInfo->bForcedShortGI = false; - // CCK rate support - // This flag is set to true to support CCK rate by default. - // It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to - // 11N BSS. + /* + * CCK rate support + * This flag is set to true to support CCK rate by default. + * It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to + * 11N BSS. + */ pHTInfo->bCurSuppCCK = true; // AMSDU related @@ -1099,13 +1119,13 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) } } -/******************************************************************************************************************** +/* *function: initialize Bss HT structure(struct PBSS_HT) * input: PBSS_HT pBssHT //to be initialized * output: none * return: none * notice: This function is called when initialize network structure -********************************************************************************************************************/ + */ void HTInitializeBssDesc(PBSS_HT pBssHT) { pBssHT->bdSupportHT = false; @@ -1120,14 +1140,14 @@ void HTInitializeBssDesc(PBSS_HT pBssHT) pBssHT->bdRT2RTLongSlotTime = false; } -/******************************************************************************************************************** +/* *function: initialize Bss HT structure(struct PBSS_HT) * input: struct ieee80211_device *ieee * struct ieee80211_network *pNetwork //usually current network we are live in * output: none * return: none * notice: This function should ONLY be called before association -********************************************************************************************************************/ + */ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -1166,8 +1186,10 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802 // Determine the IOT Peer Vendor. HTIOTPeerDetermine(ieee); - // Decide IOT Action - // Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided + /* + * Decide IOT Action + * Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided + */ pHTInfo->IOTAction = 0; bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid); if (bIOTAction) @@ -1208,27 +1230,27 @@ void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_ PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf; if (pHTInfo->bCurrentHTSupport) { - // - // Config current operation mode. - // + /* + * Config current operation mode. + */ if (pNetwork->bssht.bdHTInfoLen != 0) pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - // - // - // + /* + * + */ } } EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting); -/******************************************************************************************************************** +/* *function: check whether HT control field exists * input: struct ieee80211_device *ieee * u8* pFrame //coming skb->data * output: none * return: return true if HT control field exists(false otherwise) * notice: -********************************************************************************************************************/ + */ u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame) { if (ieee->pHTInfo->bCurrentHTSupport) { @@ -1240,9 +1262,9 @@ u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame) return false; } -// -// This function set bandwidth mode in protocol layer. -// +/* + * This function set bandwidth mode in protocol layer. + */ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -1280,10 +1302,12 @@ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidt pHTInfo->bSwBwInProgress = true; - // TODO: 2007.7.13 by Emily Wait 2000ms in order to guarantee that switching - // bandwidth is executed after scan is finished. It is a temporal solution - // because software should ganrantee the last operation of switching bandwidth - // is executed properlly. + /* + * TODO: 2007.7.13 by Emily Wait 2000ms in order to guarantee that switching + * bandwidth is executed after scan is finished. It is a temporal solution + * because software should ganrantee the last operation of switching bandwidth + * is executed properlly. + */ HTSetConnectBwModeCallback(ieee); // spin_unlock_irqrestore(&(ieee->bw_spinlock), flags); From 5d9f4b53ca148bc4b03b41237a86a021f0f7ac79 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 24 Jun 2018 16:34:48 +0100 Subject: [PATCH 085/903] staging: rtl8192u: Correct indentation of switch statement - Coding Style Removed an extra indentation from the code of the various case options in a switch statement. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_HTProc.c | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 54c48747f5fa..4bfadb49c363 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -753,28 +753,28 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) case IEEE_A: case IEEE_B: case IEEE_G: - //legacy rate routine handled at selectedrate + //legacy rate routine handled at selectedrate - //no MCS rate - for (i = 0; i <= 15; i++) - pOperateMCS[i] = 0; - break; + //no MCS rate + for (i = 0; i <= 15; i++) + pOperateMCS[i] = 0; + break; case IEEE_N_24G: //assume CCK rate ok case IEEE_N_5G: - // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G. - // Legacy part shall be handled at SelectRateSet(). + // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G. + // Legacy part shall be handled at SelectRateSet(). - //HT part - // TODO: may be different if we have different number of antenna - pOperateMCS[0] &= RATE_ADPT_1SS_MASK; //support MCS 0~7 - pOperateMCS[1] &= RATE_ADPT_2SS_MASK; - pOperateMCS[3] &= RATE_ADPT_MCS32_MASK; - break; + //HT part + // TODO: may be different if we have different number of antenna + pOperateMCS[0] &= RATE_ADPT_1SS_MASK; //support MCS 0~7 + pOperateMCS[1] &= RATE_ADPT_2SS_MASK; + pOperateMCS[3] &= RATE_ADPT_MCS32_MASK; + break; //should never reach here default: - break; + break; } return true; From e62b4e21d1edf1cbe6d79e4c05fdbd56190a57aa Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 24 Jun 2018 16:34:50 +0100 Subject: [PATCH 086/903] staging: rtl8192u: Truncate block comments to 80 character length - Style Where possible truncation of block comments to the 80 character length preferred by the coding style. In a previous version of this commit some of the comments were contentious so those have not been touched in this version. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_HTProc.c | 106 +++++++++++------- 1 file changed, 63 insertions(+), 43 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 4bfadb49c363..cfe08ef636cc 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -//As this function is mainly ported from Windows driver, so leave the name little changed. If any confusion caused, tell me. Created by WB. 2008.05.08 +/* + * As this function is mainly ported from Windows driver, so leave the name + * little changed. If any confusion caused, tell me. Created by WB. 2008.05.08 + */ #include "ieee80211.h" #include "rtl819x_HT.h" u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -42,8 +45,8 @@ static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; //static u8 DLINK_ATHEROS[3] = {0x00, 0x1c, 0xf0}; static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; /* - * 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Should we put the - * code in other place?? + * 2008/04/01 MH For Cisco G mode RX TP We need to change FW duration. Should we + * put the code in other place?? * static u8 WIFI_CISCO_G_AP[3] = {0x00, 0x40, 0x96}; */ /* @@ -117,7 +120,8 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee) } /* - *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq) + *function: This function print out each field on HT capability + * IE mainly from (Beacon/ProbeRsp/AssocReq) * input: u8* CapIE //Capability IE to be printed out * u8* TitleString //mainly print out caller function * output: none @@ -151,7 +155,8 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) } /* - *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp) + *function: This function print out each field on HT Information + * IE mainly from (Beacon/ProbeRsp) * input: u8* InfoIE //Capability IE to be printed out * u8* TitleString //mainly print out caller function * output: none @@ -387,8 +392,9 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) } /* - *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good - * at receiving MCS14~15 frame from some AP. + *function: Check whether driver should declare received rate up to MCS13 + * only since some chipset is not good at receiving MCS14~15 frame + * from some AP. * input: struct ieee80211_device* ieee * u8 * PeerMacAddr * output: none @@ -402,7 +408,8 @@ static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 *PeerMacAddr) /* * Function: HTIOTActIsDisableMCS15 * - * Overview: Check whether driver should declare capability of receiving MCS15 + * Overview: Check whether driver should declare capability of receiving + * MCS15 * * Input: * PADAPTER Adapter, @@ -439,7 +446,8 @@ static bool HTIOTActIsDisableMCS15(struct ieee80211_device *ieee) /* * Function: HTIOTActIsDisableMCSTwoSpatialStream * - * Overview: Check whether driver should declare capability of receiving All 2 ss packets + * Overview: Check whether driver should declare capability of receiving + * All 2 ss packets * * Input: * PADAPTER Adapter, @@ -462,7 +470,8 @@ static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee, * input: struct ieee80211_device* ieee * u8* PeerMacAddr * output: none - * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0) + * return: return 1 if driver should disable EDCA turbo mode + * (otherwise return 0) */ static u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device *ieee, u8 *PeerMacAddr) @@ -471,7 +480,8 @@ static u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device *ieee, } /* - *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP + *function: Check whether we need to use OFDM to sned MGNT frame for + * broadcom AP * input: struct ieee80211_network *network //current network we live * output: none * return: return 1 if true @@ -510,9 +520,9 @@ void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo) /* *function: Construct Capablility Element in Beacon... if HTEnable is turned on * input: struct ieee80211_device* ieee - * u8* posHTCap //pointer to store Capability Ele - * u8* len //store length of CE - * u8 IsEncrypt //whether encrypt, needed further + * u8* posHTCap //pointer to store Capability Ele + * u8* len //store length of CE + * u8 IsEncrypt //whether encrypt, needed further * output: none * return: none * notice: posHTCap can't be null and should be initialized before. @@ -551,7 +561,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!! pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!! //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r", - //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz); + //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz); pCapELE->TxSTBC = 1; pCapELE->RxSTBC = 0; pCapELE->DelayBA = 0; // Do not support now!! @@ -612,19 +622,23 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTCap, *len -2); - //Print each field in detail. Driver should not print out this message by default + /* + * Print each field in detail. Driver should not print out this message + * by default + */ // HTDebugHTCapability(posHTCap, (u8*)"HTConstructCapability()"); } /* - *function: Construct Information Element in Beacon... if HTEnable is turned on + *function: Construct Information Element in Beacon... if HTEnable is turned on * input: struct ieee80211_device* ieee - * u8* posHTCap //pointer to store Information Ele - * u8* len //store len of - * u8 IsEncrypt //whether encrypt, needed further + * u8* posHTCap //pointer to store Information Ele + * u8* len //store len of + * u8 IsEncrypt //whether encrypt, needed further * output: none * return: none - * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this + * notice: posHTCap can't be null and be initialized before. + * Only AP and IBSS sta should do this */ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *len, u8 IsEncrypt) { @@ -666,16 +680,17 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le } /* - * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance - * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2 - * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set - * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP - * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently - * at the same time. + * According to experiment, Realtek AP to STA (based on rtl8190) may achieve + * best performance if both STA and AP set limitation of aggregation size to + * 32K, that is, set AMPDU density to 2 (Ref: IEEE 11n specification). + * However, if Realtek STA associates to other AP, STA should set limitation of + * aggregation size to 8K, otherwise, performance of traffic stream from STA to + * AP will be much less than the traffic stream from AP to STA if both of the + * stream runs concurrently at the same time. * * Frame Format - * Element ID Length OUI Type1 Reserved - * 1 byte 1 byte 3 bytes 1 byte 1 byte + * Element ID Length OUI Type1 Reserved + * 1 byte 1 byte 3 bytes 1 byte 1 byte * * OUI = 0x00, 0xe0, 0x4c, * Type = 0x02 @@ -686,8 +701,8 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le /* *function: Construct Information Element in Beacon... in RT2RT condition * input: struct ieee80211_device* ieee - * u8* posRT2RTAgg //pointer to store Information Ele - * u8* len //store len + * u8* posRT2RTAgg //pointer to store Information Ele + * u8* len //store len * output: none * return: none * notice: @@ -736,7 +751,7 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, /* *function: Pick the right Rate Adaptive table to use * input: struct ieee80211_device* ieee - * u8* pOperateMCS //A pointer to MCS rate bitmap + * u8* pOperateMCS //A pointer to MCS rate bitmap * return: always we return true * notice: */ @@ -856,8 +871,9 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number /* - * TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet - * we also shall suggested the first start rate set according to our singal strength + * TODO: fill suggested rate adaptive rate index and give firmware info + * using Tx command packet we also shall suggested the first start rate + * set according to our singal strength */ HT_PickMCSRate(ieee, pOperateMCS); @@ -1016,7 +1032,8 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) /* * Filter out unsupported HT rate for this AP * Update RATR table - * This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism. + * This is only for 8190 ,8192 or later product which using firmware to + * handle rate adaptive mechanism. */ /* @@ -1053,7 +1070,9 @@ void HTSetConnectBwModeCallback(struct ieee80211_device *ieee); * input: struct ieee80211_device* ieee * output: none * return: none - * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP + * notice: This function is called when + * * (1) MPInitialization Phase + * * (2) Receiving of Deauthentication from AP */ // TODO: Should this funciton be called when receiving of Disassociation? void HTInitializeHTInfo(struct ieee80211_device *ieee) @@ -1078,8 +1097,8 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) /* * CCK rate support * This flag is set to true to support CCK rate by default. - * It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to - * 11N BSS. + * It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities + * only when associate to 11N BSS. */ pHTInfo->bCurSuppCCK = true; @@ -1143,7 +1162,8 @@ void HTInitializeBssDesc(PBSS_HT pBssHT) /* *function: initialize Bss HT structure(struct PBSS_HT) * input: struct ieee80211_device *ieee - * struct ieee80211_network *pNetwork //usually current network we are live in + * struct ieee80211_network *pNetwork //usually current network + * we are live in * output: none * return: none * notice: This function should ONLY be called before association @@ -1303,10 +1323,10 @@ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidt pHTInfo->bSwBwInProgress = true; /* - * TODO: 2007.7.13 by Emily Wait 2000ms in order to guarantee that switching - * bandwidth is executed after scan is finished. It is a temporal solution - * because software should ganrantee the last operation of switching bandwidth - * is executed properlly. + * TODO: 2007.7.13 by Emily Wait 2000ms in order to guarantee that + * switching bandwidth is executed after scan is finished. It is a + * temporal solution because software should ganrantee the last + * operation of switching bandwidth is executed properlly. */ HTSetConnectBwModeCallback(ieee); From dff11576389f099b608daba633eb84b6dde1c283 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 24 Jun 2018 16:34:52 +0100 Subject: [PATCH 087/903] staging: rtl8192u: Remove braces from single statement blocks - Style Removed the unrequired braces from single statement blocks - Coding Style. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index cfe08ef636cc..0831ea791b54 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -549,11 +549,10 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u //HT capability info pCapELE->AdvCoding = 0; // This feature is not supported now!! - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pCapELE->ChlWidth = 0; - } else { + else pCapELE->ChlWidth = (pHT->bRegBW40MHz ? 1 : 0); - } // pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); pCapELE->MimoPwrSave = pHT->SelfMimoPs; @@ -721,9 +720,8 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, *posRT2RTAgg++ = 0x01; *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02; - if (ieee->bSupportRemoteWakeUp) { + if (ieee->bSupportRemoteWakeUp) *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW; - } *len = 6 + 2; return; @@ -864,12 +862,10 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, u8 i = 0; // filter out operational rate set not supported by AP, the length of it is 16 - for (i = 0; i <= 15; i++) { + for (i = 0; i <= 15; i++) pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i] & pSupportMCS[i]; - } // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number - /* * TODO: fill suggested rate adaptive rate index and give firmware info * using Tx command packet we also shall suggested the first start rate From c8cf478ab7180d1c0efb66ac6cfcab3154073485 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 24 Jun 2018 16:34:53 +0100 Subject: [PATCH 088/903] staging: rtl8192u: Correct if statement - Coding Style Corrected the coding style of if statement. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 0831ea791b54..208773cd4cb1 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -732,7 +732,7 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, section of code. if(IS_UNDER_11N_AES_MODE(Adapter)) { - posRT2RTAgg->Octet[5] |=RT_HT_CAP_USE_AMPDU; + posRT2RTAgg->Octet[5] |= RT_HT_CAP_USE_AMPDU; }else { posRT2RTAgg->Octet[5] &= 0xfb; From 931113828cd1fc0c2d1dcc1037aa2967d633b996 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 24 Jun 2018 16:34:54 +0100 Subject: [PATCH 089/903] staging: rtl8192u: Correction of spelling mistake in comment. Simple spelling correction. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 208773cd4cb1..1dd4c6ae7319 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -869,7 +869,7 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, /* * TODO: fill suggested rate adaptive rate index and give firmware info * using Tx command packet we also shall suggested the first start rate - * set according to our singal strength + * set according to our signal strength */ HT_PickMCSRate(ieee, pOperateMCS); From 71e9bd3ff847afae91b9f66f9217921e98c25b0b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 25 Jun 2018 23:41:56 +0200 Subject: [PATCH 090/903] staging: rtl8188eu: add SPDX identifiers This satisfies a checkpatch warning and is the preferred method for notating the license. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_cmd.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_debug.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_efuse.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_iol.c | 11 +---------- drivers/staging/rtl8188eu/core/rtw_led.c | 11 +---------- drivers/staging/rtl8188eu/core/rtw_mlme.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_recv.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_rf.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_security.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_sreset.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 10 +--------- drivers/staging/rtl8188eu/core/rtw_xmit.c | 10 +--------- drivers/staging/rtl8188eu/hal/bb_cfg.c | 10 +--------- drivers/staging/rtl8188eu/hal/fw.c | 13 +------------ drivers/staging/rtl8188eu/hal/hal_com.c | 10 +--------- drivers/staging/rtl8188eu/hal/hal_intf.c | 10 +--------- drivers/staging/rtl8188eu/hal/mac_cfg.c | 18 +++++------------- drivers/staging/rtl8188eu/hal/odm.c | 10 +--------- drivers/staging/rtl8188eu/hal/odm_HWConfig.c | 10 +--------- drivers/staging/rtl8188eu/hal/odm_RTL8188E.c | 10 +--------- drivers/staging/rtl8188eu/hal/phy.c | 10 +--------- drivers/staging/rtl8188eu/hal/pwrseq.c | 10 +--------- drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 10 +--------- drivers/staging/rtl8188eu/hal/rf.c | 10 +--------- drivers/staging/rtl8188eu/hal/rf_cfg.c | 18 +++++------------- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 10 +--------- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 10 +--------- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 10 +--------- .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 10 +--------- drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c | 10 +--------- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 10 +--------- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 10 +--------- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 10 +--------- drivers/staging/rtl8188eu/hal/usb_halinit.c | 10 +--------- .../staging/rtl8188eu/include/Hal8188EPhyCfg.h | 10 +--------- .../staging/rtl8188eu/include/Hal8188EPhyReg.h | 10 +--------- drivers/staging/rtl8188eu/include/HalVerDef.h | 10 +--------- .../staging/rtl8188eu/include/basic_types.h | 12 ++---------- drivers/staging/rtl8188eu/include/drv_types.h | 10 +--------- drivers/staging/rtl8188eu/include/fw.h | 13 +------------ drivers/staging/rtl8188eu/include/hal_com.h | 10 +--------- drivers/staging/rtl8188eu/include/hal_intf.h | 10 +--------- drivers/staging/rtl8188eu/include/ieee80211.h | 10 +--------- drivers/staging/rtl8188eu/include/mlme_osdep.h | 10 +--------- drivers/staging/rtl8188eu/include/mon.h | 10 +--------- .../staging/rtl8188eu/include/mp_custom_oid.h | 10 +--------- drivers/staging/rtl8188eu/include/odm.h | 10 +--------- .../staging/rtl8188eu/include/odm_HWConfig.h | 11 +---------- .../staging/rtl8188eu/include/odm_RTL8188E.h | 10 +--------- .../rtl8188eu/include/odm_RegDefine11N.h | 10 +--------- drivers/staging/rtl8188eu/include/odm_debug.h | 10 +--------- .../staging/rtl8188eu/include/odm_precomp.h | 10 +--------- drivers/staging/rtl8188eu/include/odm_reg.h | 10 +--------- drivers/staging/rtl8188eu/include/odm_types.h | 10 +--------- drivers/staging/rtl8188eu/include/osdep_intf.h | 10 +--------- .../staging/rtl8188eu/include/osdep_service.h | 10 +--------- drivers/staging/rtl8188eu/include/pwrseq.h | 11 +---------- drivers/staging/rtl8188eu/include/pwrseqcmd.h | 10 +--------- drivers/staging/rtl8188eu/include/recv_osdep.h | 10 +--------- .../staging/rtl8188eu/include/rtl8188e_cmd.h | 10 +--------- .../staging/rtl8188eu/include/rtl8188e_dm.h | 10 +--------- .../staging/rtl8188eu/include/rtl8188e_hal.h | 10 +--------- .../staging/rtl8188eu/include/rtl8188e_led.h | 10 +--------- .../staging/rtl8188eu/include/rtl8188e_recv.h | 10 +--------- .../staging/rtl8188eu/include/rtl8188e_spec.h | 10 +--------- .../staging/rtl8188eu/include/rtl8188e_xmit.h | 10 +--------- .../staging/rtl8188eu/include/rtw_android.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_ap.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_cmd.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_debug.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_eeprom.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_efuse.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_event.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_ht.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_ioctl.h | 10 +--------- .../staging/rtl8188eu/include/rtw_ioctl_rtl.h | 10 +--------- .../staging/rtl8188eu/include/rtw_ioctl_set.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_iol.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_led.h | 11 +---------- drivers/staging/rtl8188eu/include/rtw_mlme.h | 10 +--------- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 10 +--------- .../rtl8188eu/include/rtw_mp_phy_regdef.h | 10 +--------- .../staging/rtl8188eu/include/rtw_pwrctrl.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_qos.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_recv.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_rf.h | 10 +--------- .../staging/rtl8188eu/include/rtw_security.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_sreset.h | 10 +--------- drivers/staging/rtl8188eu/include/rtw_xmit.h | 10 +--------- drivers/staging/rtl8188eu/include/sta_info.h | 10 +--------- .../staging/rtl8188eu/include/usb_ops_linux.h | 10 +--------- drivers/staging/rtl8188eu/include/wifi.h | 10 +--------- .../staging/rtl8188eu/include/wlan_bssdef.h | 10 +--------- drivers/staging/rtl8188eu/include/xmit_osdep.h | 10 +--------- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 10 +--------- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 10 +--------- drivers/staging/rtl8188eu/os_dep/mon.c | 10 +--------- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 10 +--------- .../staging/rtl8188eu/os_dep/osdep_service.c | 10 +--------- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 10 +--------- drivers/staging/rtl8188eu/os_dep/rtw_android.c | 10 +--------- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 10 +--------- .../staging/rtl8188eu/os_dep/usb_ops_linux.c | 10 +--------- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 10 +--------- 110 files changed, 119 insertions(+), 1010 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 4140e37bf859..17cd28b893a4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_AP_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index a4654c85ca78..59039211dad2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_CMD_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c index 60d8c7b9f458..67461fdf315c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_debug.c +++ b/drivers/staging/rtl8188eu/core/rtw_debug.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_DEBUG_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 2c4c8c43b1ad..5b8414c568e5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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_EFUSE_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 52ad085383a0..785f78fe51c5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _IEEE80211_C diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 2fca8ae68e05..733fefec134d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_IOCTL_SET_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_iol.c b/drivers/staging/rtl8188eu/core/rtw_iol.c index 2e2145caa56b..6b97e9f2a77b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_iol.c +++ b/drivers/staging/rtl8188eu/core/rtw_iol.c @@ -1,17 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * ******************************************************************************/ #include diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index c4335893d8f6..3e3038bc628e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -1,17 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * ******************************************************************************/ #include diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 50e7cae32f75..5929edcc07aa 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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_MLME_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 59d862f67573..c8c09ae9f5a4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_MLME_EXT_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index ac27f9a023bc..213a10c8576a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_PWRCTRL_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 05936a45eb93..965fe9afda7c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_RECV_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_rf.c b/drivers/staging/rtl8188eu/core/rtw_rf.c index e47be87fb402..094aa15efe44 100644 --- a/drivers/staging/rtl8188eu/core/rtw_rf.c +++ b/drivers/staging/rtl8188eu/core/rtw_rf.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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_RF_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index bfe0b217e679..8e204dc4ab1b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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_SECURITY_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_sreset.c b/drivers/staging/rtl8188eu/core/rtw_sreset.c index a198c5779d50..4097380b0bc9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sreset.c +++ b/drivers/staging/rtl8188eu/core/rtw_sreset.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index f42aa4e0ddb8..53c6ca85d69f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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_STA_MGT_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index ec5a74df9f48..93d8fa66be7a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_WLAN_UTIL_C_ diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 3c034486346b..2f85f58b7934 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _RTW_XMIT_C_ diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c b/drivers/staging/rtl8188eu/hal/bb_cfg.c index 26e0ef224299..1862c1396c85 100644 --- a/drivers/staging/rtl8188eu/hal/bb_cfg.c +++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* ******************************************************************************/ #include "odm_precomp.h" diff --git a/drivers/staging/rtl8188eu/hal/fw.c b/drivers/staging/rtl8188eu/hal/fw.c index 6b67b38a6a9f..1b8341f40995 100644 --- a/drivers/staging/rtl8188eu/hal/fw.c +++ b/drivers/staging/rtl8188eu/hal/fw.c @@ -1,19 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2009-2013 Realtek Corporation. * - * 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. - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * * Contact Information: * wlanfae * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index 960cc406d238..b91902cdb34c 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include #include diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index a11c7b4254f6..aaa1718ca603 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _HAL_INTF_C_ diff --git a/drivers/staging/rtl8188eu/hal/mac_cfg.c b/drivers/staging/rtl8188eu/hal/mac_cfg.c index 6ed5e15ce661..8e849228f376 100644 --- a/drivers/staging/rtl8188eu/hal/mac_cfg.c +++ b/drivers/staging/rtl8188eu/hal/mac_cfg.c @@ -1,17 +1,9 @@ +// SPDX-License-Identifier: GPL-2.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. -* -******************************************************************************/ + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + ******************************************************************************/ #include "odm_precomp.h" #include "phy.h" diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 001d6267b56e..8d087b05df6e 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ /* include files */ diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c index 5fcbe5639e99..0464dc41f860 100644 --- a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ /* include files */ diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c index 91e0f6cee8f4..d5001920f77c 100644 --- a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include "odm_precomp.h" diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 20253b5b6679..2ede7cf2371b 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _RTL8188E_PHYCFG_C_ diff --git a/drivers/staging/rtl8188eu/hal/pwrseq.c b/drivers/staging/rtl8188eu/hal/pwrseq.c index d92a34ea8d60..4aa1dec0b5e4 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseq.c +++ b/drivers/staging/rtl8188eu/hal/pwrseq.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include "pwrseq.h" diff --git a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c index e6867eea3530..249cbc375074 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c +++ b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include diff --git a/drivers/staging/rtl8188eu/hal/rf.c b/drivers/staging/rtl8188eu/hal/rf.c index 8f8c9de6a9bc..39bc3afdf991 100644 --- a/drivers/staging/rtl8188eu/hal/rf.c +++ b/drivers/staging/rtl8188eu/hal/rf.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include diff --git a/drivers/staging/rtl8188eu/hal/rf_cfg.c b/drivers/staging/rtl8188eu/hal/rf_cfg.c index 9712d7b74345..0700d8bd448d 100644 --- a/drivers/staging/rtl8188eu/hal/rf_cfg.c +++ b/drivers/staging/rtl8188eu/hal/rf_cfg.c @@ -1,17 +1,9 @@ +// SPDX-License-Identifier: GPL-2.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. -* -******************************************************************************/ + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + ******************************************************************************/ #include "odm_precomp.h" diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index eeb2d9f82e92..db5d4375277e 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _RTL8188E_CMD_C_ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c index ff227c8b98ca..545d6a6102f1 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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. - * ******************************************************************************/ /* */ /* Description: */ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 54ede4baa0c9..0f92cc9d3bbe 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _HAL_INIT_C_ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c index 9f51f54f866a..0a900827c4fc 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _RTL8188E_REDESC_C_ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c index 460a20558bc0..6883746f3b8b 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _RTL8188E_XMIT_C_ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 12879afb992e..ca0b0f1c2a7f 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 0fc093eb7a77..8979e27b092f 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _RTL8188EU_RECV_C_ #include diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 4f0f512f303c..14622eee56ca 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _RTL8188E_XMIT_C_ #include diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index c3bb183aba38..4b3ece90bb34 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _HCI_HAL_INIT_C_ diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h index 4e5d7fc6de07..da66695a1d8f 100644 --- a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h +++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __INC_HAL8188EPHYCFG_H__ #define __INC_HAL8188EPHYCFG_H__ diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h index 8cbba85e1587..53afcea21c96 100644 --- a/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h +++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __INC_HAL8188EPHYREG_H__ #define __INC_HAL8188EPHYREG_H__ diff --git a/drivers/staging/rtl8188eu/include/HalVerDef.h b/drivers/staging/rtl8188eu/include/HalVerDef.h index d244efff3593..63a144ee2183 100644 --- a/drivers/staging/rtl8188eu/include/HalVerDef.h +++ b/drivers/staging/rtl8188eu/include/HalVerDef.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __HAL_VERSION_DEF_H__ #define __HAL_VERSION_DEF_H__ diff --git a/drivers/staging/rtl8188eu/include/basic_types.h b/drivers/staging/rtl8188eu/include/basic_types.h index 73cc86705cf3..b69b45d95402 100644 --- a/drivers/staging/rtl8188eu/include/basic_types.h +++ b/drivers/staging/rtl8188eu/include/basic_types.h @@ -1,16 +1,8 @@ - /****************************************************************************** +/* SPDX-License-Identifier: GPL-2.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 __BASIC_TYPES_H__ #define __BASIC_TYPES_H__ diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h index 2734565ce802..4ae095837bef 100644 --- a/drivers/staging/rtl8188eu/include/drv_types.h +++ b/drivers/staging/rtl8188eu/include/drv_types.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ /*----------------------------------------------------------------------------- diff --git a/drivers/staging/rtl8188eu/include/fw.h b/drivers/staging/rtl8188eu/include/fw.h index b016f32a8992..9f010c4b8f9c 100644 --- a/drivers/staging/rtl8188eu/include/fw.h +++ b/drivers/staging/rtl8188eu/include/fw.h @@ -1,19 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2009-2013 Realtek Corporation. * - * 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. - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * * Contact Information: * wlanfae * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, diff --git a/drivers/staging/rtl8188eu/include/hal_com.h b/drivers/staging/rtl8188eu/include/hal_com.h index aaf444733507..428a2a92820e 100644 --- a/drivers/staging/rtl8188eu/include/hal_com.h +++ b/drivers/staging/rtl8188eu/include/hal_com.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __HAL_COMMON_H__ #define __HAL_COMMON_H__ diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index da4ee1561c36..5a706818d079 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #ifndef __HAL_INTF_H__ #define __HAL_INTF_H__ diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index 9f480ccec531..1668bb531ead 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __IEEE80211_H #define __IEEE80211_H diff --git a/drivers/staging/rtl8188eu/include/mlme_osdep.h b/drivers/staging/rtl8188eu/include/mlme_osdep.h index 5a35b0866db6..eda16c06336a 100644 --- a/drivers/staging/rtl8188eu/include/mlme_osdep.h +++ b/drivers/staging/rtl8188eu/include/mlme_osdep.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __MLME_OSDEP_H_ #define __MLME_OSDEP_H_ diff --git a/drivers/staging/rtl8188eu/include/mon.h b/drivers/staging/rtl8188eu/include/mon.h index f31fa688e092..297710626d72 100644 --- a/drivers/staging/rtl8188eu/include/mon.h +++ b/drivers/staging/rtl8188eu/include/mon.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * RTL8188EU monitor interface * * Copyright (C) 2015 Jakub Sitnicki - * - * 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. */ /* diff --git a/drivers/staging/rtl8188eu/include/mp_custom_oid.h b/drivers/staging/rtl8188eu/include/mp_custom_oid.h index 1a06ee6ad460..8dd8451cbad0 100644 --- a/drivers/staging/rtl8188eu/include/mp_custom_oid.h +++ b/drivers/staging/rtl8188eu/include/mp_custom_oid.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __CUSTOM_OID_H #define __CUSTOM_OID_H diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 95426b7c6dbf..79affc617f35 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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. - * ******************************************************************************/ diff --git a/drivers/staging/rtl8188eu/include/odm_HWConfig.h b/drivers/staging/rtl8188eu/include/odm_HWConfig.h index da7325d599c6..8cef32dc6350 100644 --- a/drivers/staging/rtl8188eu/include/odm_HWConfig.h +++ b/drivers/staging/rtl8188eu/include/odm_HWConfig.h @@ -1,17 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __HALHWOUTSRC_H__ diff --git a/drivers/staging/rtl8188eu/include/odm_RTL8188E.h b/drivers/staging/rtl8188eu/include/odm_RTL8188E.h index 72b4db67ac33..dbf13c48767d 100644 --- a/drivers/staging/rtl8188eu/include/odm_RTL8188E.h +++ b/drivers/staging/rtl8188eu/include/odm_RTL8188E.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __ODM_RTL8188E_H__ #define __ODM_RTL8188E_H__ diff --git a/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h b/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h index f46f7d43ce00..8663a8ccc75d 100644 --- a/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h +++ b/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __ODM_REGDEFINE11N_H__ diff --git a/drivers/staging/rtl8188eu/include/odm_debug.h b/drivers/staging/rtl8188eu/include/odm_debug.h index 687ff3e9c09a..7ab2483bdacc 100644 --- a/drivers/staging/rtl8188eu/include/odm_debug.h +++ b/drivers/staging/rtl8188eu/include/odm_debug.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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. - * ******************************************************************************/ diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h index 9e5fe1777e6c..c01714be141f 100644 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __ODM_PRECOMP_H__ diff --git a/drivers/staging/rtl8188eu/include/odm_reg.h b/drivers/staging/rtl8188eu/include/odm_reg.h index 3405a44a19ed..b56549ba1256 100644 --- a/drivers/staging/rtl8188eu/include/odm_reg.h +++ b/drivers/staging/rtl8188eu/include/odm_reg.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 Name: odm_reg.h */ diff --git a/drivers/staging/rtl8188eu/include/odm_types.h b/drivers/staging/rtl8188eu/include/odm_types.h index 3474a9c72640..7255f7afff7a 100644 --- a/drivers/staging/rtl8188eu/include/odm_types.h +++ b/drivers/staging/rtl8188eu/include/odm_types.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __ODM_TYPES_H__ #define __ODM_TYPES_H__ diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h index f1fb3d511a45..07c32768f649 100644 --- a/drivers/staging/rtl8188eu/include/osdep_intf.h +++ b/drivers/staging/rtl8188eu/include/osdep_intf.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __OSDEP_INTF_H_ diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 9e390648d93e..fbcba79a0927 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __OSDEP_SERVICE_H_ #define __OSDEP_SERVICE_H_ diff --git a/drivers/staging/rtl8188eu/include/pwrseq.h b/drivers/staging/rtl8188eu/include/pwrseq.h index bd77a50c0d41..aa58db5fbd80 100644 --- a/drivers/staging/rtl8188eu/include/pwrseq.h +++ b/drivers/staging/rtl8188eu/include/pwrseq.h @@ -1,17 +1,8 @@ - +/* SPDX-License-Identifier: GPL-2.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 __HAL8188EPWRSEQ_H__ diff --git a/drivers/staging/rtl8188eu/include/pwrseqcmd.h b/drivers/staging/rtl8188eu/include/pwrseqcmd.h index c4a919ea17ea..8c73322a0314 100644 --- a/drivers/staging/rtl8188eu/include/pwrseqcmd.h +++ b/drivers/staging/rtl8188eu/include/pwrseqcmd.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __HALPWRSEQCMD_H__ #define __HALPWRSEQCMD_H__ diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index 9b43a1314bd5..d2341521cc8e 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RECV_OSDEP_H_ #define __RECV_OSDEP_H_ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h b/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h index 042b4ec656c8..e588656f1de9 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RTL8188E_CMD_H__ #define __RTL8188E_CMD_H__ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_dm.h b/drivers/staging/rtl8188eu/include/rtl8188e_dm.h index c0ffd98d7617..19204335ab4c 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_dm.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_dm.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RTL8188E_DM_H__ #define __RTL8188E_DM_H__ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index b4b5e217105a..54d34976c721 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RTL8188E_HAL_H__ #define __RTL8188E_HAL_H__ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_led.h b/drivers/staging/rtl8188eu/include/rtl8188e_led.h index d1ad6aa8c1e0..74f2554e41d3 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_led.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_led.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RTL8188E_LED_H__ #define __RTL8188E_LED_H__ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h index 0d8bf51c72a9..c2c7ef974dc5 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RTL8188E_RECV_H__ #define __RTL8188E_RECV_H__ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h index 71e2b817e20a..dd943c831d91 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RTL8188E_SPEC_H__ #define __RTL8188E_SPEC_H__ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h index 66205b782721..17e7b3016674 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __RTL8188E_XMIT_H__ #define __RTL8188E_XMIT_H__ diff --git a/drivers/staging/rtl8188eu/include/rtw_android.h b/drivers/staging/rtl8188eu/include/rtw_android.h index e81ee92b0ae2..d7ca7c2fb118 100644 --- a/drivers/staging/rtl8188eu/include/rtw_android.h +++ b/drivers/staging/rtl8188eu/include/rtw_android.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_ANDROID_H__ diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h b/drivers/staging/rtl8188eu/include/rtw_ap.h index e8dd6d4407aa..bca41d68ce9d 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ap.h +++ b/drivers/staging/rtl8188eu/include/rtw_ap.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #ifndef __RTW_AP_H_ #define __RTW_AP_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h index 2c026bf6fecb..fa5e212fc9e0 100644 --- a/drivers/staging/rtl8188eu/include/rtw_cmd.h +++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_CMD_H_ #define __RTW_CMD_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_debug.h b/drivers/staging/rtl8188eu/include/rtw_debug.h index 4873ba49900c..9840e596feaa 100644 --- a/drivers/staging/rtl8188eu/include/rtw_debug.h +++ b/drivers/staging/rtl8188eu/include/rtw_debug.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_DEBUG_H__ #define __RTW_DEBUG_H__ diff --git a/drivers/staging/rtl8188eu/include/rtw_eeprom.h b/drivers/staging/rtl8188eu/include/rtw_eeprom.h index 11d1cb6de506..db25eb580c98 100644 --- a/drivers/staging/rtl8188eu/include/rtw_eeprom.h +++ b/drivers/staging/rtl8188eu/include/rtw_eeprom.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_EEPROM_H__ #define __RTW_EEPROM_H__ diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h index 168c12d3c0b4..adfbf3571c8b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_efuse.h +++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_EFUSE_H__ #define __RTW_EFUSE_H__ diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h index e798e794d962..bfe774e876d1 100644 --- a/drivers/staging/rtl8188eu/include/rtw_event.h +++ b/drivers/staging/rtl8188eu/include/rtw_event.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_EVENT_H_ #define _RTW_EVENT_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_ht.h b/drivers/staging/rtl8188eu/include/rtw_ht.h index d842eade7f57..192fa50c07be 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ht.h +++ b/drivers/staging/rtl8188eu/include/rtw_ht.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_HT_H_ #define _RTW_HT_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl.h index 4c925e610997..5d773c84f11b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_IOCTL_H_ #define _RTW_IOCTL_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h index da4949f94f4c..e29ebfd40a58 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_IOCTL_RTL_H_ #define _RTW_IOCTL_RTL_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h b/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h index b6e14a8b7a11..0be99f6d75ba 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_IOCTL_SET_H_ #define __RTW_IOCTL_SET_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_iol.h b/drivers/staging/rtl8188eu/include/rtw_iol.h index 1f324e68d2ae..53f5fe210e7b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_iol.h +++ b/drivers/staging/rtl8188eu/include/rtw_iol.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_IOL_H_ #define __RTW_IOL_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 884e1397755a..e50237ab05c4 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -1,17 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * ******************************************************************************/ #ifndef __RTW_LED_H_ #define __RTW_LED_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index e6d4175af3a2..35997c521c35 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_MLME_H_ #define __RTW_MLME_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 118bf5509d97..8ecf43d03278 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_MLME_EXT_H_ #define __RTW_MLME_EXT_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h b/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h index aa353aefed3d..9276e2321f2a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h +++ b/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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. - * ******************************************************************************/ /***************************************************************************** * diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h index f39e90cfc031..404634999e35 100644 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #ifndef __RTW_PWRCTRL_H_ #define __RTW_PWRCTRL_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_qos.h b/drivers/staging/rtl8188eu/include/rtw_qos.h index 576dff68d0dc..bf617da3cd6c 100644 --- a/drivers/staging/rtl8188eu/include/rtw_qos.h +++ b/drivers/staging/rtl8188eu/include/rtw_qos.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_QOS_H_ #define _RTW_QOS_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 7e85f700acb3..54b7ba367293 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #ifndef _RTW_RECV_H_ #define _RTW_RECV_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_rf.h b/drivers/staging/rtl8188eu/include/rtw_rf.h index 0718a29e7c9d..b5dfb226f32a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_rf.h +++ b/drivers/staging/rtl8188eu/include/rtw_rf.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_RF_H_ #define __RTW_RF_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h index b1883ca852af..f8d9151fe6e3 100644 --- a/drivers/staging/rtl8188eu/include/rtw_security.h +++ b/drivers/staging/rtl8188eu/include/rtw_security.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_SECURITY_H_ #define __RTW_SECURITY_H_ diff --git a/drivers/staging/rtl8188eu/include/rtw_sreset.h b/drivers/staging/rtl8188eu/include/rtw_sreset.h index 4c4ccd564863..a03989461985 100644 --- a/drivers/staging/rtl8188eu/include/rtw_sreset.h +++ b/drivers/staging/rtl8188eu/include/rtw_sreset.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #ifndef _RTW_SRESET_C_ #define _RTW_SRESET_C_ diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h index b4b3d13ace9e..af6485aa6900 100644 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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_XMIT_H_ #define _RTW_XMIT_H_ diff --git a/drivers/staging/rtl8188eu/include/sta_info.h b/drivers/staging/rtl8188eu/include/sta_info.h index 8f01deed6e4a..dc685a14aeb8 100644 --- a/drivers/staging/rtl8188eu/include/sta_info.h +++ b/drivers/staging/rtl8188eu/include/sta_info.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __STA_INFO_H_ #define __STA_INFO_H_ diff --git a/drivers/staging/rtl8188eu/include/usb_ops_linux.h b/drivers/staging/rtl8188eu/include/usb_ops_linux.h index fb586365d2e5..70d729742839 100644 --- a/drivers/staging/rtl8188eu/include/usb_ops_linux.h +++ b/drivers/staging/rtl8188eu/include/usb_ops_linux.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __USB_OPS_LINUX_H__ #define __USB_OPS_LINUX_H__ diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index 084a246eec19..a41e8eda02fb 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #ifndef _WIFI_H_ #define _WIFI_H_ diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h b/drivers/staging/rtl8188eu/include/wlan_bssdef.h index 6000049bda8f..5e13a6ddf083 100644 --- a/drivers/staging/rtl8188eu/include/wlan_bssdef.h +++ b/drivers/staging/rtl8188eu/include/wlan_bssdef.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __WLAN_BSSDEF_H__ #define __WLAN_BSSDEF_H__ diff --git a/drivers/staging/rtl8188eu/include/xmit_osdep.h b/drivers/staging/rtl8188eu/include/xmit_osdep.h index 00ebad88f0d1..5283a6d53700 100644 --- a/drivers/staging/rtl8188eu/include/xmit_osdep.h +++ b/drivers/staging/rtl8188eu/include/xmit_osdep.h @@ -1,16 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.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 __XMIT_OSDEP_H_ #define __XMIT_OSDEP_H_ diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 3d648cb55a6d..80ccd19e776d 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _IOCTL_LINUX_C_ diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c index 831c1ecc5e28..aa08793699ca 100644 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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. - * ******************************************************************************/ diff --git a/drivers/staging/rtl8188eu/os_dep/mon.c b/drivers/staging/rtl8188eu/os_dep/mon.c index 225c23fc69dc..73b9599fe0dc 100644 --- a/drivers/staging/rtl8188eu/os_dep/mon.c +++ b/drivers/staging/rtl8188eu/os_dep/mon.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * RTL8188EU monitor interface * * Copyright (C) 2015 Jakub Sitnicki - * - * 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 diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index add1ba00f3e9..8dd17986d969 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 _OS_INTFS_C_ diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 3be87252fd62..78daef6704ac 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _OSDEP_SERVICE_C_ diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 7ec53a9dfa27..9f9a595191b6 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include #include diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c index 336e7023f7f7..34080c0ce14a 100644 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #include diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 127ecf896fc9..0d0517d226a6 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.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 pr_fmt(fmt) "R8188EU: " fmt diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 7e75030475f7..20727ad83e01 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _USB_OPS_LINUX_C_ diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 8ac9567c954d..a4210aaf300c 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * ******************************************************************************/ #define _XMIT_OSDEP_C_ From 3b20b0037a59c2344696eebb076f5bad12dd72e0 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 8 Jun 2018 14:16:31 +0200 Subject: [PATCH 091/903] staging: mt7621-pinctrl: add SPDX identifier It's good to have SPDX identifiers in driver files to make it easier to audit the kernel tree for correct licenses. Fix up the one of staging mt7621-pinctrl file to have a proper SPDX identifier, based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 0c3e498ae99c..df783e558f90 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -1,10 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * linux/drivers/pinctrl/pinctrl-rt2880.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 - * publishhed by the Free Software Foundation. - * * Copyright (C) 2013 John Crispin */ From c3de99239efd15d956c0f2b8475f6670f6f69b7b Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 8 Jun 2018 14:16:32 +0200 Subject: [PATCH 092/903] staging: mt7621-pinctrl: replace 'unsigned' types with 'unsigned int' This commit replaces all 'unsigned' type declarations along the driver code in favour of the preferred one 'unsigned int'. This also silence checkpatch script warnings about this issue. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- .../staging/mt7621-pinctrl/pinctrl-rt2880.c | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index df783e558f90..4a32d2b95735 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -49,7 +49,7 @@ static int rt2880_get_group_count(struct pinctrl_dev *pctrldev) } static const char *rt2880_get_group_name(struct pinctrl_dev *pctrldev, - unsigned group) + unsigned int group) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); @@ -60,9 +60,9 @@ static const char *rt2880_get_group_name(struct pinctrl_dev *pctrldev, } static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev, - unsigned group, - const unsigned **pins, - unsigned *num_pins) + unsigned int group, + const unsigned int **pins, + unsigned int *num_pins) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); @@ -76,7 +76,8 @@ static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev, } static void rt2880_pinctrl_dt_free_map(struct pinctrl_dev *pctrldev, - struct pinctrl_map *map, unsigned num_maps) + struct pinctrl_map *map, + unsigned int num_maps) { int i; @@ -89,7 +90,7 @@ static void rt2880_pinctrl_dt_free_map(struct pinctrl_dev *pctrldev, static void rt2880_pinctrl_pin_dbg_show(struct pinctrl_dev *pctrldev, struct seq_file *s, - unsigned offset) + unsigned int offset) { seq_printf(s, "ralink pio"); } @@ -122,7 +123,7 @@ static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev, static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, struct device_node *np_config, struct pinctrl_map **map, - unsigned *num_maps) + unsigned int *num_maps) { int max_maps = 0; struct pinctrl_map *tmp; @@ -168,7 +169,7 @@ static int rt2880_pmx_func_count(struct pinctrl_dev *pctrldev) } static const char *rt2880_pmx_func_name(struct pinctrl_dev *pctrldev, - unsigned func) + unsigned int func) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); @@ -176,9 +177,9 @@ static const char *rt2880_pmx_func_name(struct pinctrl_dev *pctrldev, } static int rt2880_pmx_group_get_groups(struct pinctrl_dev *pctrldev, - unsigned func, + unsigned int func, const char * const **groups, - unsigned * const num_groups) + unsigned int * const num_groups) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); @@ -193,8 +194,8 @@ static int rt2880_pmx_group_get_groups(struct pinctrl_dev *pctrldev, } static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, - unsigned func, - unsigned group) + unsigned int func, + unsigned int group) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); u32 mode = 0; @@ -238,7 +239,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, static int rt2880_pmx_group_gpio_request_enable(struct pinctrl_dev *pctrldev, struct pinctrl_gpio_range *range, - unsigned pin) + unsigned int pin) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); From 63e57b953f747ce39f8de51548b4e584f00273ae Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 8 Jun 2018 14:16:33 +0200 Subject: [PATCH 093/903] staging: mt7621-pinctrl: remove unnecessary 'out of memory' message Messages when memory allocation fails are not needed at all and checkpatch script complains about them. Remove one in this driver code. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 4a32d2b95735..8d5d4f15dc64 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -379,10 +379,8 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) /* strlen("ioXY") + 1 = 5 */ char *name = devm_kzalloc(p->dev, 5, GFP_KERNEL); - if (!name) { - dev_err(p->dev, "Failed to allocate pad name\n"); + if (!name) return -ENOMEM; - } snprintf(name, 5, "io%d", i); p->pads[i].number = i; p->pads[i].name = name; From 32c6dcffdd20e8697ca5f2ce13f9bfbc582f1caf Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 8 Jun 2018 14:16:34 +0200 Subject: [PATCH 094/903] staging: mt7621-pinctrl: replace ENOSYS with better fitting error code This commit replaces ENOSYS return with ENOTSUPP silencing the following checkpatch warning: WARNING: ENOSYS means 'invalid syscall nr' and nothing else Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 8d5d4f15dc64..1e49a7b9e5fb 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -398,7 +398,7 @@ static int rt2880_pinmux_probe(struct platform_device *pdev) struct device_node *np; if (!rt2880_pinmux_data) - return -ENOSYS; + return -ENOTSUPP; /* setup the private data */ p = devm_kzalloc(&pdev->dev, sizeof(struct rt2880_priv), GFP_KERNEL); From 2e477f9ee5e3085a0d020acd6b614eca568981ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:35 +0200 Subject: [PATCH 095/903] staging: mt7621-mmc: Remove unused variable in msdc_command_resp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable resp in msdc_command_resp is once set and never read, delete it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 648a2dd1436e..7cfadb41a53d 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -886,13 +886,10 @@ static unsigned int msdc_command_resp(struct msdc_host *host, void __iomem *base = host->base; u32 opcode = cmd->opcode; //u32 rawcmd; - u32 resp; u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO | MSDC_INT_ACMD19_DONE; - resp = host->cmd_rsp; - BUG_ON(in_interrupt()); //init_completion(&host->cmd_done); //sdr_set_bits(MSDC_INTEN, wints); From 73384e52756a607fa5d1bff1fa06ed9f4ae52651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:36 +0200 Subject: [PATCH 096/903] staging: mt7621-mmc: Remove unused macro msdc_fifo_write8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro msdc_fifo_write8 is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 7cfadb41a53d..4a69bc84bbd2 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -150,7 +150,6 @@ static int msdc_rsp[] = { #define msdc_txfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 16) #define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0) #define msdc_fifo_write32(v) sdr_write32(MSDC_TXDATA, (v)) -#define msdc_fifo_write8(v) sdr_write8(MSDC_TXDATA, (v)) #define msdc_fifo_read32() sdr_read32(MSDC_RXDATA) #define msdc_fifo_read8() sdr_read8(MSDC_RXDATA) From 12c3ab44fabb834699e2463f6530289a5680a30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:37 +0200 Subject: [PATCH 097/903] staging: mt7621-mmc: Remove unused macro msdc_fifo_read8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro msdc_fifo_read8 is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 4a69bc84bbd2..98bcb0fe6f40 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -151,7 +151,6 @@ static int msdc_rsp[] = { #define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0) #define msdc_fifo_write32(v) sdr_write32(MSDC_TXDATA, (v)) #define msdc_fifo_read32() sdr_read32(MSDC_RXDATA) -#define msdc_fifo_read8() sdr_read8(MSDC_RXDATA) #define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO) From bbe95e24212f704db81fc1c36e343514b50f4ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:38 +0200 Subject: [PATCH 098/903] staging: mt7621-mmc: Remove unused macro msdc_fifo_write32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro msdc_fifo_write32 is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 98bcb0fe6f40..9e00f86a0398 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -149,7 +149,6 @@ static int msdc_rsp[] = { #define msdc_txfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 16) #define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0) -#define msdc_fifo_write32(v) sdr_write32(MSDC_TXDATA, (v)) #define msdc_fifo_read32() sdr_read32(MSDC_RXDATA) #define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO) From dbed911180b0d88bd29a04280eabce25b1f12e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:39 +0200 Subject: [PATCH 099/903] staging: mt7621-mmc: Remove unused macro msdc_fifo_read32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro msdc_fifo_read32 is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 9e00f86a0398..0f9cba918586 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -149,7 +149,6 @@ static int msdc_rsp[] = { #define msdc_txfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 16) #define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0) -#define msdc_fifo_read32() sdr_read32(MSDC_RXDATA) #define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO) From 98336f9924d242e26de1f4cf14976af0beaa536b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:40 +0200 Subject: [PATCH 100/903] staging: mt7621-mmc: Remove unused macro msdc_txfifocnt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro msdc_txfifocnt is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 0f9cba918586..c6aced0c0a6a 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -147,7 +147,6 @@ static int msdc_rsp[] = { 7, /* RESP_R1b */ }; -#define msdc_txfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 16) #define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0) #define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO) From 09cb808cfdf3aaf129d8a01e43b281e8d6dcc30e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:41 +0200 Subject: [PATCH 101/903] staging: mt7621-mmc: Remove unused macro msdc_rxfifocnt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro msdc_rxfifocnt is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index c6aced0c0a6a..78a681a72f11 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -147,8 +147,6 @@ static int msdc_rsp[] = { 7, /* RESP_R1b */ }; -#define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0) - #define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO) #define msdc_retry(expr, retry, cnt) \ From 8fbcf12087ef17490e3c59dcf53db9bccb5e81ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:42 +0200 Subject: [PATCH 102/903] staging: mt7621-mmc: Replace sdr_write32 with writel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code uses a macro (sdr_write32) for writing to hardware, but it is only a writel with switched arguments, so replace it to get nearer to upstream code. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 1 - drivers/staging/mt7621-mmc/sd.c | 64 +++++++++++++------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 33fa59a019ec..e8e79aab52f8 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -950,7 +950,6 @@ struct msdc_host { #define sdr_read8(reg) readb(reg) #define sdr_read32(reg) readl(reg) #define sdr_write8(reg, val) writeb(val, reg) -#define sdr_write32(reg, val) writel(val, reg) static inline void sdr_set_bits(void __iomem *reg, u32 bs) { diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 78a681a72f11..e6232f5ac6a8 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -174,7 +174,7 @@ static void msdc_reset_hw(struct msdc_host *host) #define msdc_clr_int() \ do { \ volatile u32 val = sdr_read32(MSDC_INT); \ - sdr_write32(MSDC_INT, val); \ + writel(val, MSDC_INT); \ } while (0) #define msdc_clr_fifo() \ @@ -235,8 +235,8 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */ #define sdc_send_cmd(cmd, arg) \ do { \ - sdr_write32(SDC_ARG, (arg)); \ - sdr_write32(SDC_CMD, (cmd)); \ + writel((arg), SDC_ARG); \ + writel((cmd), SDC_CMD); \ } while (0) // can modify to read h/w register. @@ -476,7 +476,7 @@ static void msdc_select_clksrc(struct msdc_host *host, unsigned char clksrc) } else { val &= ~0x3; val |= clksrc; } - sdr_write32(MSDC_CLKSRC_REG, val); + writel(val, MSDC_CLKSRC_REG); host->hclk = hclks[clksrc]; host->hw->clk_src = clksrc; @@ -1044,14 +1044,14 @@ static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) case MSDC_MODE_DMA_BASIC: BUG_ON(host->xfer_size > 65535); BUG_ON(dma->sglen != 1); - sdr_write32(MSDC_DMA_SA, PHYSADDR(sg_dma_address(sg))); + writel(PHYSADDR(sg_dma_address(sg)), MSDC_DMA_SA); sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_LASTBUF, 1); //#if defined (CONFIG_RALINK_MT7620) if (ralink_soc == MT762X_SOC_MT7620A) sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_XFERSZ, sg_dma_len(sg)); //#elif defined (CONFIG_RALINK_MT7621) || defined (CONFIG_RALINK_MT7628) else - sdr_write32((void __iomem *)(RALINK_MSDC_BASE + 0xa8), sg_dma_len(sg)); + writel(sg_dma_len(sg), (void __iomem *)(RALINK_MSDC_BASE + 0xa8)); //#endif sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, MSDC_BRUST_64B); @@ -1094,7 +1094,7 @@ static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) MSDC_BRUST_64B); sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1); - sdr_write32(MSDC_DMA_SA, PHYSADDR((u32)dma->gpd_addr)); + writel(PHYSADDR((u32)dma->gpd_addr), MSDC_DMA_SA); break; default: @@ -1172,7 +1172,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) } } - sdr_write32(SDC_BLK_NUM, data->blocks); + writel(data->blocks, SDC_BLK_NUM); //msdc_clr_fifo(); /* no need */ msdc_dma_on(); /* enable DMA mode first!! */ @@ -1465,8 +1465,8 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0); cur_rxdly1 = (cur_dat4 << 24) | (cur_dat5 << 16) | (cur_dat6 << 8) | (cur_dat7 << 0); - sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0); - sdr_write32(MSDC_DAT_RDDLY1, cur_rxdly1); + writel(cur_rxdly0, MSDC_DAT_RDDLY0); + writel(cur_rxdly1, MSDC_DAT_RDDLY1); } while (++rxdly < 32); @@ -1555,7 +1555,7 @@ static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq) cur_dat3 = orig_dat3; cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0); - sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0); + writel(cur_rxdly0, MSDC_DAT_RDDLY0); } while (++rxdly < 32); done: @@ -1726,7 +1726,7 @@ static void msdc_set_buswidth(struct msdc_host *host, u32 width) break; } - sdr_write32(SDC_CFG, val); + writel(val, SDC_CFG); N_MSG(CFG, "Bus Width = %d", width); } @@ -1787,12 +1787,12 @@ static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) MSDC_SMPL_FALLING); //} /* for tuning debug */ } else { /* default value */ - sdr_write32(MSDC_IOCON, 0x00000000); - // sdr_write32(MSDC_DAT_RDDLY0, 0x00000000); - sdr_write32(MSDC_DAT_RDDLY0, 0x10101010); // for MT7620 E2 and afterward - sdr_write32(MSDC_DAT_RDDLY1, 0x00000000); - // sdr_write32(MSDC_PAD_TUNE, 0x00000000); - sdr_write32(MSDC_PAD_TUNE, 0x84101010); // for MT7620 E2 and afterward + writel(0x00000000, MSDC_IOCON); + // writel(0x00000000, MSDC_DAT_RDDLY0); + writel(0x10101010, MSDC_DAT_RDDLY0); // for MT7620 E2 and afterward + writel(0x00000000, MSDC_DAT_RDDLY1); + // writel(0x00000000, MSDC_PAD_TUNE); + writel(0x84101010, MSDC_PAD_TUNE); // for MT7620 E2 and afterward } msdc_set_mclk(host, ddr, ios->clock); } @@ -1882,7 +1882,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) u32 intsts = sdr_read32(MSDC_INT); u32 inten = sdr_read32(MSDC_INTEN); inten &= intsts; - sdr_write32(MSDC_INT, intsts); /* clear interrupts */ + writel(intsts, MSDC_INT); /* clear interrupts */ /* MSG will cause fatal error */ /* card change interrupt */ @@ -2078,21 +2078,21 @@ static void msdc_init_hw(struct msdc_host *host) /* Disable and clear all interrupts */ sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN)); - sdr_write32(MSDC_INT, sdr_read32(MSDC_INT)); + writel(sdr_read32(MSDC_INT), MSDC_INT); #if 1 /* reset tuning parameter */ - sdr_write32(MSDC_PAD_CTL0, 0x00090000); - sdr_write32(MSDC_PAD_CTL1, 0x000A0000); - sdr_write32(MSDC_PAD_CTL2, 0x000A0000); - // sdr_write32(MSDC_PAD_TUNE, 0x00000000); - sdr_write32(MSDC_PAD_TUNE, 0x84101010); // for MT7620 E2 and afterward - // sdr_write32(MSDC_DAT_RDDLY0, 0x00000000); - sdr_write32(MSDC_DAT_RDDLY0, 0x10101010); // for MT7620 E2 and afterward - sdr_write32(MSDC_DAT_RDDLY1, 0x00000000); - sdr_write32(MSDC_IOCON, 0x00000000); + writel(0x00090000, MSDC_PAD_CTL0); + writel(0x000A0000, MSDC_PAD_CTL1); + writel(0x000A0000, MSDC_PAD_CTL2); + // writel( 0x00000000, MSDC_PAD_TUNE); + writel(0x84101010, MSDC_PAD_TUNE); // for MT7620 E2 and afterward + // writel(0x00000000, MSDC_DAT_RDDLY0); + writel(0x10101010, MSDC_DAT_RDDLY0); // for MT7620 E2 and afterward + writel(0x00000000, MSDC_DAT_RDDLY1); + writel(0x00000000, MSDC_IOCON); #if 0 // use MT7620 default value: 0x403c004f - sdr_write32(MSDC_PATCH_BIT0, 0x003C000F); /* bit0 modified: Rx Data Clock Source: 1 -> 2.0*/ + writel(0x003C000F, MSDC_PATCH_BIT0); /* bit0 modified: Rx Data Clock Source: 1 -> 2.0*/ #endif if (sdr_read32(MSDC_ECO_VER) >= 4) { @@ -2157,7 +2157,7 @@ static void msdc_deinit_hw(struct msdc_host *host) /* Disable and clear all interrupts */ sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN)); - sdr_write32(MSDC_INT, sdr_read32(MSDC_INT)); + writel(sdr_read32(MSDC_INT), MSDC_INT); /* Disable card detection */ msdc_enable_cd_irq(host, 0); @@ -2420,7 +2420,7 @@ static int __init mt_msdc_init(void) // Set the pins for sdxc to sdxc mode //FIXME: this should be done by pinctl and not by the sd driver reg = sdr_read32((void __iomem *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 << 18); - sdr_write32((void __iomem *)(RALINK_SYSCTL_BASE + 0x60), reg); + writel(reg, (void __iomem *)(RALINK_SYSCTL_BASE + 0x60)); ret = platform_driver_register(&mt_msdc_driver); if (ret) { From e988d35a6240252eaf802111d64e0a701d8dea13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:43 +0200 Subject: [PATCH 103/903] staging: mt7621-mmc: Replace sdr_read32 with readl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code uses a macro (sdr_read32) for reading from hardware, but it is only a readl, so replace it to get nearer to upstream code. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 1 - drivers/staging/mt7621-mmc/sd.c | 98 +++++++++++++------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index e8e79aab52f8..29e2ede6816b 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -948,7 +948,6 @@ struct msdc_host { }; #define sdr_read8(reg) readb(reg) -#define sdr_read32(reg) readl(reg) #define sdr_write8(reg, val) writeb(val, reg) static inline void sdr_set_bits(void __iomem *reg, u32 bs) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index e6232f5ac6a8..1d0829e88886 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -167,13 +167,13 @@ static void msdc_reset_hw(struct msdc_host *host) void __iomem *base = host->base; sdr_set_bits(MSDC_CFG, MSDC_CFG_RST); - while (sdr_read32(MSDC_CFG) & MSDC_CFG_RST) + while (readl(MSDC_CFG) & MSDC_CFG_RST) cpu_relax(); } #define msdc_clr_int() \ do { \ - volatile u32 val = sdr_read32(MSDC_INT); \ + volatile u32 val = readl(MSDC_INT); \ writel(val, MSDC_INT); \ } while (0) @@ -181,12 +181,12 @@ static void msdc_reset_hw(struct msdc_host *host) do { \ int retry = 3, cnt = 1000; \ sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \ - msdc_retry(sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \ + msdc_retry(readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \ } while (0) #define msdc_irq_save(val) \ do { \ - val = sdr_read32(MSDC_INTEN); \ + val = readl(MSDC_INTEN); \ sdr_clr_bits(MSDC_INTEN, val); \ } while (0) @@ -230,8 +230,8 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */ (void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \ } while (0) -#define sdc_is_busy() (sdr_read32(SDC_STS) & SDC_STS_SDCBUSY) -#define sdc_is_cmd_busy() (sdr_read32(SDC_STS) & SDC_STS_CMDBUSY) +#define sdc_is_busy() (readl(SDC_STS) & SDC_STS_SDCBUSY) +#define sdc_is_cmd_busy() (readl(SDC_STS) & SDC_STS_CMDBUSY) #define sdc_send_cmd(cmd, arg) \ do { \ @@ -240,7 +240,7 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */ } while (0) // can modify to read h/w register. -//#define is_card_present(h) ((sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1); +//#define is_card_present(h) ((readl(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1); #define is_card_present(h) (((struct msdc_host *)(h))->card_inserted) /* +++ by chhung */ @@ -426,7 +426,7 @@ static void msdc_tasklet_card(struct work_struct *work) spin_lock(&host->lock); - status = sdr_read32(MSDC_PS); + status = readl(MSDC_PS); if (cd_active_low) inserted = (status & MSDC_PS_CDSTS) ? 0 : 1; else @@ -469,8 +469,8 @@ static void msdc_select_clksrc(struct msdc_host *host, unsigned char clksrc) BUG_ON(clksrc > 3); INIT_MSG("set clock source to <%d>", clksrc); - val = sdr_read32(MSDC_CLKSRC_REG); - if (sdr_read32(MSDC_ECO_VER) >= 4) { + val = readl(MSDC_CLKSRC_REG); + if (readl(MSDC_ECO_VER) >= 4) { val &= ~(0x3 << clk_src_bit[host->id]); val |= clksrc << clk_src_bit[host->id]; } else { @@ -531,7 +531,7 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, unsigned int hz) sdr_set_field(MSDC_CFG, MSDC_CFG_CKDIV, div); /* wait clock stable */ - while (!(sdr_read32(MSDC_CFG) & MSDC_CFG_CKSTB)) + while (!(readl(MSDC_CFG) & MSDC_CFG_CKSTB)) cpu_relax(); host->sclk = sclk; @@ -940,7 +940,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host, /* memory card CRC */ if (host->hw->flags & MSDC_REMOVABLE && cmd->error == -EIO) { - if (sdr_read32(SDC_CMD) & 0x1800) { /* check if has data phase */ + if (readl(SDC_CMD) & 0x1800) { /* check if has data phase */ msdc_abort_data(host); } else { /* do basic: reset*/ @@ -953,7 +953,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host, // check DAT0 /* if (resp == RESP_R1B) { - while ((sdr_read32(MSDC_PS) & 0x10000) != 0x10000); + while ((readl(MSDC_PS) & 0x10000) != 0x10000); } */ /* CMD12 Error Handle */ @@ -1007,11 +1007,11 @@ static void msdc_dma_stop(struct msdc_host *host) //u32 retries=500; u32 wints = MSDC_INTEN_XFER_COMPL | MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR; - N_MSG(DMA, "DMA status: 0x%.8x", sdr_read32(MSDC_DMA_CFG)); - //while (sdr_read32(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS); + N_MSG(DMA, "DMA status: 0x%.8x", readl(MSDC_DMA_CFG)); + //while (readl(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS); sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_STOP, 1); - while (sdr_read32(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS) + while (readl(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS) ; //dsb(); /* --- by chhung */ @@ -1101,9 +1101,9 @@ static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) break; } - N_MSG(DMA, "DMA_CTRL = 0x%x", sdr_read32(MSDC_DMA_CTRL)); - N_MSG(DMA, "DMA_CFG = 0x%x", sdr_read32(MSDC_DMA_CFG)); - N_MSG(DMA, "DMA_SA = 0x%x", sdr_read32(MSDC_DMA_SA)); + N_MSG(DMA, "DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL)); + N_MSG(DMA, "DMA_CFG = 0x%x", readl(MSDC_DMA_CFG)); + N_MSG(DMA, "DMA_SA = 0x%x", readl(MSDC_DMA_SA)); } @@ -1200,10 +1200,10 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) spin_unlock(&host->lock); if (!wait_for_completion_timeout(&host->xfer_done, DAT_TIMEOUT)) { ERR_MSG("XXX CMD<%d> wait xfer_done<%d> timeout!!", cmd->opcode, data->blocks * data->blksz); - ERR_MSG(" DMA_SA = 0x%x", sdr_read32(MSDC_DMA_SA)); - ERR_MSG(" DMA_CA = 0x%x", sdr_read32(MSDC_DMA_CA)); - ERR_MSG(" DMA_CTRL = 0x%x", sdr_read32(MSDC_DMA_CTRL)); - ERR_MSG(" DMA_CFG = 0x%x", sdr_read32(MSDC_DMA_CFG)); + ERR_MSG(" DMA_SA = 0x%x", readl(MSDC_DMA_SA)); + ERR_MSG(" DMA_CA = 0x%x", readl(MSDC_DMA_CA)); + ERR_MSG(" DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL)); + ERR_MSG(" DMA_CFG = 0x%x", readl(MSDC_DMA_CFG)); data->error = -ETIMEDOUT; msdc_reset_hw(host); @@ -1346,7 +1346,7 @@ static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd) } /* should be EIO */ - if (sdr_read32(SDC_CMD) & 0x1800) { /* check if has data phase */ + if (readl(SDC_CMD) & 0x1800) { /* check if has data phase */ msdc_abort_data(host); } } @@ -1406,7 +1406,7 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) dcrc &= ~SDC_DCRC_STS_NEG; ERR_MSG("TUNE_BREAD<%s> dcrc<0x%x> DATRDDLY0/1<0x%x><0x%x> dsmpl<0x%x>", (result == 0 && dcrc == 0) ? "PASS" : "FAIL", dcrc, - sdr_read32(MSDC_DAT_RDDLY0), sdr_read32(MSDC_DAT_RDDLY1), cur_dsmpl); + readl(MSDC_DAT_RDDLY0), readl(MSDC_DAT_RDDLY1), cur_dsmpl); /* Fix me: result is 0, but dcrc is still exist */ if (result == 0 && dcrc == 0) { @@ -1422,11 +1422,11 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) } } - cur_rxdly0 = sdr_read32(MSDC_DAT_RDDLY0); - cur_rxdly1 = sdr_read32(MSDC_DAT_RDDLY1); + cur_rxdly0 = readl(MSDC_DAT_RDDLY0); + cur_rxdly1 = readl(MSDC_DAT_RDDLY1); /* E1 ECO. YD: Reverse */ - if (sdr_read32(MSDC_ECO_VER) >= 4) { + if (readl(MSDC_ECO_VER) >= 4) { orig_dat0 = (cur_rxdly0 >> 24) & 0x1F; orig_dat1 = (cur_rxdly0 >> 16) & 0x1F; orig_dat2 = (cur_rxdly0 >> 8) & 0x1F; @@ -1494,10 +1494,10 @@ static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq) /* Tune Method 2. just DAT0 */ sdr_set_field(MSDC_IOCON, MSDC_IOCON_DDLSEL, 1); - cur_rxdly0 = sdr_read32(MSDC_DAT_RDDLY0); + cur_rxdly0 = readl(MSDC_DAT_RDDLY0); /* E1 ECO. YD: Reverse */ - if (sdr_read32(MSDC_ECO_VER) >= 4) { + if (readl(MSDC_ECO_VER) >= 4) { orig_dat0 = (cur_rxdly0 >> 24) & 0x1F; orig_dat1 = (cur_rxdly0 >> 16) & 0x1F; orig_dat2 = (cur_rxdly0 >> 8) & 0x1F; @@ -1708,7 +1708,7 @@ static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq) static void msdc_set_buswidth(struct msdc_host *host, u32 width) { void __iomem *base = host->base; - u32 val = sdr_read32(SDC_CFG); + u32 val = readl(SDC_CFG); val &= ~SDC_CFG_BUSWIDTH; @@ -1808,7 +1808,7 @@ static int msdc_ops_get_ro(struct mmc_host *mmc) if (host->hw->flags & MSDC_WP_PIN_EN) { /* set for card */ spin_lock_irqsave(&host->lock, flags); - ro = (sdr_read32(MSDC_PS) >> 31); + ro = (readl(MSDC_PS) >> 31); spin_unlock_irqrestore(&host->lock, flags); } return ro; @@ -1843,9 +1843,9 @@ static int msdc_ops_get_cd(struct mmc_host *mmc) #else // CD if (cd_active_low) - present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1; + present = (readl(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1; else - present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0; + present = (readl(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0; host->card_inserted = present; #endif spin_unlock_irqrestore(&host->lock, flags); @@ -1879,8 +1879,8 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) MSDC_INT_ACMD19_DONE; u32 datsts = MSDC_INT_DATCRCERR | MSDC_INT_DATTMO; - u32 intsts = sdr_read32(MSDC_INT); - u32 inten = sdr_read32(MSDC_INTEN); inten &= intsts; + u32 intsts = readl(MSDC_INT); + u32 inten = readl(MSDC_INTEN); inten &= intsts; writel(intsts, MSDC_INT); /* clear interrupts */ /* MSG will cause fatal error */ @@ -1917,11 +1917,11 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) IRQ_MSG("XXX CMD<%d> MSDC_INT_DATTMO", host->mrq->cmd->opcode); data->error = -ETIMEDOUT; } else if (intsts & MSDC_INT_DATCRCERR) { - IRQ_MSG("XXX CMD<%d> MSDC_INT_DATCRCERR, SDC_DCRC_STS<0x%x>", host->mrq->cmd->opcode, sdr_read32(SDC_DCRC_STS)); + IRQ_MSG("XXX CMD<%d> MSDC_INT_DATCRCERR, SDC_DCRC_STS<0x%x>", host->mrq->cmd->opcode, readl(SDC_DCRC_STS)); data->error = -EIO; } - //if(sdr_read32(MSDC_INTEN) & MSDC_INT_XFER_COMPL) { + //if(readl(MSDC_INTEN) & MSDC_INT_XFER_COMPL) { complete(&host->xfer_done); /* Read CRC come fast, XFER_COMPL not enabled */ } } @@ -1936,14 +1936,14 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) case RESP_NONE: break; case RESP_R2: - *rsp++ = sdr_read32(SDC_RESP3); *rsp++ = sdr_read32(SDC_RESP2); - *rsp++ = sdr_read32(SDC_RESP1); *rsp++ = sdr_read32(SDC_RESP0); + *rsp++ = readl(SDC_RESP3); *rsp++ = readl(SDC_RESP2); + *rsp++ = readl(SDC_RESP1); *rsp++ = readl(SDC_RESP0); break; default: /* Response types 1, 3, 4, 5, 6, 7(1b) */ if ((intsts & MSDC_INT_ACMDRDY) || (intsts & MSDC_INT_ACMD19_DONE)) - *rsp = sdr_read32(SDC_ACMD_RESP); + *rsp = readl(SDC_ACMD_RESP); else - *rsp = sdr_read32(SDC_RESP0); + *rsp = readl(SDC_RESP0); break; } } else if ((intsts & MSDC_INT_RSPCRCERR) || (intsts & MSDC_INT_ACMDCRCERR)) { @@ -1967,7 +1967,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) /* mmc irq interrupts */ if (intsts & MSDC_INT_MMCIRQ) - printk(KERN_INFO "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", host->id, sdr_read32(SDC_CSTS)); + printk(KERN_INFO "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", host->id, readl(SDC_CSTS)); #ifdef MT6575_SD_DEBUG { @@ -2077,8 +2077,8 @@ static void msdc_init_hw(struct msdc_host *host) sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN); /* Disable and clear all interrupts */ - sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN)); - writel(sdr_read32(MSDC_INT), MSDC_INT); + sdr_clr_bits(MSDC_INTEN, readl(MSDC_INTEN)); + writel(readl(MSDC_INT), MSDC_INT); #if 1 /* reset tuning parameter */ @@ -2095,7 +2095,7 @@ static void msdc_init_hw(struct msdc_host *host) writel(0x003C000F, MSDC_PATCH_BIT0); /* bit0 modified: Rx Data Clock Source: 1 -> 2.0*/ #endif - if (sdr_read32(MSDC_ECO_VER) >= 4) { + if (readl(MSDC_ECO_VER) >= 4) { if (host->id == 1) { sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_WRDAT_CRCS, 1); sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_CMD_RSP, 1); @@ -2156,8 +2156,8 @@ static void msdc_deinit_hw(struct msdc_host *host) void __iomem *base = host->base; /* Disable and clear all interrupts */ - sdr_clr_bits(MSDC_INTEN, sdr_read32(MSDC_INTEN)); - writel(sdr_read32(MSDC_INT), MSDC_INT); + sdr_clr_bits(MSDC_INTEN, readl(MSDC_INTEN)); + writel(readl(MSDC_INT), MSDC_INT); /* Disable card detection */ msdc_enable_cd_irq(host, 0); @@ -2419,7 +2419,7 @@ static int __init mt_msdc_init(void) // Set the pins for sdxc to sdxc mode //FIXME: this should be done by pinctl and not by the sd driver - reg = sdr_read32((void __iomem *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 << 18); + reg = readl((void __iomem *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 << 18); writel(reg, (void __iomem *)(RALINK_SYSCTL_BASE + 0x60)); ret = platform_driver_register(&mt_msdc_driver); From 85e25ffc9922a9dc1b3758f75d2bf09749839c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:44 +0200 Subject: [PATCH 104/903] staging: mt7621-mmc: Remove unused macro sdr_read8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro sdr_read8 is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 29e2ede6816b..adccabe32660 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -947,7 +947,6 @@ struct msdc_host { u32 app_cmd_arg; }; -#define sdr_read8(reg) readb(reg) #define sdr_write8(reg, val) writeb(val, reg) static inline void sdr_set_bits(void __iomem *reg, u32 bs) From 9705766bfba49c073bd7c7759e6cd9881f243a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:45 +0200 Subject: [PATCH 105/903] staging: mt7621-mmc: Remove unused macro sdr_write8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro sdr_write8 is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index adccabe32660..375cb109806e 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -947,8 +947,6 @@ struct msdc_host { u32 app_cmd_arg; }; -#define sdr_write8(reg, val) writeb(val, reg) - static inline void sdr_set_bits(void __iomem *reg, u32 bs) { u32 val = readl(reg); From b9ec4b83781a45d310b79cc986159176295332db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:46 +0200 Subject: [PATCH 106/903] staging: mt7621-mmc: Remove register debugging structures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current code has structures for all the registers of the device, but these are never used and there are also masks for all of them, so these structures do not contain any useful information. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 411 ------------------------- 1 file changed, 411 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 375cb109806e..07f48d526888 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -478,417 +478,6 @@ struct bd { u32 rsv3:16; }; -/*--------------------------------------------------------------------------*/ -/* Register Debugging Structure */ -/*--------------------------------------------------------------------------*/ - -struct msdc_cfg_reg { - u32 msdc:1; - u32 ckpwn:1; - u32 rst:1; - u32 pio:1; - u32 ckdrven:1; - u32 start18v:1; - u32 pass18v:1; - u32 ckstb:1; - u32 ckdiv:8; - u32 ckmod:2; - u32 pad:14; -}; - -struct msdc_iocon_reg { - u32 sdr104cksel:1; - u32 rsmpl:1; - u32 dsmpl:1; - u32 ddlysel:1; - u32 ddr50ckd:1; - u32 dsplsel:1; - u32 pad1:10; - u32 d0spl:1; - u32 d1spl:1; - u32 d2spl:1; - u32 d3spl:1; - u32 d4spl:1; - u32 d5spl:1; - u32 d6spl:1; - u32 d7spl:1; - u32 riscsz:1; - u32 pad2:7; -}; - -struct msdc_ps_reg { - u32 cden:1; - u32 cdsts:1; - u32 pad1:10; - u32 cddebounce:4; - u32 dat:8; - u32 cmd:1; - u32 pad2:6; - u32 wp:1; -}; - -struct msdc_int_reg { - u32 mmcirq:1; - u32 cdsc:1; - u32 pad1:1; - u32 atocmdrdy:1; - u32 atocmdtmo:1; - u32 atocmdcrc:1; - u32 dmaqempty:1; - u32 sdioirq:1; - u32 cmdrdy:1; - u32 cmdtmo:1; - u32 rspcrc:1; - u32 csta:1; - u32 xfercomp:1; - u32 dxferdone:1; - u32 dattmo:1; - u32 datcrc:1; - u32 atocmd19done:1; - u32 pad2:15; -}; - -struct msdc_inten_reg { - u32 mmcirq:1; - u32 cdsc:1; - u32 pad1:1; - u32 atocmdrdy:1; - u32 atocmdtmo:1; - u32 atocmdcrc:1; - u32 dmaqempty:1; - u32 sdioirq:1; - u32 cmdrdy:1; - u32 cmdtmo:1; - u32 rspcrc:1; - u32 csta:1; - u32 xfercomp:1; - u32 dxferdone:1; - u32 dattmo:1; - u32 datcrc:1; - u32 atocmd19done:1; - u32 pad2:15; -}; - -struct msdc_fifocs_reg { - u32 rxcnt:8; - u32 pad1:8; - u32 txcnt:8; - u32 pad2:7; - u32 clr:1; -}; - -struct msdc_txdat_reg { - u32 val; -}; - -struct msdc_rxdat_reg { - u32 val; -}; - -struct sdc_cfg_reg { - u32 sdiowkup:1; - u32 inswkup:1; - u32 pad1:14; - u32 buswidth:2; - u32 pad2:1; - u32 sdio:1; - u32 sdioide:1; - u32 intblkgap:1; - u32 pad4:2; - u32 dtoc:8; -}; - -struct sdc_cmd_reg { - u32 cmd:6; - u32 brk:1; - u32 rsptyp:3; - u32 pad1:1; - u32 dtype:2; - u32 rw:1; - u32 stop:1; - u32 goirq:1; - u32 blklen:12; - u32 atocmd:2; - u32 volswth:1; - u32 pad2:1; -}; - -struct sdc_arg_reg { - u32 arg; -}; - -struct sdc_sts_reg { - u32 sdcbusy:1; - u32 cmdbusy:1; - u32 pad:29; - u32 swrcmpl:1; -}; - -struct sdc_resp0_reg { - u32 val; -}; - -struct sdc_resp1_reg { - u32 val; -}; - -struct sdc_resp2_reg { - u32 val; -}; - -struct sdc_resp3_reg { - u32 val; -}; - -struct sdc_blknum_reg { - u32 num; -}; - -struct sdc_csts_reg { - u32 sts; -}; - -struct sdc_cstsen_reg { - u32 sts; -}; - -struct sdc_datcrcsts_reg { - u32 datcrcsts:8; - u32 ddrcrcsts:4; - u32 pad:20; -}; - -struct emmc_cfg0_reg { - u32 bootstart:1; - u32 bootstop:1; - u32 bootmode:1; - u32 pad1:9; - u32 bootwaidly:3; - u32 bootsupp:1; - u32 pad2:16; -}; - -struct emmc_cfg1_reg { - u32 bootcrctmc:16; - u32 pad:4; - u32 bootacktmc:12; -}; - -struct emmc_sts_reg { - u32 bootcrcerr:1; - u32 bootackerr:1; - u32 bootdattmo:1; - u32 bootacktmo:1; - u32 bootupstate:1; - u32 bootackrcv:1; - u32 bootdatrcv:1; - u32 pad:25; -}; - -struct emmc_iocon_reg { - u32 bootrst:1; - u32 pad:31; -}; - -struct msdc_acmd_resp_reg { - u32 val; -}; - -struct msdc_acmd19_trg_reg { - u32 tunesel:4; - u32 pad:28; -}; - -struct msdc_acmd19_sts_reg { - u32 val; -}; - -struct msdc_dma_sa_reg { - u32 addr; -}; - -struct msdc_dma_ca_reg { - u32 addr; -}; - -struct msdc_dma_ctrl_reg { - u32 start:1; - u32 stop:1; - u32 resume:1; - u32 pad1:5; - u32 mode:1; - u32 pad2:1; - u32 lastbuf:1; - u32 pad3:1; - u32 brustsz:3; - u32 pad4:1; - u32 xfersz:16; -}; - -struct msdc_dma_cfg_reg { - u32 status:1; - u32 decsen:1; - u32 pad1:2; - u32 bdcsen:1; - u32 gpdcsen:1; - u32 pad2:26; -}; - -struct msdc_dbg_sel_reg { - u32 sel:16; - u32 pad2:16; -}; - -struct msdc_dbg_out_reg { - u32 val; -}; - -struct msdc_pad_ctl0_reg { - u32 clkdrvn:3; - u32 rsv0:1; - u32 clkdrvp:3; - u32 rsv1:1; - u32 clksr:1; - u32 rsv2:7; - u32 clkpd:1; - u32 clkpu:1; - u32 clksmt:1; - u32 clkies:1; - u32 clktdsel:4; - u32 clkrdsel:8; -}; - -struct msdc_pad_ctl1_reg { - u32 cmddrvn:3; - u32 rsv0:1; - u32 cmddrvp:3; - u32 rsv1:1; - u32 cmdsr:1; - u32 rsv2:7; - u32 cmdpd:1; - u32 cmdpu:1; - u32 cmdsmt:1; - u32 cmdies:1; - u32 cmdtdsel:4; - u32 cmdrdsel:8; -}; - -struct msdc_pad_ctl2_reg { - u32 datdrvn:3; - u32 rsv0:1; - u32 datdrvp:3; - u32 rsv1:1; - u32 datsr:1; - u32 rsv2:7; - u32 datpd:1; - u32 datpu:1; - u32 datsmt:1; - u32 daties:1; - u32 dattdsel:4; - u32 datrdsel:8; -}; - -struct msdc_pad_tune_reg { - u32 wrrxdly:3; - u32 pad1:5; - u32 rdrxdly:8; - u32 pad2:16; -}; - -struct msdc_dat_rddly0 { - u32 dat0:5; - u32 rsv0:3; - u32 dat1:5; - u32 rsv1:3; - u32 dat2:5; - u32 rsv2:3; - u32 dat3:5; - u32 rsv3:3; -}; - -struct msdc_dat_rddly1 { - u32 dat4:5; - u32 rsv4:3; - u32 dat5:5; - u32 rsv5:3; - u32 dat6:5; - u32 rsv6:3; - u32 dat7:5; - u32 rsv7:3; -}; - -struct msdc_hw_dbg_reg { - u32 dbg0sel:8; - u32 dbg1sel:6; - u32 pad1:2; - u32 dbg2sel:6; - u32 pad2:2; - u32 dbg3sel:6; - u32 pad3:2; -}; - -struct msdc_version_reg { - u32 val; -}; - -struct msdc_eco_ver_reg { - u32 val; -}; - -struct msdc_regs { - struct msdc_cfg_reg msdc_cfg; /* base+0x00h */ - struct msdc_iocon_reg msdc_iocon; /* base+0x04h */ - struct msdc_ps_reg msdc_ps; /* base+0x08h */ - struct msdc_int_reg msdc_int; /* base+0x0ch */ - struct msdc_inten_reg msdc_inten; /* base+0x10h */ - struct msdc_fifocs_reg msdc_fifocs; /* base+0x14h */ - struct msdc_txdat_reg msdc_txdat; /* base+0x18h */ - struct msdc_rxdat_reg msdc_rxdat; /* base+0x1ch */ - u32 rsv1[4]; - struct sdc_cfg_reg sdc_cfg; /* base+0x30h */ - struct sdc_cmd_reg sdc_cmd; /* base+0x34h */ - struct sdc_arg_reg sdc_arg; /* base+0x38h */ - struct sdc_sts_reg sdc_sts; /* base+0x3ch */ - struct sdc_resp0_reg sdc_resp0; /* base+0x40h */ - struct sdc_resp1_reg sdc_resp1; /* base+0x44h */ - struct sdc_resp2_reg sdc_resp2; /* base+0x48h */ - struct sdc_resp3_reg sdc_resp3; /* base+0x4ch */ - struct sdc_blknum_reg sdc_blknum; /* base+0x50h */ - u32 rsv2[1]; - struct sdc_csts_reg sdc_csts; /* base+0x58h */ - struct sdc_cstsen_reg sdc_cstsen; /* base+0x5ch */ - struct sdc_datcrcsts_reg sdc_dcrcsta; /* base+0x60h */ - u32 rsv3[3]; - struct emmc_cfg0_reg emmc_cfg0; /* base+0x70h */ - struct emmc_cfg1_reg emmc_cfg1; /* base+0x74h */ - struct emmc_sts_reg emmc_sts; /* base+0x78h */ - struct emmc_iocon_reg emmc_iocon; /* base+0x7ch */ - struct msdc_acmd_resp_reg acmd_resp; /* base+0x80h */ - struct msdc_acmd19_trg_reg acmd19_trg; /* base+0x84h */ - struct msdc_acmd19_sts_reg acmd19_sts; /* base+0x88h */ - u32 rsv4[1]; - struct msdc_dma_sa_reg dma_sa; /* base+0x90h */ - struct msdc_dma_ca_reg dma_ca; /* base+0x94h */ - struct msdc_dma_ctrl_reg dma_ctrl; /* base+0x98h */ - struct msdc_dma_cfg_reg dma_cfg; /* base+0x9ch */ - struct msdc_dbg_sel_reg dbg_sel; /* base+0xa0h */ - struct msdc_dbg_out_reg dbg_out; /* base+0xa4h */ - u32 rsv5[2]; - u32 patch0; /* base+0xb0h */ - u32 patch1; /* base+0xb4h */ - u32 rsv6[10]; - struct msdc_pad_ctl0_reg pad_ctl0; /* base+0xe0h */ - struct msdc_pad_ctl1_reg pad_ctl1; /* base+0xe4h */ - struct msdc_pad_ctl2_reg pad_ctl2; /* base+0xe8h */ - struct msdc_pad_tune_reg pad_tune; /* base+0xech */ - struct msdc_dat_rddly0 dat_rddly0; /* base+0xf0h */ - struct msdc_dat_rddly1 dat_rddly1; /* base+0xf4h */ - struct msdc_hw_dbg_reg hw_dbg; /* base+0xf8h */ - u32 rsv7[1]; - struct msdc_version_reg version; /* base+0x100h */ - struct msdc_eco_ver_reg eco_ver; /* base+0x104h */ -}; - struct msdc_dma { u32 sglen; /* size of scatter list */ struct scatterlist *sg; /* I/O scatter list */ From f3e1b5766c5945b70c7d4dc36f145ba02c9b23e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:47 +0200 Subject: [PATCH 107/903] staging: mt7621-mmc: Remove DMA basic mode code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The driver currently only uses DMA linked mode and the upstream driver does the same, so remove the basic mode code. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 90 ++++++++++++--------------------- 1 file changed, 33 insertions(+), 57 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 1d0829e88886..1196e8eb86c5 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1040,67 +1040,43 @@ static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) struct gpd *gpd; struct bd *bd; - switch (dma->mode) { - case MSDC_MODE_DMA_BASIC: - BUG_ON(host->xfer_size > 65535); - BUG_ON(dma->sglen != 1); - writel(PHYSADDR(sg_dma_address(sg)), MSDC_DMA_SA); - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_LASTBUF, 1); -//#if defined (CONFIG_RALINK_MT7620) - if (ralink_soc == MT762X_SOC_MT7620A) - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_XFERSZ, sg_dma_len(sg)); -//#elif defined (CONFIG_RALINK_MT7621) || defined (CONFIG_RALINK_MT7628) + /* calculate the required number of gpd */ + num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD; + BUG_ON(num != 1); + + gpd = dma->gpd; + bd = dma->bd; + + /* modify gpd*/ + //gpd->intr = 0; + gpd->hwo = 1; /* hw will clear it */ + gpd->bdp = 1; + gpd->chksum = 0; /* need to clear first. */ + gpd->chksum = msdc_dma_calcs((u8 *)gpd, 16); + + /* modify bd*/ + for_each_sg(dma->sg, sg, dma->sglen, j) { + bd[j].blkpad = 0; + bd[j].dwpad = 0; + bd[j].ptr = (void *)sg_dma_address(sg); + bd[j].buflen = sg_dma_len(sg); + + if (j == dma->sglen - 1) + bd[j].eol = 1; /* the last bd */ else - writel(sg_dma_len(sg), (void __iomem *)(RALINK_MSDC_BASE + 0xa8)); -//#endif - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, - MSDC_BRUST_64B); - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 0); - break; - case MSDC_MODE_DMA_DESC: + bd[j].eol = 0; - /* calculate the required number of gpd */ - num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD; - BUG_ON(num != 1); - - gpd = dma->gpd; - bd = dma->bd; - - /* modify gpd*/ - //gpd->intr = 0; - gpd->hwo = 1; /* hw will clear it */ - gpd->bdp = 1; - gpd->chksum = 0; /* need to clear first. */ - gpd->chksum = msdc_dma_calcs((u8 *)gpd, 16); - - /* modify bd*/ - for_each_sg(dma->sg, sg, dma->sglen, j) { - bd[j].blkpad = 0; - bd[j].dwpad = 0; - bd[j].ptr = (void *)sg_dma_address(sg); - bd[j].buflen = sg_dma_len(sg); - - if (j == dma->sglen - 1) - bd[j].eol = 1; /* the last bd */ - else - bd[j].eol = 0; - - bd[j].chksum = 0; /* checksume need to clear first */ - bd[j].chksum = msdc_dma_calcs((u8 *)(&bd[j]), 16); - } - - sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, 1); - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, - MSDC_BRUST_64B); - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1); - - writel(PHYSADDR((u32)dma->gpd_addr), MSDC_DMA_SA); - break; - - default: - break; + bd[j].chksum = 0; /* checksume need to clear first */ + bd[j].chksum = msdc_dma_calcs((u8 *)(&bd[j]), 16); } + sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, 1); + sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, + MSDC_BRUST_64B); + sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1); + + writel(PHYSADDR((u32)dma->gpd_addr), MSDC_DMA_SA); + N_MSG(DMA, "DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL)); N_MSG(DMA, "DMA_CFG = 0x%x", readl(MSDC_DMA_CFG)); N_MSG(DMA, "DMA_SA = 0x%x", readl(MSDC_DMA_SA)); From 1668d5fc7b811f13827cf6bf26482dfd2537d34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:48 +0200 Subject: [PATCH 108/903] staging: mt7621-mmc: Remove unused field mode from msdc_dma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The field mode of struct msdc_dma has no remaining use, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 1 - drivers/staging/mt7621-mmc/sd.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 07f48d526888..8eb30d908f9d 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -481,7 +481,6 @@ struct bd { struct msdc_dma { u32 sglen; /* size of scatter list */ struct scatterlist *sg; /* I/O scatter list */ - u8 mode; /* dma mode */ struct gpd *gpd; /* pointer to gpd array */ struct bd *bd; /* pointer to bd array */ diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 1196e8eb86c5..3066fa3799ac 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1091,10 +1091,7 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, dma->sg = sg; dma->sglen = sglen; - dma->mode = MSDC_MODE_DMA_DESC; - - N_MSG(DMA, "DMA mode<%d> sglen<%d> xfersz<%d>", dma->mode, dma->sglen, - host->xfer_size); + N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", dma->sglen, host->xfer_size); msdc_dma_config(host, dma); } From 8cfba8ac750d3167128bda34bee7e408f4ae2785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:49 +0200 Subject: [PATCH 109/903] staging: mt7621-mmc: Refactor dma setup process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current code uses two functions for dma setup, msdc_dma_config and msdc_dma_setup. By now msdc_dma_setup is nearly empty and mainly calls msdc_dma_config, so the later one can be inline into the first one. While doing this there is also some refactoring done. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 34 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 3066fa3799ac..923b0687918d 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1030,18 +1030,24 @@ static u8 msdc_dma_calcs(u8 *buf, u32 len) return 0xFF - (u8)sum; } -/* gpd bd setup + dma registers */ -static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) +static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, + struct scatterlist *sg_cmd, unsigned int sglen) { void __iomem *base = host->base; - //u32 i, j, num, bdlen, arg, xfersz; - u32 j, num; struct scatterlist *sg; struct gpd *gpd; struct bd *bd; + u32 j, num; + + BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ + + dma->sg = sg_cmd; + dma->sglen = sglen; + + N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size); /* calculate the required number of gpd */ - num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD; + num = (sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD; BUG_ON(num != 1); gpd = dma->gpd; @@ -1055,13 +1061,13 @@ static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) gpd->chksum = msdc_dma_calcs((u8 *)gpd, 16); /* modify bd*/ - for_each_sg(dma->sg, sg, dma->sglen, j) { + for_each_sg(sg_cmd, sg, sglen, j) { bd[j].blkpad = 0; bd[j].dwpad = 0; bd[j].ptr = (void *)sg_dma_address(sg); bd[j].buflen = sg_dma_len(sg); - if (j == dma->sglen - 1) + if (j == sglen - 1) bd[j].eol = 1; /* the last bd */ else bd[j].eol = 0; @@ -1080,20 +1086,6 @@ static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) N_MSG(DMA, "DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL)); N_MSG(DMA, "DMA_CFG = 0x%x", readl(MSDC_DMA_CFG)); N_MSG(DMA, "DMA_SA = 0x%x", readl(MSDC_DMA_SA)); - -} - -static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, - struct scatterlist *sg, unsigned int sglen) -{ - BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ - - dma->sg = sg; - dma->sglen = sglen; - - N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", dma->sglen, host->xfer_size); - - msdc_dma_config(host, dma); } static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) From acbd652b033d3197ea859bc18a6ba5524af0520b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:50 +0200 Subject: [PATCH 110/903] staging: mt7621-mmc: Remove unused field sg from msdc_dma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The field sg from struct msdc_dma is once set and never read, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 1 - drivers/staging/mt7621-mmc/sd.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 8eb30d908f9d..c8c5c349adf8 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -480,7 +480,6 @@ struct bd { struct msdc_dma { u32 sglen; /* size of scatter list */ - struct scatterlist *sg; /* I/O scatter list */ struct gpd *gpd; /* pointer to gpd array */ struct bd *bd; /* pointer to bd array */ diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 923b0687918d..050c4a910aef 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1041,7 +1041,6 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ - dma->sg = sg_cmd; dma->sglen = sglen; N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size); From fe219842d688c8d5acd9823ea92967cc0f8df1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:51 +0200 Subject: [PATCH 111/903] staging: mt7621-mmc: Remove unused field sglen from msdc_dma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The field sglen from struct msdc_dma is once set and never read, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 2 -- drivers/staging/mt7621-mmc/sd.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index c8c5c349adf8..4b56d9a37b84 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -479,8 +479,6 @@ struct bd { }; struct msdc_dma { - u32 sglen; /* size of scatter list */ - struct gpd *gpd; /* pointer to gpd array */ struct bd *bd; /* pointer to bd array */ dma_addr_t gpd_addr; /* the physical address of gpd array */ diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 050c4a910aef..e1077068604d 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1041,8 +1041,6 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ - dma->sglen = sglen; - N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size); /* calculate the required number of gpd */ From d812c6a9bba4fad6eb82ff19428f6c6e4df3cdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:52 +0200 Subject: [PATCH 112/903] staging: mt7621-mmc: Remove variable num form msdc_dma_setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable num in msdc_dma_setup is only used for a BUG_ON statement, so it can be removed by inlining the condition. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index e1077068604d..68dfbf38b0ea 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1037,15 +1037,14 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, struct scatterlist *sg; struct gpd *gpd; struct bd *bd; - u32 j, num; + u32 j; BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size); /* calculate the required number of gpd */ - num = (sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD; - BUG_ON(num != 1); + BUG_ON(((sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD) != 1); gpd = dma->gpd; bd = dma->bd; From 41015d06e64fdafcbbb4ca17baf8a673f5ae3f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:53 +0200 Subject: [PATCH 113/903] staging: mt7621-mmc: Remove unnecessary BUG_ON() in msdc_dma_setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The BUG_ON() removed by this patch is just a duplicate of a prior BUG_ON() statement. There the condition is just clearer, it checks weather sglen > MAX_BD_NUM and MAX_BD_NUM is equal MAX_BD_PER_GPD. So this statement can be safely removed. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 68dfbf38b0ea..a506c7e19086 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1043,9 +1043,6 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size); - /* calculate the required number of gpd */ - BUG_ON(((sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD) != 1); - gpd = dma->gpd; bd = dma->bd; From e327df5e886e8a34165a931128e10ecd99377256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:54 +0200 Subject: [PATCH 114/903] staging: mt7621-mmc: Make msdc_clr_fifo a function and relax cpu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the current code, msdc_clr_fifo is a macro and just busy waits for a limited amount of time for the fifo clear to finish. That is not correct, the programming manual hits, that the user should wait until the bit is cleared by hardware and not a limited amount of time. So the code is changed to a function, that also relaxes the cpu while busy waiting. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index a506c7e19086..01a925ae662e 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -177,12 +177,14 @@ static void msdc_reset_hw(struct msdc_host *host) writel(val, MSDC_INT); \ } while (0) -#define msdc_clr_fifo() \ - do { \ - int retry = 3, cnt = 1000; \ - sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \ - msdc_retry(readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \ - } while (0) +static void msdc_clr_fifo(struct msdc_host *host) +{ + void __iomem *base = host->base; + + sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); + while (readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR) + cpu_relax(); +} #define msdc_irq_save(val) \ do { \ @@ -554,7 +556,7 @@ static void msdc_abort_data(struct msdc_host *host) ERR_MSG("Need to Abort."); msdc_reset_hw(host); - msdc_clr_fifo(); + msdc_clr_fifo(host); msdc_clr_int(); // need to check FIFO count 0 ? @@ -945,7 +947,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host, } else { /* do basic: reset*/ msdc_reset_hw(host); - msdc_clr_fifo(); + msdc_clr_fifo(host); msdc_clr_int(); } cmd->error = msdc_tune_cmdrsp(host, cmd); @@ -1131,7 +1133,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) } writel(data->blocks, SDC_BLK_NUM); - //msdc_clr_fifo(); /* no need */ + //msdc_clr_fifo(host); /* no need */ msdc_dma_on(); /* enable DMA mode first!! */ init_completion(&host->xfer_done); @@ -1165,7 +1167,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) data->error = -ETIMEDOUT; msdc_reset_hw(host); - msdc_clr_fifo(); + msdc_clr_fifo(host); msdc_clr_int(); } spin_lock(&host->lock); @@ -1868,7 +1870,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) if (intsts & datsts) { /* do basic reset, or stop command will sdc_busy */ msdc_reset_hw(host); - msdc_clr_fifo(); + msdc_clr_fifo(host); msdc_clr_int(); if (intsts & MSDC_INT_DATTMO) { @@ -1917,7 +1919,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) IRQ_MSG("XXX CMD<%d> MSDC_INT_CMDTMO", cmd->opcode); cmd->error = -ETIMEDOUT; msdc_reset_hw(host); - msdc_clr_fifo(); + msdc_clr_fifo(host); msdc_clr_int(); } complete(&host->cmd_done); @@ -2029,7 +2031,7 @@ static void msdc_init_hw(struct msdc_host *host) /* Reset */ msdc_reset_hw(host); - msdc_clr_fifo(); + msdc_clr_fifo(host); /* Disable card detection */ sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN); From 6a1636fa1146bbeb86e1731d815f3528e8dec1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:55 +0200 Subject: [PATCH 115/903] staging: mt7621-mmc: Remove unused macro msdc_retry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro msdc_retry is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 01a925ae662e..0e94bb0d5927 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -149,19 +149,6 @@ static int msdc_rsp[] = { #define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO) -#define msdc_retry(expr, retry, cnt) \ - do { \ - int backup = cnt; \ - while (retry) { \ - if (!(expr)) \ - break; \ - if (cnt-- == 0) { \ - retry--; mdelay(1); cnt = backup; \ - } \ - } \ - WARN_ON(retry == 0); \ - } while (0) - static void msdc_reset_hw(struct msdc_host *host) { void __iomem *base = host->base; From a98c143734924e78c40320183fc9739ac7453169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:56 +0200 Subject: [PATCH 116/903] staging: mt7621-mmc: Remove unused macro MAX_BD_PER_GPD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro MAX_BD_PER_GPD is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 0e94bb0d5927..e99a12002646 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -91,7 +91,6 @@ #define MAX_GPD_NUM (1 + 1) /* one null gpd */ #define MAX_BD_NUM (1024) -#define MAX_BD_PER_GPD (MAX_BD_NUM) #define MAX_HW_SGMTS (MAX_BD_NUM) #define MAX_PHY_SGMTS (MAX_BD_NUM) From 6aab8b53084a487ccdff095aec091814d9db70c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:57 +0200 Subject: [PATCH 117/903] staging: mt7621-mmc: Remove unused variable from msdc_tune_request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable cmd in the function msdc_tune_request is set but never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index e99a12002646..c5139a20e10f 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1556,12 +1556,10 @@ static int msdc_check_busy(struct mmc_host *mmc, struct msdc_host *host) static int msdc_tune_request(struct mmc_host *mmc, struct mmc_request *mrq) { struct msdc_host *host = mmc_priv(mmc); - struct mmc_command *cmd; struct mmc_data *data; //u32 base = host->base; int ret = 0, read; - cmd = mrq->cmd; data = mrq->cmd->data; read = data->flags & MMC_DATA_READ ? 1 : 0; From 8a5b9f049bed94a16ca99070364fad5033e82d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:58 +0200 Subject: [PATCH 118/903] staging: mt7621-mmc: Remove MSDC_MODE_* defines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MSDC_MODE_* defines are all never used and do not contain any information about the device, so remove them. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 4b56d9a37b84..9b6cd6db37df 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -56,13 +56,6 @@ #define MSDC_MS (0) #define MSDC_SDMMC (1) -#define MSDC_MODE_UNKNOWN (0) -#define MSDC_MODE_PIO (1) -#define MSDC_MODE_DMA_BASIC (2) -#define MSDC_MODE_DMA_DESC (3) -#define MSDC_MODE_DMA_ENHANCED (4) -#define MSDC_MODE_MMC_STREAM (5) - #define MSDC_BUS_1BITS (0) #define MSDC_BUS_4BITS (1) #define MSDC_BUS_8BITS (2) From 2dfc73d5bb908e38789c715de1aceeae0fb2f4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:14:59 +0200 Subject: [PATCH 119/903] staging: mt7621-mmc: Cleanup source of base address for io MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the base address for all io operations is hidden behind a macro, REG_ADD. This macro uses the symbol "base" as the base address and all functions set base = host->base. This is hard to read, so the whole wrapping is removed and host->base is directly inserted in the io access. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/mt6575_sd.h | 161 +++-------- drivers/staging/mt7621-mmc/sd.c | 378 +++++++++++++------------ 2 files changed, 236 insertions(+), 303 deletions(-) diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 9b6cd6db37df..4e287c140acb 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -41,11 +41,6 @@ // #include /* --- by chhung */ -/*--------------------------------------------------------------------------*/ -/* Common Macro */ -/*--------------------------------------------------------------------------*/ -#define REG_ADDR(x) (base + OFFSET_##x) - /*--------------------------------------------------------------------------*/ /* Common Definition */ /*--------------------------------------------------------------------------*/ @@ -95,117 +90,51 @@ enum { /*--------------------------------------------------------------------------*/ /* Register Offset */ /*--------------------------------------------------------------------------*/ -#define OFFSET_MSDC_CFG (0x0) -#define OFFSET_MSDC_IOCON (0x04) -#define OFFSET_MSDC_PS (0x08) -#define OFFSET_MSDC_INT (0x0c) -#define OFFSET_MSDC_INTEN (0x10) -#define OFFSET_MSDC_FIFOCS (0x14) -#define OFFSET_MSDC_TXDATA (0x18) -#define OFFSET_MSDC_RXDATA (0x1c) -#define OFFSET_SDC_CFG (0x30) -#define OFFSET_SDC_CMD (0x34) -#define OFFSET_SDC_ARG (0x38) -#define OFFSET_SDC_STS (0x3c) -#define OFFSET_SDC_RESP0 (0x40) -#define OFFSET_SDC_RESP1 (0x44) -#define OFFSET_SDC_RESP2 (0x48) -#define OFFSET_SDC_RESP3 (0x4c) -#define OFFSET_SDC_BLK_NUM (0x50) -#define OFFSET_SDC_CSTS (0x58) -#define OFFSET_SDC_CSTS_EN (0x5c) -#define OFFSET_SDC_DCRC_STS (0x60) -#define OFFSET_EMMC_CFG0 (0x70) -#define OFFSET_EMMC_CFG1 (0x74) -#define OFFSET_EMMC_STS (0x78) -#define OFFSET_EMMC_IOCON (0x7c) -#define OFFSET_SDC_ACMD_RESP (0x80) -#define OFFSET_SDC_ACMD19_TRG (0x84) -#define OFFSET_SDC_ACMD19_STS (0x88) -#define OFFSET_MSDC_DMA_SA (0x90) -#define OFFSET_MSDC_DMA_CA (0x94) -#define OFFSET_MSDC_DMA_CTRL (0x98) -#define OFFSET_MSDC_DMA_CFG (0x9c) -#define OFFSET_MSDC_DBG_SEL (0xa0) -#define OFFSET_MSDC_DBG_OUT (0xa4) -#define OFFSET_MSDC_PATCH_BIT (0xb0) -#define OFFSET_MSDC_PATCH_BIT1 (0xb4) -#define OFFSET_MSDC_PAD_CTL0 (0xe0) -#define OFFSET_MSDC_PAD_CTL1 (0xe4) -#define OFFSET_MSDC_PAD_CTL2 (0xe8) -#define OFFSET_MSDC_PAD_TUNE (0xec) -#define OFFSET_MSDC_DAT_RDDLY0 (0xf0) -#define OFFSET_MSDC_DAT_RDDLY1 (0xf4) -#define OFFSET_MSDC_HW_DBG (0xf8) -#define OFFSET_MSDC_VERSION (0x100) -#define OFFSET_MSDC_ECO_VER (0x104) - -/*--------------------------------------------------------------------------*/ -/* Register Address */ -/*--------------------------------------------------------------------------*/ - -/* common register */ -#define MSDC_CFG REG_ADDR(MSDC_CFG) -#define MSDC_IOCON REG_ADDR(MSDC_IOCON) -#define MSDC_PS REG_ADDR(MSDC_PS) -#define MSDC_INT REG_ADDR(MSDC_INT) -#define MSDC_INTEN REG_ADDR(MSDC_INTEN) -#define MSDC_FIFOCS REG_ADDR(MSDC_FIFOCS) -#define MSDC_TXDATA REG_ADDR(MSDC_TXDATA) -#define MSDC_RXDATA REG_ADDR(MSDC_RXDATA) -#define MSDC_PATCH_BIT0 REG_ADDR(MSDC_PATCH_BIT) - -/* sdmmc register */ -#define SDC_CFG REG_ADDR(SDC_CFG) -#define SDC_CMD REG_ADDR(SDC_CMD) -#define SDC_ARG REG_ADDR(SDC_ARG) -#define SDC_STS REG_ADDR(SDC_STS) -#define SDC_RESP0 REG_ADDR(SDC_RESP0) -#define SDC_RESP1 REG_ADDR(SDC_RESP1) -#define SDC_RESP2 REG_ADDR(SDC_RESP2) -#define SDC_RESP3 REG_ADDR(SDC_RESP3) -#define SDC_BLK_NUM REG_ADDR(SDC_BLK_NUM) -#define SDC_CSTS REG_ADDR(SDC_CSTS) -#define SDC_CSTS_EN REG_ADDR(SDC_CSTS_EN) -#define SDC_DCRC_STS REG_ADDR(SDC_DCRC_STS) - -/* emmc register*/ -#define EMMC_CFG0 REG_ADDR(EMMC_CFG0) -#define EMMC_CFG1 REG_ADDR(EMMC_CFG1) -#define EMMC_STS REG_ADDR(EMMC_STS) -#define EMMC_IOCON REG_ADDR(EMMC_IOCON) - -/* auto command register */ -#define SDC_ACMD_RESP REG_ADDR(SDC_ACMD_RESP) -#define SDC_ACMD19_TRG REG_ADDR(SDC_ACMD19_TRG) -#define SDC_ACMD19_STS REG_ADDR(SDC_ACMD19_STS) - -/* dma register */ -#define MSDC_DMA_SA REG_ADDR(MSDC_DMA_SA) -#define MSDC_DMA_CA REG_ADDR(MSDC_DMA_CA) -#define MSDC_DMA_CTRL REG_ADDR(MSDC_DMA_CTRL) -#define MSDC_DMA_CFG REG_ADDR(MSDC_DMA_CFG) - -/* pad ctrl register */ -#define MSDC_PAD_CTL0 REG_ADDR(MSDC_PAD_CTL0) -#define MSDC_PAD_CTL1 REG_ADDR(MSDC_PAD_CTL1) -#define MSDC_PAD_CTL2 REG_ADDR(MSDC_PAD_CTL2) - -/* data read delay */ -#define MSDC_DAT_RDDLY0 REG_ADDR(MSDC_DAT_RDDLY0) -#define MSDC_DAT_RDDLY1 REG_ADDR(MSDC_DAT_RDDLY1) - -/* debug register */ -#define MSDC_DBG_SEL REG_ADDR(MSDC_DBG_SEL) -#define MSDC_DBG_OUT REG_ADDR(MSDC_DBG_OUT) - -/* misc register */ -#define MSDC_PATCH_BIT REG_ADDR(MSDC_PATCH_BIT) -#define MSDC_PATCH_BIT1 REG_ADDR(MSDC_PATCH_BIT1) -#define MSDC_PAD_TUNE REG_ADDR(MSDC_PAD_TUNE) -#define MSDC_HW_DBG REG_ADDR(MSDC_HW_DBG) -#define MSDC_VERSION REG_ADDR(MSDC_VERSION) -#define MSDC_ECO_VER REG_ADDR(MSDC_ECO_VER) /* ECO Version */ +#define MSDC_CFG (0x0) +#define MSDC_IOCON (0x04) +#define MSDC_PS (0x08) +#define MSDC_INT (0x0c) +#define MSDC_INTEN (0x10) +#define MSDC_FIFOCS (0x14) +#define MSDC_TXDATA (0x18) +#define MSDC_RXDATA (0x1c) +#define SDC_CFG (0x30) +#define SDC_CMD (0x34) +#define SDC_ARG (0x38) +#define SDC_STS (0x3c) +#define SDC_RESP0 (0x40) +#define SDC_RESP1 (0x44) +#define SDC_RESP2 (0x48) +#define SDC_RESP3 (0x4c) +#define SDC_BLK_NUM (0x50) +#define SDC_CSTS (0x58) +#define SDC_CSTS_EN (0x5c) +#define SDC_DCRC_STS (0x60) +#define EMMC_CFG0 (0x70) +#define EMMC_CFG1 (0x74) +#define EMMC_STS (0x78) +#define EMMC_IOCON (0x7c) +#define SDC_ACMD_RESP (0x80) +#define SDC_ACMD19_TRG (0x84) +#define SDC_ACMD19_STS (0x88) +#define MSDC_DMA_SA (0x90) +#define MSDC_DMA_CA (0x94) +#define MSDC_DMA_CTRL (0x98) +#define MSDC_DMA_CFG (0x9c) +#define MSDC_DBG_SEL (0xa0) +#define MSDC_DBG_OUT (0xa4) +#define MSDC_PATCH_BIT (0xb0) +#define MSDC_PATCH_BIT0 MSDC_PATCH_BIT +#define MSDC_PATCH_BIT1 (0xb4) +#define MSDC_PAD_CTL0 (0xe0) +#define MSDC_PAD_CTL1 (0xe4) +#define MSDC_PAD_CTL2 (0xe8) +#define MSDC_PAD_TUNE (0xec) +#define MSDC_DAT_RDDLY0 (0xf0) +#define MSDC_DAT_RDDLY1 (0xf4) +#define MSDC_HW_DBG (0xf8) +#define MSDC_VERSION (0x100) +#define MSDC_ECO_VER (0x104) /*--------------------------------------------------------------------------*/ /* Register Mask */ diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index c5139a20e10f..e639ceb2ba85 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -146,41 +146,37 @@ static int msdc_rsp[] = { 7, /* RESP_R1b */ }; -#define msdc_dma_on() sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO) +#define msdc_dma_on() sdr_clr_bits(host->base + MSDC_CFG, MSDC_CFG_PIO) static void msdc_reset_hw(struct msdc_host *host) { - void __iomem *base = host->base; - - sdr_set_bits(MSDC_CFG, MSDC_CFG_RST); - while (readl(MSDC_CFG) & MSDC_CFG_RST) + sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_RST); + while (readl(host->base + MSDC_CFG) & MSDC_CFG_RST) cpu_relax(); } #define msdc_clr_int() \ do { \ - volatile u32 val = readl(MSDC_INT); \ - writel(val, MSDC_INT); \ + volatile u32 val = readl(host->base + MSDC_INT); \ + writel(val, host->base + MSDC_INT); \ } while (0) static void msdc_clr_fifo(struct msdc_host *host) { - void __iomem *base = host->base; - - sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); - while (readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR) + sdr_set_bits(host->base + MSDC_FIFOCS, MSDC_FIFOCS_CLR); + while (readl(host->base + MSDC_FIFOCS) & MSDC_FIFOCS_CLR) cpu_relax(); } #define msdc_irq_save(val) \ do { \ - val = readl(MSDC_INTEN); \ - sdr_clr_bits(MSDC_INTEN, val); \ + val = readl(host->base + MSDC_INTEN); \ + sdr_clr_bits(host->base + MSDC_INTEN, val); \ } while (0) #define msdc_irq_restore(val) \ do { \ - sdr_set_bits(MSDC_INTEN, val); \ + sdr_set_bits(host->base + MSDC_INTEN, val); \ } while (0) /* clock source for host: global */ @@ -218,13 +214,13 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */ (void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \ } while (0) -#define sdc_is_busy() (readl(SDC_STS) & SDC_STS_SDCBUSY) -#define sdc_is_cmd_busy() (readl(SDC_STS) & SDC_STS_CMDBUSY) +#define sdc_is_busy() (readl(host->base + SDC_STS) & SDC_STS_SDCBUSY) +#define sdc_is_cmd_busy() (readl(host->base + SDC_STS) & SDC_STS_CMDBUSY) #define sdc_send_cmd(cmd, arg) \ do { \ - writel((arg), SDC_ARG); \ - writel((cmd), SDC_CMD); \ + writel((arg), host->base + SDC_ARG); \ + writel((cmd), host->base + SDC_CMD); \ } while (0) // can modify to read h/w register. @@ -385,7 +381,6 @@ static void msdc_dump_io_resp(struct msdc_host *host, u32 resp) static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks) { - void __iomem *base = host->base; u32 timeout, clk_ns; host->timeout_ns = ns; @@ -397,7 +392,7 @@ static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks) timeout = timeout > 1 ? timeout - 1 : 0; timeout = timeout > 255 ? 255 : timeout; - sdr_set_field(SDC_CFG, SDC_CFG_DTOC, timeout); + sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, timeout); N_MSG(OPS, "Set read data timeout: %dns %dclks -> %d x 65536 cycles", ns, clks, timeout + 1); @@ -407,14 +402,13 @@ static void msdc_tasklet_card(struct work_struct *work) { struct msdc_host *host = (struct msdc_host *)container_of(work, struct msdc_host, card_delaywork.work); - void __iomem *base = host->base; u32 inserted; u32 status = 0; //u32 change = 0; spin_lock(&host->lock); - status = readl(MSDC_PS); + status = readl(host->base + MSDC_PS); if (cd_active_low) inserted = (status & MSDC_PS_CDSTS) ? 0 : 1; else @@ -452,19 +446,18 @@ static u8 clk_src_bit[4] = { static void msdc_select_clksrc(struct msdc_host *host, unsigned char clksrc) { u32 val; - void __iomem *base = host->base; BUG_ON(clksrc > 3); INIT_MSG("set clock source to <%d>", clksrc); - val = readl(MSDC_CLKSRC_REG); - if (readl(MSDC_ECO_VER) >= 4) { + val = readl(host->base + MSDC_CLKSRC_REG); + if (readl(host->base + MSDC_ECO_VER) >= 4) { val &= ~(0x3 << clk_src_bit[host->id]); val |= clksrc << clk_src_bit[host->id]; } else { val &= ~0x3; val |= clksrc; } - writel(val, MSDC_CLKSRC_REG); + writel(val, host->base + MSDC_CLKSRC_REG); host->hclk = hclks[clksrc]; host->hw->clk_src = clksrc; @@ -474,7 +467,6 @@ static void msdc_select_clksrc(struct msdc_host *host, unsigned char clksrc) static void msdc_set_mclk(struct msdc_host *host, int ddr, unsigned int hz) { //struct msdc_hw *hw = host->hw; - void __iomem *base = host->base; u32 mode; u32 flags; u32 div; @@ -515,11 +507,11 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, unsigned int hz) } /* set clock mode and divisor */ - sdr_set_field(MSDC_CFG, MSDC_CFG_CKMOD, mode); - sdr_set_field(MSDC_CFG, MSDC_CFG_CKDIV, div); + sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_CKMOD, mode); + sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_CKDIV, div); /* wait clock stable */ - while (!(readl(MSDC_CFG) & MSDC_CFG_CKSTB)) + while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) cpu_relax(); host->sclk = sclk; @@ -536,7 +528,6 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, unsigned int hz) /* Fix me. when need to abort */ static void msdc_abort_data(struct msdc_host *host) { - void __iomem *base = host->base; struct mmc_command *stop = host->mrq->stop; ERR_MSG("Need to Abort."); @@ -561,7 +552,6 @@ static void msdc_abort_data(struct msdc_host *host) static void msdc_pin_config(struct msdc_host *host, int mode) { struct msdc_hw *hw = host->hw; - void __iomem *base = host->base; int pull = (mode == MSDC_PIN_PULL_UP) ? GPIO_PULL_UP : GPIO_PULL_DOWN; /* Config WP pin */ @@ -574,27 +564,27 @@ static void msdc_pin_config(struct msdc_host *host, int mode) case MSDC_PIN_PULL_UP: //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 1); /* Check & FIXME */ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 0); /* Check & FIXME */ - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 1); - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 1); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 1); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 1); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0); break; case MSDC_PIN_PULL_DOWN: //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 0); /* Check & FIXME */ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 1); /* Check & FIXME */ - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0); - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 1); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 1); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 1); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 1); break; case MSDC_PIN_PULL_NONE: default: //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPU, 0); /* Check & FIXME */ //sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKPD, 0); /* Check & FIXME */ - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0); - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPU, 0); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDPD, 0); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPU, 0); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATPD, 0); break; } @@ -605,7 +595,6 @@ static void msdc_pin_config(struct msdc_host *host, int mode) void msdc_pin_reset(struct msdc_host *host, int mode) { struct msdc_hw *hw = (struct msdc_hw *)host->hw; - void __iomem *base = host->base; int pull = (mode == MSDC_PIN_PULL_UP) ? GPIO_PULL_UP : GPIO_PULL_DOWN; /* Config reset pin */ @@ -614,9 +603,9 @@ void msdc_pin_reset(struct msdc_host *host, int mode) hw->config_gpio_pin(MSDC_RST_PIN, pull); if (mode == MSDC_PIN_PULL_UP) - sdr_clr_bits(EMMC_IOCON, EMMC_IOCON_BOOTRST); + sdr_clr_bits(host->base + EMMC_IOCON, EMMC_IOCON_BOOTRST); else - sdr_set_bits(EMMC_IOCON, EMMC_IOCON_BOOTRST); + sdr_set_bits(host->base + EMMC_IOCON, EMMC_IOCON_BOOTRST); } } @@ -733,7 +722,6 @@ static unsigned int msdc_command_start(struct msdc_host *host, int tune, /* not used */ unsigned long timeout) { - void __iomem *base = host->base; u32 opcode = cmd->opcode; u32 rawcmd; u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | @@ -851,7 +839,7 @@ static unsigned int msdc_command_start(struct msdc_host *host, init_completion(&host->cmd_done); - sdr_set_bits(MSDC_INTEN, wints); + sdr_set_bits(host->base + MSDC_INTEN, wints); sdc_send_cmd(rawcmd, cmd->arg); end: @@ -864,7 +852,6 @@ static unsigned int msdc_command_resp(struct msdc_host *host, unsigned long timeout) __must_hold(&host->lock) { - void __iomem *base = host->base; u32 opcode = cmd->opcode; //u32 rawcmd; u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | @@ -873,7 +860,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host, BUG_ON(in_interrupt()); //init_completion(&host->cmd_done); - //sdr_set_bits(MSDC_INTEN, wints); + //sdr_set_bits(host->base + MSDC_INTEN, wints); spin_unlock(&host->lock); if (!wait_for_completion_timeout(&host->cmd_done, 10 * timeout)) { @@ -883,7 +870,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host, } spin_lock(&host->lock); - sdr_clr_bits(MSDC_INTEN, wints); + sdr_clr_bits(host->base + MSDC_INTEN, wints); host->cmd = NULL; //end: @@ -928,7 +915,8 @@ static unsigned int msdc_command_resp(struct msdc_host *host, /* memory card CRC */ if (host->hw->flags & MSDC_REMOVABLE && cmd->error == -EIO) { - if (readl(SDC_CMD) & 0x1800) { /* check if has data phase */ + /* check if has data phase */ + if (readl(host->base + SDC_CMD) & 0x1800) { msdc_abort_data(host); } else { /* do basic: reset*/ @@ -941,7 +929,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host, // check DAT0 /* if (resp == RESP_R1B) { - while ((readl(MSDC_PS) & 0x10000) != 0x10000); + while ((readl(host->base + MSDC_PS) & 0x10000) != 0x10000); } */ /* CMD12 Error Handle */ @@ -969,9 +957,7 @@ end: // DMA resume / start / stop static void msdc_dma_resume(struct msdc_host *host) { - void __iomem *base = host->base; - - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_RESUME, 1); + sdr_set_field(host->base + MSDC_DMA_CTRL, MSDC_DMA_CTRL_RESUME, 1); N_MSG(DMA, "DMA resume"); } @@ -979,31 +965,29 @@ static void msdc_dma_resume(struct msdc_host *host) static void msdc_dma_start(struct msdc_host *host) { - void __iomem *base = host->base; u32 wints = MSDC_INTEN_XFER_COMPL | MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR; - sdr_set_bits(MSDC_INTEN, wints); + sdr_set_bits(host->base + MSDC_INTEN, wints); //dsb(); /* --- by chhung */ - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_START, 1); + sdr_set_field(host->base + MSDC_DMA_CTRL, MSDC_DMA_CTRL_START, 1); N_MSG(DMA, "DMA start"); } static void msdc_dma_stop(struct msdc_host *host) { - void __iomem *base = host->base; //u32 retries=500; u32 wints = MSDC_INTEN_XFER_COMPL | MSDC_INTEN_DATTMO | MSDC_INTEN_DATCRCERR; - N_MSG(DMA, "DMA status: 0x%.8x", readl(MSDC_DMA_CFG)); - //while (readl(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS); + N_MSG(DMA, "DMA status: 0x%.8x", readl(host->base + MSDC_DMA_CFG)); + //while (readl(host->base + MSDC_DMA_CFG) & MSDC_DMA_CFG_STS); - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_STOP, 1); - while (readl(MSDC_DMA_CFG) & MSDC_DMA_CFG_STS) + sdr_set_field(host->base + MSDC_DMA_CTRL, MSDC_DMA_CTRL_STOP, 1); + while (readl(host->base + MSDC_DMA_CFG) & MSDC_DMA_CFG_STS) ; //dsb(); /* --- by chhung */ - sdr_clr_bits(MSDC_INTEN, wints); /* Not just xfer_comp */ + sdr_clr_bits(host->base + MSDC_INTEN, wints); /* Not just xfer_comp */ N_MSG(DMA, "DMA stop"); } @@ -1021,7 +1005,6 @@ static u8 msdc_dma_calcs(u8 *buf, u32 len) static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, struct scatterlist *sg_cmd, unsigned int sglen) { - void __iomem *base = host->base; struct scatterlist *sg; struct gpd *gpd; struct bd *bd; @@ -1057,16 +1040,16 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, bd[j].chksum = msdc_dma_calcs((u8 *)(&bd[j]), 16); } - sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, 1); - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, + sdr_set_field(host->base + MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, 1); + sdr_set_field(host->base + MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, MSDC_BRUST_64B); - sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1); + sdr_set_field(host->base + MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1); - writel(PHYSADDR((u32)dma->gpd_addr), MSDC_DMA_SA); + writel(PHYSADDR((u32)dma->gpd_addr), host->base + MSDC_DMA_SA); - N_MSG(DMA, "DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL)); - N_MSG(DMA, "DMA_CFG = 0x%x", readl(MSDC_DMA_CFG)); - N_MSG(DMA, "DMA_SA = 0x%x", readl(MSDC_DMA_SA)); + N_MSG(DMA, "DMA_CTRL = 0x%x", readl(host->base + MSDC_DMA_CTRL)); + N_MSG(DMA, "DMA_CFG = 0x%x", readl(host->base + MSDC_DMA_CFG)); + N_MSG(DMA, "DMA_SA = 0x%x", readl(host->base + MSDC_DMA_SA)); } static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) @@ -1075,7 +1058,6 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) struct msdc_host *host = mmc_priv(mmc); struct mmc_command *cmd; struct mmc_data *data; - void __iomem *base = host->base; //u32 intsts = 0; int read = 1, send_type = 0; @@ -1118,7 +1100,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) } } - writel(data->blocks, SDC_BLK_NUM); + writel(data->blocks, host->base + SDC_BLK_NUM); //msdc_clr_fifo(host); /* no need */ msdc_dma_on(); /* enable DMA mode first!! */ @@ -1146,10 +1128,14 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) spin_unlock(&host->lock); if (!wait_for_completion_timeout(&host->xfer_done, DAT_TIMEOUT)) { ERR_MSG("XXX CMD<%d> wait xfer_done<%d> timeout!!", cmd->opcode, data->blocks * data->blksz); - ERR_MSG(" DMA_SA = 0x%x", readl(MSDC_DMA_SA)); - ERR_MSG(" DMA_CA = 0x%x", readl(MSDC_DMA_CA)); - ERR_MSG(" DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL)); - ERR_MSG(" DMA_CFG = 0x%x", readl(MSDC_DMA_CFG)); + ERR_MSG(" DMA_SA = 0x%x", + readl(host->base + MSDC_DMA_SA)); + ERR_MSG(" DMA_CA = 0x%x", + readl(host->base + MSDC_DMA_CA)); + ERR_MSG(" DMA_CTRL = 0x%x", + readl(host->base + MSDC_DMA_CTRL)); + ERR_MSG(" DMA_CFG = 0x%x", + readl(host->base + MSDC_DMA_CFG)); data->error = -ETIMEDOUT; msdc_reset_hw(host); @@ -1247,7 +1233,6 @@ static int msdc_app_cmd(struct mmc_host *mmc, struct msdc_host *host) static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd) { int result = -1; - void __iomem *base = host->base; u32 rsmpl, cur_rsmpl, orig_rsmpl; u32 rrdly, cur_rrdly = 0xffffffff, orig_rrdly; u32 skip = 1; @@ -1258,8 +1243,9 @@ static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd) ==========================*/ // save the previous tune result - sdr_get_field(MSDC_IOCON, MSDC_IOCON_RSPL, &orig_rsmpl); - sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, &orig_rrdly); + sdr_get_field(host->base + MSDC_IOCON, MSDC_IOCON_RSPL, &orig_rsmpl); + sdr_get_field(host->base + MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, + &orig_rrdly); rrdly = 0; do { @@ -1270,7 +1256,8 @@ static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd) skip = 0; continue; } - sdr_set_field(MSDC_IOCON, MSDC_IOCON_RSPL, cur_rsmpl); + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_RSPL, + cur_rsmpl); if (host->app_cmd) { result = msdc_app_cmd(host->mmc, host); @@ -1292,14 +1279,15 @@ static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd) } /* should be EIO */ - if (readl(SDC_CMD) & 0x1800) { /* check if has data phase */ + /* check if has data phase */ + if (readl(host->base + SDC_CMD) & 0x1800) msdc_abort_data(host); - } } /* Lv2: PAD_CMD_RESP_RXDLY[26:22] */ cur_rrdly = (orig_rrdly + rrdly + 1) % 32; - sdr_set_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, cur_rrdly); + sdr_set_field(host->base + MSDC_PAD_TUNE, + MSDC_PAD_TUNE_CMDRRDLY, cur_rrdly); } while (++rrdly < 32); return result; @@ -1309,7 +1297,6 @@ static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd) static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) { struct msdc_host *host = mmc_priv(mmc); - void __iomem *base = host->base; u32 ddr = 0; u32 dcrc = 0; u32 rxdly, cur_rxdly0, cur_rxdly1; @@ -1321,10 +1308,10 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) int result = -1; u32 skip = 1; - sdr_get_field(MSDC_IOCON, MSDC_IOCON_DSPL, &orig_dsmpl); + sdr_get_field(host->base + MSDC_IOCON, MSDC_IOCON_DSPL, &orig_dsmpl); /* Tune Method 2. */ - sdr_set_field(MSDC_IOCON, MSDC_IOCON_DDLSEL, 1); + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DDLSEL, 1); rxdly = 0; do { @@ -1334,7 +1321,8 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) skip = 0; continue; } - sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, cur_dsmpl); + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DSPL, + cur_dsmpl); if (host->app_cmd) { result = msdc_app_cmd(host->mmc, host); @@ -1345,14 +1333,15 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) } result = msdc_do_request(mmc, mrq); - sdr_get_field(SDC_DCRC_STS, + sdr_get_field(host->base + SDC_DCRC_STS, SDC_DCRC_STS_POS | SDC_DCRC_STS_NEG, &dcrc); /* RO */ if (!ddr) dcrc &= ~SDC_DCRC_STS_NEG; ERR_MSG("TUNE_BREAD<%s> dcrc<0x%x> DATRDDLY0/1<0x%x><0x%x> dsmpl<0x%x>", (result == 0 && dcrc == 0) ? "PASS" : "FAIL", dcrc, - readl(MSDC_DAT_RDDLY0), readl(MSDC_DAT_RDDLY1), cur_dsmpl); + readl(host->base + MSDC_DAT_RDDLY0), + readl(host->base + MSDC_DAT_RDDLY1), cur_dsmpl); /* Fix me: result is 0, but dcrc is still exist */ if (result == 0 && dcrc == 0) { @@ -1368,11 +1357,11 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) } } - cur_rxdly0 = readl(MSDC_DAT_RDDLY0); - cur_rxdly1 = readl(MSDC_DAT_RDDLY1); + cur_rxdly0 = readl(host->base + MSDC_DAT_RDDLY0); + cur_rxdly1 = readl(host->base + MSDC_DAT_RDDLY1); /* E1 ECO. YD: Reverse */ - if (readl(MSDC_ECO_VER) >= 4) { + if (readl(host->base + MSDC_ECO_VER) >= 4) { orig_dat0 = (cur_rxdly0 >> 24) & 0x1F; orig_dat1 = (cur_rxdly0 >> 16) & 0x1F; orig_dat2 = (cur_rxdly0 >> 8) & 0x1F; @@ -1411,8 +1400,8 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct mmc_request *mrq) cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0); cur_rxdly1 = (cur_dat4 << 24) | (cur_dat5 << 16) | (cur_dat6 << 8) | (cur_dat7 << 0); - writel(cur_rxdly0, MSDC_DAT_RDDLY0); - writel(cur_rxdly1, MSDC_DAT_RDDLY1); + writel(cur_rxdly0, host->base + MSDC_DAT_RDDLY0); + writel(cur_rxdly1, host->base + MSDC_DAT_RDDLY1); } while (++rxdly < 32); @@ -1423,7 +1412,6 @@ done: static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq) { struct msdc_host *host = mmc_priv(mmc); - void __iomem *base = host->base; u32 wrrdly, cur_wrrdly = 0xffffffff, orig_wrrdly; u32 dsmpl, cur_dsmpl, orig_dsmpl; @@ -1435,15 +1423,16 @@ static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq) // MSDC_IOCON_DDR50CKD need to check. [Fix me] - sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_DATWRDLY, &orig_wrrdly); - sdr_get_field(MSDC_IOCON, MSDC_IOCON_DSPL, &orig_dsmpl); + sdr_get_field(host->base + MSDC_PAD_TUNE, MSDC_PAD_TUNE_DATWRDLY, + &orig_wrrdly); + sdr_get_field(host->base + MSDC_IOCON, MSDC_IOCON_DSPL, &orig_dsmpl); /* Tune Method 2. just DAT0 */ - sdr_set_field(MSDC_IOCON, MSDC_IOCON_DDLSEL, 1); - cur_rxdly0 = readl(MSDC_DAT_RDDLY0); + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DDLSEL, 1); + cur_rxdly0 = readl(host->base + MSDC_DAT_RDDLY0); /* E1 ECO. YD: Reverse */ - if (readl(MSDC_ECO_VER) >= 4) { + if (readl(host->base + MSDC_ECO_VER) >= 4) { orig_dat0 = (cur_rxdly0 >> 24) & 0x1F; orig_dat1 = (cur_rxdly0 >> 16) & 0x1F; orig_dat2 = (cur_rxdly0 >> 8) & 0x1F; @@ -1465,7 +1454,8 @@ static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq) skip = 0; continue; } - sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, cur_dsmpl); + sdr_set_field(host->base + MSDC_IOCON, + MSDC_IOCON_DSPL, cur_dsmpl); if (host->app_cmd) { result = msdc_app_cmd(host->mmc, host); @@ -1492,7 +1482,8 @@ static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq) } } cur_wrrdly = (orig_wrrdly + wrrdly + 1) % 32; - sdr_set_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_DATWRDLY, cur_wrrdly); + sdr_set_field(host->base + MSDC_PAD_TUNE, + MSDC_PAD_TUNE_DATWRDLY, cur_wrrdly); } while (++wrrdly < 32); cur_dat0 = (orig_dat0 + rxdly) % 32; /* only adjust bit-1 for crc */ @@ -1501,7 +1492,7 @@ static int msdc_tune_bwrite(struct mmc_host *mmc, struct mmc_request *mrq) cur_dat3 = orig_dat3; cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 8) | (cur_dat3 << 0); - writel(cur_rxdly0, MSDC_DAT_RDDLY0); + writel(cur_rxdly0, host->base + MSDC_DAT_RDDLY0); } while (++rxdly < 32); done: @@ -1651,8 +1642,7 @@ static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq) /* called by ops.set_ios */ static void msdc_set_buswidth(struct msdc_host *host, u32 width) { - void __iomem *base = host->base; - u32 val = readl(SDC_CFG); + u32 val = readl(host->base + SDC_CFG); val &= ~SDC_CFG_BUSWIDTH; @@ -1670,7 +1660,7 @@ static void msdc_set_buswidth(struct msdc_host *host, u32 width) break; } - writel(val, SDC_CFG); + writel(val, host->base + SDC_CFG); N_MSG(CFG, "Bus Width = %d", width); } @@ -1679,7 +1669,6 @@ static void msdc_set_buswidth(struct msdc_host *host, u32 width) static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { struct msdc_host *host = mmc_priv(mmc); - void __iomem *base = host->base; u32 ddr = 0; #ifdef MT6575_SD_DEBUG @@ -1725,18 +1714,23 @@ static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) if (ios->clock > 25000000) { //if (!(host->hw->flags & MSDC_REMOVABLE)) { INIT_MSG("SD data latch edge<%d>", MSDC_SMPL_FALLING); - sdr_set_field(MSDC_IOCON, MSDC_IOCON_RSPL, + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_RSPL, MSDC_SMPL_FALLING); - sdr_set_field(MSDC_IOCON, MSDC_IOCON_DSPL, + sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DSPL, MSDC_SMPL_FALLING); //} /* for tuning debug */ } else { /* default value */ - writel(0x00000000, MSDC_IOCON); - // writel(0x00000000, MSDC_DAT_RDDLY0); - writel(0x10101010, MSDC_DAT_RDDLY0); // for MT7620 E2 and afterward - writel(0x00000000, MSDC_DAT_RDDLY1); - // writel(0x00000000, MSDC_PAD_TUNE); - writel(0x84101010, MSDC_PAD_TUNE); // for MT7620 E2 and afterward + writel(0x00000000, host->base + MSDC_IOCON); + // writel(0x00000000, host->base + MSDC_DAT_RDDLY0); + + // for MT7620 E2 and afterward + writel(0x10101010, host->base + MSDC_DAT_RDDLY0); + + writel(0x00000000, host->base + MSDC_DAT_RDDLY1); + // writel(0x00000000, host->base + MSDC_PAD_TUNE); + + // for MT7620 E2 and afterward + writel(0x84101010, host->base + MSDC_PAD_TUNE); } msdc_set_mclk(host, ddr, ios->clock); } @@ -1746,13 +1740,12 @@ static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) static int msdc_ops_get_ro(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); - void __iomem *base = host->base; unsigned long flags; int ro = 0; if (host->hw->flags & MSDC_WP_PIN_EN) { /* set for card */ spin_lock_irqsave(&host->lock, flags); - ro = (readl(MSDC_PS) >> 31); + ro = (readl(host->base + MSDC_PS) >> 31); spin_unlock_irqrestore(&host->lock, flags); } return ro; @@ -1762,7 +1755,6 @@ static int msdc_ops_get_ro(struct mmc_host *mmc) static int msdc_ops_get_cd(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); - void __iomem *base = host->base; unsigned long flags; int present = 1; @@ -1786,10 +1778,11 @@ static int msdc_ops_get_cd(struct mmc_host *mmc) present = host->card_inserted; /* why not read from H/W: Fix me*/ #else // CD + present = readl(host->base + MSDC_PS) & MSDC_PS_CDSTS; if (cd_active_low) - present = (readl(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1; + present = present ? 0 : 1; else - present = (readl(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0; + present = present ? 1 : 0; host->card_inserted = present; #endif spin_unlock_irqrestore(&host->lock, flags); @@ -1816,17 +1809,16 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) struct msdc_host *host = (struct msdc_host *)dev_id; struct mmc_data *data = host->data; struct mmc_command *cmd = host->cmd; - void __iomem *base = host->base; u32 cmdsts = MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | MSDC_INT_CMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO | MSDC_INT_ACMDRDY | MSDC_INT_ACMD19_DONE; u32 datsts = MSDC_INT_DATCRCERR | MSDC_INT_DATTMO; - u32 intsts = readl(MSDC_INT); - u32 inten = readl(MSDC_INTEN); inten &= intsts; + u32 intsts = readl(host->base + MSDC_INT); + u32 inten = readl(host->base + MSDC_INTEN); inten &= intsts; - writel(intsts, MSDC_INT); /* clear interrupts */ + writel(intsts, host->base + MSDC_INT); /* clear interrupts */ /* MSG will cause fatal error */ /* card change interrupt */ @@ -1861,7 +1853,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) IRQ_MSG("XXX CMD<%d> MSDC_INT_DATTMO", host->mrq->cmd->opcode); data->error = -ETIMEDOUT; } else if (intsts & MSDC_INT_DATCRCERR) { - IRQ_MSG("XXX CMD<%d> MSDC_INT_DATCRCERR, SDC_DCRC_STS<0x%x>", host->mrq->cmd->opcode, readl(SDC_DCRC_STS)); + IRQ_MSG("XXX CMD<%d> MSDC_INT_DATCRCERR, SDC_DCRC_STS<0x%x>", host->mrq->cmd->opcode, readl(host->base + SDC_DCRC_STS)); data->error = -EIO; } @@ -1880,14 +1872,16 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) case RESP_NONE: break; case RESP_R2: - *rsp++ = readl(SDC_RESP3); *rsp++ = readl(SDC_RESP2); - *rsp++ = readl(SDC_RESP1); *rsp++ = readl(SDC_RESP0); + *rsp++ = readl(host->base + SDC_RESP3); + *rsp++ = readl(host->base + SDC_RESP2); + *rsp++ = readl(host->base + SDC_RESP1); + *rsp++ = readl(host->base + SDC_RESP0); break; default: /* Response types 1, 3, 4, 5, 6, 7(1b) */ if ((intsts & MSDC_INT_ACMDRDY) || (intsts & MSDC_INT_ACMD19_DONE)) - *rsp = readl(SDC_ACMD_RESP); + *rsp = readl(host->base + SDC_ACMD_RESP); else - *rsp = readl(SDC_RESP0); + *rsp = readl(host->base + SDC_RESP0); break; } } else if ((intsts & MSDC_INT_RSPCRCERR) || (intsts & MSDC_INT_ACMDCRCERR)) { @@ -1911,7 +1905,8 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) /* mmc irq interrupts */ if (intsts & MSDC_INT_MMCIRQ) - printk(KERN_INFO "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", host->id, readl(SDC_CSTS)); + printk(KERN_INFO "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", + host->id, readl(host->base + SDC_CSTS)); #ifdef MT6575_SD_DEBUG { @@ -1951,7 +1946,6 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) static void msdc_enable_cd_irq(struct msdc_host *host, int enable) { struct msdc_hw *hw = host->hw; - void __iomem *base = host->base; /* for sdio, not set */ if ((hw->flags & MSDC_CD_PIN_EN) == 0) { @@ -1960,9 +1954,9 @@ static void msdc_enable_cd_irq(struct msdc_host *host, int enable) if (hw->config_gpio_pin) hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN); */ - sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN); - sdr_clr_bits(MSDC_INTEN, MSDC_INTEN_CDSC); - sdr_clr_bits(SDC_CFG, SDC_CFG_INSWKUP); + sdr_clr_bits(host->base + MSDC_PS, MSDC_PS_CDEN); + sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_CDSC); + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_INSWKUP); return; } @@ -1978,17 +1972,20 @@ static void msdc_enable_cd_irq(struct msdc_host *host, int enable) if (hw->config_gpio_pin) /* NULL */ hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_UP); - sdr_set_field(MSDC_PS, MSDC_PS_CDDEBOUNCE, DEFAULT_DEBOUNCE); - sdr_set_bits(MSDC_PS, MSDC_PS_CDEN); - sdr_set_bits(MSDC_INTEN, MSDC_INTEN_CDSC); - sdr_set_bits(SDC_CFG, SDC_CFG_INSWKUP); /* not in document! Fix me */ + sdr_set_field(host->base + MSDC_PS, MSDC_PS_CDDEBOUNCE, + DEFAULT_DEBOUNCE); + sdr_set_bits(host->base + MSDC_PS, MSDC_PS_CDEN); + sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_CDSC); + + /* not in document! Fix me */ + sdr_set_bits(host->base + SDC_CFG, SDC_CFG_INSWKUP); } else { if (hw->config_gpio_pin) /* NULL */ hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN); - sdr_clr_bits(SDC_CFG, SDC_CFG_INSWKUP); - sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN); - sdr_clr_bits(MSDC_INTEN, MSDC_INTEN_CDSC); + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_INSWKUP); + sdr_clr_bits(host->base + MSDC_PS, MSDC_PS_CDEN); + sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_CDSC); /* Here decreases a reference count to core power since card * detection circuit is shutdown. @@ -2000,7 +1997,6 @@ static void msdc_enable_cd_irq(struct msdc_host *host, int enable) /* called by msdc_drv_probe */ static void msdc_init_hw(struct msdc_host *host) { - void __iomem *base = host->base; /* Power on */ #if 0 /* --- by chhung */ @@ -2011,41 +2007,51 @@ static void msdc_init_hw(struct msdc_host *host) msdc_vdd_on(host); #endif /* end of --- */ /* Configure to MMC/SD mode */ - sdr_set_field(MSDC_CFG, MSDC_CFG_MODE, MSDC_SDMMC); + sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_MODE, MSDC_SDMMC); /* Reset */ msdc_reset_hw(host); msdc_clr_fifo(host); /* Disable card detection */ - sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN); + sdr_clr_bits(host->base + MSDC_PS, MSDC_PS_CDEN); /* Disable and clear all interrupts */ - sdr_clr_bits(MSDC_INTEN, readl(MSDC_INTEN)); - writel(readl(MSDC_INT), MSDC_INT); + sdr_clr_bits(host->base + MSDC_INTEN, readl(host->base + MSDC_INTEN)); + writel(readl(host->base + MSDC_INT), host->base + MSDC_INT); #if 1 /* reset tuning parameter */ - writel(0x00090000, MSDC_PAD_CTL0); - writel(0x000A0000, MSDC_PAD_CTL1); - writel(0x000A0000, MSDC_PAD_CTL2); - // writel( 0x00000000, MSDC_PAD_TUNE); - writel(0x84101010, MSDC_PAD_TUNE); // for MT7620 E2 and afterward - // writel(0x00000000, MSDC_DAT_RDDLY0); - writel(0x10101010, MSDC_DAT_RDDLY0); // for MT7620 E2 and afterward - writel(0x00000000, MSDC_DAT_RDDLY1); - writel(0x00000000, MSDC_IOCON); + writel(0x00090000, host->base + MSDC_PAD_CTL0); + writel(0x000A0000, host->base + MSDC_PAD_CTL1); + writel(0x000A0000, host->base + MSDC_PAD_CTL2); + // writel( 0x00000000, host->base + MSDC_PAD_TUNE); + + // for MT7620 E2 and afterward + writel(0x84101010, host->base + MSDC_PAD_TUNE); + + // writel(0x00000000, host->base + MSDC_DAT_RDDLY0); + + // for MT7620 E2 and afterward + writel(0x10101010, host->base + MSDC_DAT_RDDLY0); + + writel(0x00000000, host->base + MSDC_DAT_RDDLY1); + writel(0x00000000, host->base + MSDC_IOCON); #if 0 // use MT7620 default value: 0x403c004f - writel(0x003C000F, MSDC_PATCH_BIT0); /* bit0 modified: Rx Data Clock Source: 1 -> 2.0*/ + /* bit0 modified: Rx Data Clock Source: 1 -> 2.0*/ + writel(0x003C000F, host->base + MSDC_PATCH_BIT0); #endif - if (readl(MSDC_ECO_VER) >= 4) { + if (readl(host->base + MSDC_ECO_VER) >= 4) { if (host->id == 1) { - sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_WRDAT_CRCS, 1); - sdr_set_field(MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_CMD_RSP, 1); + sdr_set_field(host->base + MSDC_PATCH_BIT1, + MSDC_PATCH_BIT1_WRDAT_CRCS, 1); + sdr_set_field(host->base + MSDC_PATCH_BIT1, + MSDC_PATCH_BIT1_CMD_RSP, 1); /* internal clock: latch read data */ - sdr_set_bits(MSDC_PATCH_BIT0, MSDC_PATCH_BIT_CKGEN_CK); + sdr_set_bits(host->base + MSDC_PATCH_BIT0, + MSDC_PATCH_BIT_CKGEN_CK); } } #endif @@ -2054,40 +2060,40 @@ static void msdc_init_hw(struct msdc_host *host) pre-loader,uboot,kernel drivers. and SDC_CFG.SDIO_INT_DET_EN will be only set when kernel driver wants to use SDIO bus interrupt */ /* Configure to enable SDIO mode. it's must otherwise sdio cmd5 failed */ - sdr_set_bits(SDC_CFG, SDC_CFG_SDIO); + sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO); /* disable detect SDIO device interupt function */ - sdr_clr_bits(SDC_CFG, SDC_CFG_SDIOIDE); + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE); /* eneable SMT for glitch filter */ - sdr_set_bits(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKSMT); - sdr_set_bits(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDSMT); - sdr_set_bits(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATSMT); + sdr_set_bits(host->base + MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKSMT); + sdr_set_bits(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDSMT); + sdr_set_bits(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATSMT); #if 1 /* set clk, cmd, dat pad driving */ - sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, 4); - sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, 4); - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, 4); - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, 4); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, 4); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, 4); + sdr_set_field(host->base + MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, 4); + sdr_set_field(host->base + MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, 4); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, 4); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, 4); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, 4); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, 4); #else - sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, 0); - sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, 0); - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, 0); - sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, 0); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, 0); - sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, 0); + sdr_set_field(host->base + MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, 0); + sdr_set_field(host->base + MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, 0); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, 0); + sdr_set_field(host->base + MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, 0); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, 0); + sdr_set_field(host->base + MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, 0); #endif /* set sampling edge */ /* write crc timeout detection */ - sdr_set_field(MSDC_PATCH_BIT0, 1 << 30, 1); + sdr_set_field(host->base + MSDC_PATCH_BIT0, 1 << 30, 1); /* Configure to default data timeout */ - sdr_set_field(SDC_CFG, SDC_CFG_DTOC, DEFAULT_DTOC); + sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, DEFAULT_DTOC); msdc_set_buswidth(host, MMC_BUS_WIDTH_1); @@ -2097,11 +2103,9 @@ static void msdc_init_hw(struct msdc_host *host) /* called by msdc_drv_remove */ static void msdc_deinit_hw(struct msdc_host *host) { - void __iomem *base = host->base; - /* Disable and clear all interrupts */ - sdr_clr_bits(MSDC_INTEN, readl(MSDC_INTEN)); - writel(readl(MSDC_INT), MSDC_INT); + sdr_clr_bits(host->base + MSDC_INTEN, readl(host->base + MSDC_INTEN)); + writel(readl(host->base + MSDC_INT), host->base + MSDC_INT); /* Disable card detection */ msdc_enable_cd_irq(host, 0); From a76187ffa593ec04066d1852411635aef8bb6727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:00 +0200 Subject: [PATCH 120/903] staging: mt7621-mmc: Remove unused define RALINK_MSDC_BASE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The define RALINK_MSDC_BASE is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index e639ceb2ba85..101ceca2ee4c 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -53,10 +53,8 @@ //#define IRQ_SDC 14 //MT7620 /*FIXME*/ #ifdef CONFIG_SOC_MT7621 #define RALINK_SYSCTL_BASE 0xbe000000 -#define RALINK_MSDC_BASE 0xbe130000 #else #define RALINK_SYSCTL_BASE 0xb0000000 -#define RALINK_MSDC_BASE 0xb0130000 #endif #define IRQ_SDC 22 /*FIXME*/ From ed940e75474ecaf13e9ab787023e90d292d07727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:01 +0200 Subject: [PATCH 121/903] staging: mt7621-mmc: Remove unused define IRQ_SDC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The define IRQ_SDC is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 101ceca2ee4c..31ee9c533f35 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -50,13 +50,11 @@ #include "dbg.h" #include "mt6575_sd.h" -//#define IRQ_SDC 14 //MT7620 /*FIXME*/ #ifdef CONFIG_SOC_MT7621 #define RALINK_SYSCTL_BASE 0xbe000000 #else #define RALINK_SYSCTL_BASE 0xb0000000 #endif -#define IRQ_SDC 22 /*FIXME*/ #define DRV_NAME "mtk-sd" From 4bd8897a7dd4801772190eba9a49fa137937262a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:02 +0200 Subject: [PATCH 122/903] staging: mt7621-mmc: Remove unused enum msdc_mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The enum msdc_mode is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/dbg.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/mt7621-mmc/dbg.h b/drivers/staging/mt7621-mmc/dbg.h index 5a25a69b00c9..2f2c56b73987 100644 --- a/drivers/staging/mt7621-mmc/dbg.h +++ b/drivers/staging/mt7621-mmc/dbg.h @@ -73,12 +73,6 @@ enum msdc_dbg { SD_TOOL_SDIO_PROFILE = 3, }; -enum msdc_mode { - MODE_PIO = 0, - MODE_DMA = 1, - MODE_SIZE_DEP = 2, -}; - /* Debug message event */ #define DBG_EVT_NONE (0) /* No event */ #define DBG_EVT_DMA (1 << 0) /* DMA related event */ From 2de186940b8716f514a91a8df1788ce6e8c9d036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:03 +0200 Subject: [PATCH 123/903] staging: mt7621-mmc: Remove unused define MAX_PHY_SGMTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The define MAX_PHY_SGMTS is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 31ee9c533f35..45d9b62f4a58 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -89,7 +89,6 @@ #define MAX_BD_NUM (1024) #define MAX_HW_SGMTS (MAX_BD_NUM) -#define MAX_PHY_SGMTS (MAX_BD_NUM) #define MAX_SGMT_SZ (MAX_DMA_CNT) #define MAX_REQ_SZ (MAX_SGMT_SZ * 8) From 008f3853de82a8674bde444c593bab7a9436ad82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:04 +0200 Subject: [PATCH 124/903] staging: mt7621-mmc: Remove unused macro is_card_present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro is_card_present is unused and also a duplicate of a macro in mmc, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 45d9b62f4a58..cfe7517f8bdf 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -218,10 +218,6 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */ writel((cmd), host->base + SDC_CMD); \ } while (0) -// can modify to read h/w register. -//#define is_card_present(h) ((readl(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1); -#define is_card_present(h) (((struct msdc_host *)(h))->card_inserted) - /* +++ by chhung */ #ifndef __ASSEMBLY__ #define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff) From 38ee87eaadf593de9e55ec1977c90f24dc39454e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:05 +0200 Subject: [PATCH 125/903] staging: mt7621-mmc: Remove unused argument from msdc_do_command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The argument tune of msdc_do_command is never used, so remove it. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index cfe7517f8bdf..93f14c9694b9 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -710,7 +710,6 @@ static void msdc_pm(pm_message_t state, void *data) /*--------------------------------------------------------------------------*/ static unsigned int msdc_command_start(struct msdc_host *host, struct mmc_command *cmd, - int tune, /* not used */ unsigned long timeout) { u32 opcode = cmd->opcode; @@ -932,7 +931,7 @@ static unsigned int msdc_do_command(struct msdc_host *host, int tune, unsigned long timeout) { - if (msdc_command_start(host, cmd, tune, timeout)) + if (msdc_command_start(host, cmd, timeout)) goto end; if (msdc_command_resp(host, cmd, tune, timeout)) @@ -1098,7 +1097,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) init_completion(&host->xfer_done); /* start the command first*/ - if (msdc_command_start(host, cmd, 1, CMD_TIMEOUT) != 0) + if (msdc_command_start(host, cmd, CMD_TIMEOUT) != 0) goto done; data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg, From 256e086636241c4c98b45ad5c173aef79a70e57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:06 +0200 Subject: [PATCH 126/903] staging: mt7621-mmc: Factor out from msdc_command_start() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently msdc_command_start does multiple things and is hard to read, so factor out the finding of the response type. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 40 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 93f14c9694b9..f7df3221a302 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -705,25 +705,11 @@ static void msdc_pm(pm_message_t state, void *data) } #endif -/*--------------------------------------------------------------------------*/ -/* mmc_host_ops members */ -/*--------------------------------------------------------------------------*/ -static unsigned int msdc_command_start(struct msdc_host *host, - struct mmc_command *cmd, - unsigned long timeout) +static inline u32 msdc_cmd_find_resp(struct mmc_command *cmd) { u32 opcode = cmd->opcode; - u32 rawcmd; - u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | - MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO | - MSDC_INT_ACMD19_DONE; - u32 resp; - unsigned long tmo; - /* Protocol layer does not provide response type, but our hardware needs - * to know exact type, not just size! - */ if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND) { resp = RESP_R3; } else if (opcode == MMC_SET_RELATIVE_ADDR) { @@ -759,6 +745,30 @@ static unsigned int msdc_command_start(struct msdc_host *host, } } + return resp; +} + +/*--------------------------------------------------------------------------*/ +/* mmc_host_ops members */ +/*--------------------------------------------------------------------------*/ +static unsigned int msdc_command_start(struct msdc_host *host, + struct mmc_command *cmd, + unsigned long timeout) +{ + u32 opcode = cmd->opcode; + u32 rawcmd; + u32 wints = MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO | + MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO | + MSDC_INT_ACMD19_DONE; + + u32 resp; + unsigned long tmo; + + /* Protocol layer does not provide response type, but our hardware needs + * to know exact type, not just size! + */ + resp = msdc_cmd_find_resp(cmd); + cmd->error = 0; /* rawcmd : * vol_swt << 30 | auto_cmd << 28 | blklen << 16 | go_irq << 15 | From c3f28802a11840cb3e0a0e572b5510fe46e39eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:07 +0200 Subject: [PATCH 127/903] staging: mt7621-mmc: Find response of MMC_SEND_OP_COND by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The response type of the MMC_SEND_OP_COND command is correctly determined using the mmc_resp_type macro, because the only use of that opcode, mmc_send_op_cond, correctly places MMC_RSP_R3 in cmd.flags. So there is no need to treat that opcode separately. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index f7df3221a302..69123cfd7309 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -710,7 +710,7 @@ static inline u32 msdc_cmd_find_resp(struct mmc_command *cmd) u32 opcode = cmd->opcode; u32 resp; - if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND) { + if (opcode == SD_APP_OP_COND) { resp = RESP_R3; } else if (opcode == MMC_SET_RELATIVE_ADDR) { resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1; From 370713270ea40ea46398c73a93427785bc41c771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Sat, 16 Jun 2018 16:15:08 +0200 Subject: [PATCH 128/903] staging: mt7621-mmc: Find response of SD_APP_OP_COND by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The response type of the SD_APP_OP_COND command is correctly determined using the mmc_resp_type macro, because the only use of that opcode, mmc_send_app_op_cond, correctly places MMC_RSP_R3 in cmd.flags. So there is no need to treat that opcode separately. Signed-off-by: Christian Lütke-Stetzkamp Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 69123cfd7309..04d23cc7cd4a 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -710,9 +710,7 @@ static inline u32 msdc_cmd_find_resp(struct mmc_command *cmd) u32 opcode = cmd->opcode; u32 resp; - if (opcode == SD_APP_OP_COND) { - resp = RESP_R3; - } else if (opcode == MMC_SET_RELATIVE_ADDR) { + if (opcode == MMC_SET_RELATIVE_ADDR) { resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1; } else if (opcode == MMC_FAST_IO) { resp = RESP_R4; From d0233204fbc10f003d1ef077f57341c2feca4002 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 16 Jun 2018 19:17:50 -0700 Subject: [PATCH 129/903] staging: mt7621-dts: Fix remaining pcie warnings This currently fixes the remaining dtb warnings: Node /pcie@1e140000/pcie0 has a reg or ranges property, but no unit name Node /pcie@1e140000/pcie1 has a reg or ranges property, but no unit name Node /pcie@1e140000/pcie2 has a reg or ranges property, but no unit name Node /pcie@1e140000/pcie0 node name is not "pci" or "pcie" Node /pcie@1e140000/pcie0 missing ranges for PCI bridge (or not a bridge) Node /pcie@1e140000/pcie0 missing bus-range for PCI bridge Node /pcie@1e140000/pcie1 node name is not "pci" or "pcie" Node /pcie@1e140000/pcie1 missing ranges for PCI bridge (or not a bridge) Node /pcie@1e140000/pcie1 missing bus-range for PCI bridge Node /pcie@1e140000/pcie2 node name is not "pci" or "pcie" Node /pcie@1e140000/pcie2 missing ranges for PCI bridge (or not a bridge) Node /pcie@1e140000/pcie2 missing bus-range for PCI bridge Warning (unit_address_format): Failed prerequisite 'pci_bridge' Warning (pci_device_reg): Failed prerequisite 'pci_bridge' Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' device_type was removed since according to documentation, it's deprecated for pci(e) devices. Signed-off-by: Rosen Penev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/gbpc1.dts | 2 ++ drivers/staging/mt7621-dts/mt7621.dtsi | 21 +++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index 570d59e847bf..425ec9539d31 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts @@ -111,6 +111,8 @@ }; &pcie { + pinctrl-names = "default"; + pinctrl-0 = <&pcie_pins>; status = "okay"; }; diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 4a58e94c2060..4bd311e94518 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -447,31 +447,28 @@ clocks = <&clkctrl 24 &clkctrl 25 &clkctrl 26>; clock-names = "pcie0", "pcie1", "pcie2"; - pcie0 { + pcie@0,0 { reg = <0x0000 0 0 0 0>; - #address-cells = <3>; #size-cells = <2>; - - device_type = "pci"; + ranges; + bus-range = <0x00 0xff>; }; - pcie1 { + pcie@1,0 { reg = <0x0800 0 0 0 0>; - #address-cells = <3>; #size-cells = <2>; - - device_type = "pci"; + ranges; + bus-range = <0x00 0xff>; }; - pcie2 { + pcie@2,0 { reg = <0x1000 0 0 0 0>; - #address-cells = <3>; #size-cells = <2>; - - device_type = "pci"; + ranges; + bus-range = <0x00 0xff>; }; }; }; From 85e1d42663a0c163002961d2685be952067b0dc2 Mon Sep 17 00:00:00 2001 From: Kamal Heib Date: Tue, 19 Jun 2018 20:04:08 +0300 Subject: [PATCH 130/903] staging: mt7621-eth: Fix memory leak in mtk_add_mac() error path Fix memory leak in error path of mtk_add_mac() by make sure to free the allocated netdev. Fixes: e3cbf478f846 ('staging: mt7621-eth: add the drivers core files') Signed-off-by: Kamal Heib Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-eth/mtk_eth_soc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c index 2c7a2e666bfb..381d9d270bf5 100644 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c +++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c @@ -2012,8 +2012,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->hw_stats = devm_kzalloc(eth->dev, sizeof(*mac->hw_stats), GFP_KERNEL); - if (!mac->hw_stats) - return -ENOMEM; + if (!mac->hw_stats) { + err = -ENOMEM; + goto free_netdev; + } spin_lock_init(&mac->hw_stats->stats_lock); mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET; } @@ -2037,7 +2039,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) err = register_netdev(eth->netdev[id]); if (err) { dev_err(eth->dev, "error bringing up device\n"); - return err; + err = -ENOMEM; + goto free_netdev; } eth->netdev[id]->irq = eth->irq; netif_info(eth, probe, eth->netdev[id], @@ -2045,6 +2048,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) eth->netdev[id]->base_addr, eth->netdev[id]->irq); return 0; + +free_netdev: + free_netdev(eth->netdev[id]); + return err; } static int mtk_probe(struct platform_device *pdev) From 144e2643e2f57d29804cacb5403708cd22984b73 Mon Sep 17 00:00:00 2001 From: Kamal Heib Date: Wed, 20 Jun 2018 13:47:11 +0300 Subject: [PATCH 131/903] staging: mt7621-eth: Use eth_hw_addr_random() Use eth_hw_addr_random() to set a random dev_addr and update addr_assign_type. Fixes: e3cbf478f846 ('staging: mt7621-eth: add the drivers core files') Signed-off-by: Kamal Heib Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-eth/mtk_eth_soc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c index 381d9d270bf5..f9b593ca2bcf 100644 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c +++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c @@ -1822,10 +1822,9 @@ static int __init mtk_init(struct net_device *dev) /* If the mac address is invalid, use random mac address */ if (!is_valid_ether_addr(dev->dev_addr)) { - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); dev_err(eth->dev, "generated random MAC address %pM\n", dev->dev_addr); - dev->addr_assign_type = NET_ADDR_RANDOM; } mac->hw->soc->set_mac(mac, dev->dev_addr); From 8b9005072821bccbcb4a6456416dfa69e8e7dd7a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:03 +0200 Subject: [PATCH 132/903] staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC Gpio complexity is just masking the fact that offset is always 0..n and writes to bits 0..n of some memory address. Because of this whole thing can just me converted to use GPIO_GENERIC and avoid duplications of a lot of driver custom functions. So use bgpio_init instead of custom code adding GPIO_GENERIC dependency to the Kconfig file. Also to make easier using bgpio_init function offset for each gpio bank, enumeration where register were defined has been replaced in favour of some macros which handle each gpio offset taking into account the bank where are located. Because of this change write and read functions which are being used for remaining irq handling stuff have been updated also as well as its dependencies along the code. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/Kconfig | 1 + drivers/staging/mt7621-gpio/gpio-mt7621.c | 136 +++++++--------------- 2 files changed, 42 insertions(+), 95 deletions(-) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index c741ec3f4e50..f4453e8d1760 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -1,6 +1,7 @@ config GPIO_MT7621 bool "Mediatek GPIO Support" depends on SOC_MT7620 || SOC_MT7621 + select GPIO_GENERIC select ARCH_REQUIRE_GPIOLIB help Say yes here to support the Mediatek SoC GPIO device diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 0c4fb4a1b4a9..eb60dd4d96e7 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -19,19 +19,18 @@ #define MTK_BANK_WIDTH 32 #define PIN_MASK(nr) (1UL << ((nr % MTK_BANK_WIDTH))) -enum mediatek_gpio_reg { - GPIO_REG_CTRL = 0, - GPIO_REG_POL, - GPIO_REG_DATA, - GPIO_REG_DSET, - GPIO_REG_DCLR, - GPIO_REG_REDGE, - GPIO_REG_FEDGE, - GPIO_REG_HLVL, - GPIO_REG_LLVL, - GPIO_REG_STAT, - GPIO_REG_EDGE, -}; +#define GPIO_BANK_WIDE 0x04 +#define GPIO_REG_CTRL 0x00 +#define GPIO_REG_POL 0x10 +#define GPIO_REG_DATA 0x20 +#define GPIO_REG_DSET 0x30 +#define GPIO_REG_DCLR 0x40 +#define GPIO_REG_REDGE 0x50 +#define GPIO_REG_FEDGE 0x60 +#define GPIO_REG_HLVL 0x70 +#define GPIO_REG_LLVL 0x80 +#define GPIO_REG_STAT 0x90 +#define GPIO_REG_EDGE 0xA0 struct mtk_gc { struct gpio_chip chip; @@ -55,80 +54,23 @@ to_mediatek_gpio(struct gpio_chip *chip) } static inline void -mtk_gpio_w32(struct mtk_gc *rg, u8 reg, u32 val) +mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val) { - struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip); - u32 offset = (reg * 0x10) + (rg->bank * 0x4); + struct gpio_chip *gc = &rg->chip; + struct mtk_data *gpio_data = gpiochip_get_data(gc); - iowrite32(val, gpio_data->gpio_membase + offset); + offset = (rg->bank * GPIO_BANK_WIDE) + offset; + gc->write_reg(gpio_data->gpio_membase + offset, val); } static inline u32 -mtk_gpio_r32(struct mtk_gc *rg, u8 reg) +mtk_gpio_r32(struct mtk_gc *rg, u32 offset) { - struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip); - u32 offset = (reg * 0x10) + (rg->bank * 0x4); + struct gpio_chip *gc = &rg->chip; + struct mtk_data *gpio_data = gpiochip_get_data(gc); - return ioread32(gpio_data->gpio_membase + offset); -} - -static void -mediatek_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - - mtk_gpio_w32(rg, (value) ? GPIO_REG_DSET : GPIO_REG_DCLR, BIT(offset)); -} - -static int -mediatek_gpio_get(struct gpio_chip *chip, unsigned int offset) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - - return !!(mtk_gpio_r32(rg, GPIO_REG_DATA) & BIT(offset)); -} - -static int -mediatek_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - unsigned long flags; - u32 t; - - spin_lock_irqsave(&rg->lock, flags); - t = mtk_gpio_r32(rg, GPIO_REG_CTRL); - t &= ~BIT(offset); - mtk_gpio_w32(rg, GPIO_REG_CTRL, t); - spin_unlock_irqrestore(&rg->lock, flags); - - return 0; -} - -static int -mediatek_gpio_direction_output(struct gpio_chip *chip, - unsigned int offset, int value) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - unsigned long flags; - u32 t; - - spin_lock_irqsave(&rg->lock, flags); - t = mtk_gpio_r32(rg, GPIO_REG_CTRL); - t |= BIT(offset); - mtk_gpio_w32(rg, GPIO_REG_CTRL, t); - mediatek_gpio_set(chip, offset, value); - spin_unlock_irqrestore(&rg->lock, flags); - - return 0; -} - -static int -mediatek_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - u32 t = mtk_gpio_r32(rg, GPIO_REG_CTRL); - - return (t & BIT(offset)) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; + offset = (rg->bank * GPIO_BANK_WIDE) + offset; + return gc->read_reg(gpio_data->gpio_membase + offset); } static int @@ -144,34 +86,38 @@ mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin) static int mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) { - struct mtk_data *gpio_data = dev_get_drvdata(&pdev->dev); + struct mtk_data *gpio = dev_get_drvdata(&pdev->dev); const __be32 *id = of_get_property(bank, "reg", NULL); struct mtk_gc *rg; + void __iomem *dat, *set, *ctrl, *diro; int ret; if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT) return -EINVAL; - rg = &gpio_data->gc_map[be32_to_cpu(*id)]; + rg = &gpio->gc_map[be32_to_cpu(*id)]; memset(rg, 0, sizeof(*rg)); spin_lock_init(&rg->lock); - - rg->chip.parent = &pdev->dev; - rg->chip.label = dev_name(&pdev->dev); rg->chip.of_node = bank; - rg->chip.base = MTK_BANK_WIDTH * be32_to_cpu(*id); - rg->chip.ngpio = MTK_BANK_WIDTH; - rg->chip.direction_input = mediatek_gpio_direction_input; - rg->chip.direction_output = mediatek_gpio_direction_output; - rg->chip.get_direction = mediatek_gpio_get_direction; - rg->chip.get = mediatek_gpio_get; - rg->chip.set = mediatek_gpio_set; - if (gpio_data->gpio_irq_domain) - rg->chip.to_irq = mediatek_gpio_to_irq; rg->bank = be32_to_cpu(*id); - ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio_data); + dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); + set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE); + ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE); + diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE); + + ret = bgpio_init(&rg->chip, &pdev->dev, 4, + dat, set, ctrl, diro, NULL, 0); + if (ret) { + dev_err(&pdev->dev, "bgpio_init() failed\n"); + return ret; + } + + if (gpio->gpio_irq_domain) + rg->chip.to_irq = mediatek_gpio_to_irq; + + ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n", rg->chip.ngpio, ret); From 7f68fefbbf94a99b35db393b89b497cd8bae7ae3 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:04 +0200 Subject: [PATCH 133/903] staging: mt7621-gpio: avoid including 'gpio.h' Including file '' should be avoided in new drivers code, so just remove it because it is no necessary at all. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index eb60dd4d96e7..f95310c230c1 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -5,7 +5,6 @@ */ #include -#include #include #include #include From 98f0703bf20a9c90df8f959ecd10775fd45ae2b1 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:05 +0200 Subject: [PATCH 134/903] staging: mt7621-gpio: make use of 'builtin_platform_driver' This driver was being registered using 'module_platform_driver' but it is not a module at all. Instead of this use 'builtin_platform_driver' which seems to be the correct one. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index f95310c230c1..6a31f60bdd12 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -312,4 +312,4 @@ static struct platform_driver mediatek_gpio_driver = { }, }; -module_platform_driver(mediatek_gpio_driver); +builtin_platform_driver(mediatek_gpio_driver); From 7e7cda889925af269ab902b2f402b94ce72059fc Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:06 +0200 Subject: [PATCH 135/903] staging: mt7621-gpio: implement '.irq_[request|release]_resources' functions When implementing custom irqchips it is important to also implement .irq_request_resources() and .irq_release_resources() and make sure these call gpiochip_[un]lock_as_irq(). Add those two for this driver. Also store struct device pointer in global state structure to be able to use 'dev_err' with the device from 'mediatek_request_resources' function. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 42 ++++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 6a31f60bdd12..e5a7979d0d73 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -40,6 +40,7 @@ struct mtk_gc { }; struct mtk_data { + struct device *dev; void __iomem *gpio_membase; int gpio_irq; struct irq_domain *gpio_irq_domain; @@ -231,12 +232,42 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) return 0; } +static int mediatek_irq_reqres(struct irq_data *d) +{ + struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); + int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH; + struct mtk_gc *rg = &gpio_data->gc_map[bank]; + struct gpio_chip *gc = &rg->chip; + int ret; + + ret = gpiochip_lock_as_irq(gc, irqd_to_hwirq(d)); + if (ret) { + dev_err(gpio_data->dev, "unable to lock HW IRQ %lu for IRQ\n", + irqd_to_hwirq(d)); + return -EINVAL; + } + + return 0; +} + +static void mediatek_irq_relres(struct irq_data *d) +{ + struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); + int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH; + struct mtk_gc *rg = &gpio_data->gc_map[bank]; + struct gpio_chip *gc = &rg->chip; + + gpiochip_unlock_as_irq(gc, irqd_to_hwirq(d)); +} + static struct irq_chip mediatek_gpio_irq_chip = { - .name = "GPIO", - .irq_unmask = mediatek_gpio_irq_unmask, - .irq_mask = mediatek_gpio_irq_mask, - .irq_mask_ack = mediatek_gpio_irq_mask, - .irq_set_type = mediatek_gpio_irq_type, + .name = "GPIO", + .irq_unmask = mediatek_gpio_irq_unmask, + .irq_mask = mediatek_gpio_irq_mask, + .irq_mask_ack = mediatek_gpio_irq_mask, + .irq_set_type = mediatek_gpio_irq_type, + .irq_request_resources = mediatek_irq_reqres, + .irq_release_resources = mediatek_irq_relres, }; static int @@ -284,6 +315,7 @@ mediatek_gpio_probe(struct platform_device *pdev) dev_err(&pdev->dev, "irq_domain_add_linear failed\n"); } + gpio_data->dev = &pdev->dev; platform_set_drvdata(pdev, gpio_data); for_each_child_of_node(np, bank) From 72b2884d62962e62079a940e58aee9a67074d304 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:07 +0200 Subject: [PATCH 136/903] staging: mt7621-gpio: add COMPILE_TEST This driver is actually platform-agnostic. Add COMPILE_TEST for the compilation test coverage. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index f4453e8d1760..835998a9b6f2 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -1,6 +1,6 @@ config GPIO_MT7621 bool "Mediatek GPIO Support" - depends on SOC_MT7620 || SOC_MT7621 + depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST select GPIO_GENERIC select ARCH_REQUIRE_GPIOLIB help From fe84f0c9b71395dd93f7f3239936ab34f7c51c39 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:08 +0200 Subject: [PATCH 137/903] staging: mt7621-gpio: add kerneldoc for state data containers This commit adds kerneldoc for the two data containers in order to better understanding of its existence. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index e5a7979d0d73..54c18c166271 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -31,6 +31,14 @@ #define GPIO_REG_STAT 0x90 #define GPIO_REG_EDGE 0xA0 +/** + * struct mtk_gc - data for a single gpio-chip + * @chip: gpio chip instance + * @lock: spinlock to protect the chip + * @bank: gpio bank number for the chip + * @rising: mask for rising irqs + * @falling: mask for falling irqs + */ struct mtk_gc { struct gpio_chip chip; spinlock_t lock; @@ -39,6 +47,16 @@ struct mtk_gc { u32 falling; }; +/** + * struct mtk_data - state container for + * data of the platform driver. It is a + * single irq-chip but 3 separate gpio-chip. + * @dev: device instance + * @gpio_membase: memory base address + * @gpio_irq: irq number from the device tree + * @gpio_irq_domain: irq domain for this chip + * @gc_map: array of the gpio chips + */ struct mtk_data { struct device *dev; void __iomem *gpio_membase; From 368d97d69dabc7d1a3d444436381ac62ba195818 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:09 +0200 Subject: [PATCH 138/903] staging: mt7621-gpio: implement high level and low level irqs This chip support high level and low level interrupts. Those have to be implemented also to get a complete and clean driver. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 47 ++++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 54c18c166271..0c344a55ff0d 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -38,6 +38,8 @@ * @bank: gpio bank number for the chip * @rising: mask for rising irqs * @falling: mask for falling irqs + * @hlevel: mask for high level irqs + * @llevel: mask for low level irqs */ struct mtk_gc { struct gpio_chip chip; @@ -45,6 +47,8 @@ struct mtk_gc { int bank; u32 rising; u32 falling; + u32 hlevel; + u32 llevel; }; /** @@ -184,7 +188,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d) int bank = pin / MTK_BANK_WIDTH; struct mtk_gc *rg = &gpio_data->gc_map[bank]; unsigned long flags; - u32 rise, fall; + u32 rise, fall, high, low; if (!rg) return; @@ -192,8 +196,12 @@ mediatek_gpio_irq_unmask(struct irq_data *d) spin_lock_irqsave(&rg->lock, flags); rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); + high = mtk_gpio_r32(rg, GPIO_REG_HLVL); + low = mtk_gpio_r32(rg, GPIO_REG_LLVL); mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (PIN_MASK(pin) & rg->rising)); mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (PIN_MASK(pin) & rg->falling)); + mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (PIN_MASK(pin) & rg->hlevel)); + mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (PIN_MASK(pin) & rg->llevel)); spin_unlock_irqrestore(&rg->lock, flags); } @@ -205,7 +213,7 @@ mediatek_gpio_irq_mask(struct irq_data *d) int bank = pin / MTK_BANK_WIDTH; struct mtk_gc *rg = &gpio_data->gc_map[bank]; unsigned long flags; - u32 rise, fall; + u32 rise, fall, high, low; if (!rg) return; @@ -213,8 +221,12 @@ mediatek_gpio_irq_mask(struct irq_data *d) spin_lock_irqsave(&rg->lock, flags); rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); + high = mtk_gpio_r32(rg, GPIO_REG_HLVL); + low = mtk_gpio_r32(rg, GPIO_REG_LLVL); mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~PIN_MASK(pin)); mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~PIN_MASK(pin)); + mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~PIN_MASK(pin)); + mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~PIN_MASK(pin)); spin_unlock_irqrestore(&rg->lock, flags); } @@ -231,21 +243,36 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) return -1; if (type == IRQ_TYPE_PROBE) { - if ((rg->rising | rg->falling) & mask) + if ((rg->rising | rg->falling | + rg->hlevel | rg->llevel) & mask) return 0; type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; } - if (type & IRQ_TYPE_EDGE_RISING) - rg->rising |= mask; - else - rg->rising &= ~mask; + rg->rising &= ~mask; + rg->falling &= ~mask; + rg->hlevel &= ~mask; + rg->llevel &= ~mask; - if (type & IRQ_TYPE_EDGE_FALLING) + switch (type & IRQ_TYPE_SENSE_MASK) { + case IRQ_TYPE_EDGE_BOTH: + rg->rising |= mask; rg->falling |= mask; - else - rg->falling &= ~mask; + break; + case IRQ_TYPE_EDGE_RISING: + rg->rising |= mask; + break; + case IRQ_TYPE_EDGE_FALLING: + rg->falling |= mask; + break; + case IRQ_TYPE_LEVEL_HIGH: + rg->hlevel |= mask; + break; + case IRQ_TYPE_LEVEL_LOW: + rg->llevel |= mask; + break; + } return 0; } From 7bf3d70e6e2c5ab724214a234a8755c03acb39a8 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:10 +0200 Subject: [PATCH 139/903] staging: mt7621-gpio: avoid custom irq_domain for gpio Instead of create a custom irq_domain for this chip, use 'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It is ok to call this function several times. We have to manually mark the line with 'IRQF_SHARED' and then loop over the three banks until you find a hit. There were some problems with removing an irqchip like that but this driver is a bool so it might work just fine. After this changes the functions 'mediatek_gpio_to_irq' is not needed anymore and also the 'gpio_irq_domain' field from the state container. Instead of use the custom irq domain in the irq handler use the associated domain from the gpio_chip in 'irq_find_mapping' function. Function 'mediatek_gpio_bank_probe' has been moved a it to the botton to have all the irq related functions together and avoid some forward declarations to resolve some symbols along the code. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/Kconfig | 1 + drivers/staging/mt7621-gpio/gpio-mt7621.c | 221 ++++++++-------------- 2 files changed, 81 insertions(+), 141 deletions(-) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index 835998a9b6f2..e32facba6cbf 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -2,6 +2,7 @@ config GPIO_MT7621 bool "Mediatek GPIO Support" depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST select GPIO_GENERIC + select GPIOLIB_IRQCHIP select ARCH_REQUIRE_GPIOLIB help Say yes here to support the Mediatek SoC GPIO device diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 0c344a55ff0d..d2a7512db0ea 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -58,14 +57,12 @@ struct mtk_gc { * @dev: device instance * @gpio_membase: memory base address * @gpio_irq: irq number from the device tree - * @gpio_irq_domain: irq domain for this chip * @gc_map: array of the gpio chips */ struct mtk_data { struct device *dev; void __iomem *gpio_membase; int gpio_irq; - struct irq_domain *gpio_irq_domain; struct mtk_gc gc_map[MTK_BANK_CNT]; }; @@ -95,98 +92,36 @@ mtk_gpio_r32(struct mtk_gc *rg, u32 offset) return gc->read_reg(gpio_data->gpio_membase + offset); } -static int -mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin) +static irqreturn_t +mediatek_gpio_irq_handler(int irq, void *data) { - struct mtk_data *gpio_data = gpiochip_get_data(chip); - struct mtk_gc *rg = to_mediatek_gpio(chip); + struct gpio_chip *gc = data; + struct mtk_gc *rg = to_mediatek_gpio(gc); + irqreturn_t ret = IRQ_NONE; + unsigned long pending; + int bit; - return irq_create_mapping(gpio_data->gpio_irq_domain, - pin + (rg->bank * MTK_BANK_WIDTH)); -} - -static int -mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) -{ - struct mtk_data *gpio = dev_get_drvdata(&pdev->dev); - const __be32 *id = of_get_property(bank, "reg", NULL); - struct mtk_gc *rg; - void __iomem *dat, *set, *ctrl, *diro; - int ret; - - if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT) - return -EINVAL; - - rg = &gpio->gc_map[be32_to_cpu(*id)]; - memset(rg, 0, sizeof(*rg)); - - spin_lock_init(&rg->lock); - rg->chip.of_node = bank; - rg->bank = be32_to_cpu(*id); - - dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); - set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE); - ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE); - diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE); - - ret = bgpio_init(&rg->chip, &pdev->dev, 4, - dat, set, ctrl, diro, NULL, 0); - if (ret) { - dev_err(&pdev->dev, "bgpio_init() failed\n"); - return ret; - } - - if (gpio->gpio_irq_domain) - rg->chip.to_irq = mediatek_gpio_to_irq; - - ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio); - if (ret < 0) { - dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n", - rg->chip.ngpio, ret); - return ret; - } - - /* set polarity to low for all gpios */ - mtk_gpio_w32(rg, GPIO_REG_POL, 0); - - dev_info(&pdev->dev, "registering %d gpios\n", rg->chip.ngpio); - - return 0; -} - -static void -mediatek_gpio_irq_handler(struct irq_desc *desc) -{ - struct mtk_data *gpio_data = irq_desc_get_handler_data(desc); - int i; - - for (i = 0; i < MTK_BANK_CNT; i++) { - struct mtk_gc *rg = &gpio_data->gc_map[i]; - unsigned long pending; - int bit; - - if (!rg) - continue; - - pending = mtk_gpio_r32(rg, GPIO_REG_STAT); + pending = mtk_gpio_r32(rg, GPIO_REG_STAT); + if (pending) { for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) { - u32 map = irq_find_mapping(gpio_data->gpio_irq_domain, - (MTK_BANK_WIDTH * i) + bit); + u32 map = irq_find_mapping(gc->irq.domain, bit); generic_handle_irq(map); mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit)); + ret |= IRQ_HANDLED; } } + + return ret; } static void mediatek_gpio_irq_unmask(struct irq_data *d) { - struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct mtk_gc *rg = to_mediatek_gpio(gc); int pin = d->hwirq; - int bank = pin / MTK_BANK_WIDTH; - struct mtk_gc *rg = &gpio_data->gc_map[bank]; unsigned long flags; u32 rise, fall, high, low; @@ -208,10 +143,9 @@ mediatek_gpio_irq_unmask(struct irq_data *d) static void mediatek_gpio_irq_mask(struct irq_data *d) { - struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct mtk_gc *rg = to_mediatek_gpio(gc); int pin = d->hwirq; - int bank = pin / MTK_BANK_WIDTH; - struct mtk_gc *rg = &gpio_data->gc_map[bank]; unsigned long flags; u32 rise, fall, high, low; @@ -233,10 +167,9 @@ mediatek_gpio_irq_mask(struct irq_data *d) static int mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) { - struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct mtk_gc *rg = to_mediatek_gpio(gc); int pin = d->hwirq; - int bank = pin / MTK_BANK_WIDTH; - struct mtk_gc *rg = &gpio_data->gc_map[bank]; u32 mask = PIN_MASK(pin); if (!rg) @@ -277,65 +210,84 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) return 0; } -static int mediatek_irq_reqres(struct irq_data *d) -{ - struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); - int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH; - struct mtk_gc *rg = &gpio_data->gc_map[bank]; - struct gpio_chip *gc = &rg->chip; - int ret; - - ret = gpiochip_lock_as_irq(gc, irqd_to_hwirq(d)); - if (ret) { - dev_err(gpio_data->dev, "unable to lock HW IRQ %lu for IRQ\n", - irqd_to_hwirq(d)); - return -EINVAL; - } - - return 0; -} - -static void mediatek_irq_relres(struct irq_data *d) -{ - struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); - int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH; - struct mtk_gc *rg = &gpio_data->gc_map[bank]; - struct gpio_chip *gc = &rg->chip; - - gpiochip_unlock_as_irq(gc, irqd_to_hwirq(d)); -} - static struct irq_chip mediatek_gpio_irq_chip = { .name = "GPIO", .irq_unmask = mediatek_gpio_irq_unmask, .irq_mask = mediatek_gpio_irq_mask, .irq_mask_ack = mediatek_gpio_irq_mask, .irq_set_type = mediatek_gpio_irq_type, - .irq_request_resources = mediatek_irq_reqres, - .irq_release_resources = mediatek_irq_relres, }; static int -mediatek_gpio_gpio_map(struct irq_domain *d, unsigned int irq, - irq_hw_number_t hw) +mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) { + struct mtk_data *gpio = dev_get_drvdata(&pdev->dev); + const __be32 *id = of_get_property(bank, "reg", NULL); + struct mtk_gc *rg; + void __iomem *dat, *set, *ctrl, *diro; int ret; - ret = irq_set_chip_data(irq, d->host_data); - if (ret < 0) + if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT) + return -EINVAL; + + rg = &gpio->gc_map[be32_to_cpu(*id)]; + memset(rg, 0, sizeof(*rg)); + + spin_lock_init(&rg->lock); + rg->chip.of_node = bank; + rg->bank = be32_to_cpu(*id); + + dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); + set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE); + ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE); + diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE); + + ret = bgpio_init(&rg->chip, &pdev->dev, 4, + dat, set, ctrl, diro, NULL, 0); + if (ret) { + dev_err(&pdev->dev, "bgpio_init() failed\n"); return ret; - irq_set_chip_and_handler(irq, &mediatek_gpio_irq_chip, - handle_level_irq); - irq_set_handler_data(irq, d); + } + + ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio); + if (ret < 0) { + dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n", + rg->chip.ngpio, ret); + return ret; + } + + /* + * Manually request the irq here instead of passing a flow-handler + * to gpiochip_set_chained_irqchip, because the irq is shared. + */ + ret = devm_request_irq(&pdev->dev, gpio->gpio_irq, + mediatek_gpio_irq_handler, IRQF_SHARED, + "mt7621", &rg->chip); + + if (ret) { + dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n", + gpio->gpio_irq, ret); + return ret; + } + + ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip, + 0, handle_simple_irq, IRQ_TYPE_NONE); + if (ret) { + dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n"); + return ret; + } + + gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip, + gpio->gpio_irq, NULL); + + /* set polarity to low for all gpios */ + mtk_gpio_w32(rg, GPIO_REG_POL, 0); + + dev_info(&pdev->dev, "registering %d gpios\n", rg->chip.ngpio); return 0; } -static const struct irq_domain_ops irq_domain_ops = { - .xlate = irq_domain_xlate_twocell, - .map = mediatek_gpio_gpio_map, -}; - static int mediatek_gpio_probe(struct platform_device *pdev) { @@ -352,14 +304,6 @@ mediatek_gpio_probe(struct platform_device *pdev) return PTR_ERR(gpio_data->gpio_membase); gpio_data->gpio_irq = irq_of_parse_and_map(np, 0); - if (gpio_data->gpio_irq) { - gpio_data->gpio_irq_domain = irq_domain_add_linear(np, - MTK_BANK_CNT * MTK_BANK_WIDTH, - &irq_domain_ops, gpio_data); - if (!gpio_data->gpio_irq_domain) - dev_err(&pdev->dev, "irq_domain_add_linear failed\n"); - } - gpio_data->dev = &pdev->dev; platform_set_drvdata(pdev, gpio_data); @@ -367,11 +311,6 @@ mediatek_gpio_probe(struct platform_device *pdev) if (of_device_is_compatible(bank, "mediatek,mt7621-gpio-bank")) mediatek_gpio_bank_probe(pdev, bank); - if (gpio_data->gpio_irq_domain) - irq_set_chained_handler_and_data(gpio_data->gpio_irq, - mediatek_gpio_irq_handler, - gpio_data); - return 0; } From 5547b411e9924c69bc3074e884227ee9bd5850d5 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:11 +0200 Subject: [PATCH 140/903] staging: mt7621-gpio: remove no more necessary PIN_MASK macro PIN_MASK macro was being used because of the fact we were only using one interrupt controller for all of the gpio chips. This has been changed to use one per gpio chip and each has 32 irqs. Because of this this macro is not needed anymore. Use BIT macro instead. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index d2a7512db0ea..a8893e811ef1 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -15,7 +15,6 @@ #define MTK_BANK_CNT 3 #define MTK_BANK_WIDTH 32 -#define PIN_MASK(nr) (1UL << ((nr % MTK_BANK_WIDTH))) #define GPIO_BANK_WIDE 0x04 #define GPIO_REG_CTRL 0x00 @@ -133,10 +132,10 @@ mediatek_gpio_irq_unmask(struct irq_data *d) fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); high = mtk_gpio_r32(rg, GPIO_REG_HLVL); low = mtk_gpio_r32(rg, GPIO_REG_LLVL); - mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (PIN_MASK(pin) & rg->rising)); - mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (PIN_MASK(pin) & rg->falling)); - mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (PIN_MASK(pin) & rg->hlevel)); - mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (PIN_MASK(pin) & rg->llevel)); + mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (BIT(pin) & rg->rising)); + mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (BIT(pin) & rg->falling)); + mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (BIT(pin) & rg->hlevel)); + mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (BIT(pin) & rg->llevel)); spin_unlock_irqrestore(&rg->lock, flags); } @@ -157,10 +156,10 @@ mediatek_gpio_irq_mask(struct irq_data *d) fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); high = mtk_gpio_r32(rg, GPIO_REG_HLVL); low = mtk_gpio_r32(rg, GPIO_REG_LLVL); - mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~PIN_MASK(pin)); - mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~PIN_MASK(pin)); - mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~PIN_MASK(pin)); - mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~PIN_MASK(pin)); + mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~BIT(pin)); + mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~BIT(pin)); + mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin)); + mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin)); spin_unlock_irqrestore(&rg->lock, flags); } @@ -170,7 +169,7 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct mtk_gc *rg = to_mediatek_gpio(gc); int pin = d->hwirq; - u32 mask = PIN_MASK(pin); + u32 mask = BIT(pin); if (!rg) return -1; From 26cbc8cf92a3675223489751b97ca0627d865263 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:12 +0200 Subject: [PATCH 141/903] staging: mt7621-gpio: update kerneldoc for state containers Update kernel doc for mtk_data and also remove no needed documentation for mtk_gc which is clear enough to don't need it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index a8893e811ef1..5f7d524cd999 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -29,16 +29,6 @@ #define GPIO_REG_STAT 0x90 #define GPIO_REG_EDGE 0xA0 -/** - * struct mtk_gc - data for a single gpio-chip - * @chip: gpio chip instance - * @lock: spinlock to protect the chip - * @bank: gpio bank number for the chip - * @rising: mask for rising irqs - * @falling: mask for falling irqs - * @hlevel: mask for high level irqs - * @llevel: mask for low level irqs - */ struct mtk_gc { struct gpio_chip chip; spinlock_t lock; @@ -51,8 +41,9 @@ struct mtk_gc { /** * struct mtk_data - state container for - * data of the platform driver. It is a - * single irq-chip but 3 separate gpio-chip. + * data of the platform driver. It is 3 + * separate gpio-chip each one with its + * own irq_chip. * @dev: device instance * @gpio_membase: memory base address * @gpio_irq: irq number from the device tree From 3e55d7c9136980c80e5ab99d24dc7b3247362953 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:13 +0200 Subject: [PATCH 142/903] staging: mt7621-gpio: align indentation for all defines There was two remaining defines which weren't properly aligned with the rest. Align them improving readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 5f7d524cd999..853817a3cf16 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -13,8 +13,8 @@ #include #include -#define MTK_BANK_CNT 3 -#define MTK_BANK_WIDTH 32 +#define MTK_BANK_CNT 3 +#define MTK_BANK_WIDTH 32 #define GPIO_BANK_WIDE 0x04 #define GPIO_REG_CTRL 0x00 From bfb623c5b0935a2e4b5fe86eab79a37a37b67209 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:14 +0200 Subject: [PATCH 143/903] staging: mt7621-gpio: avoid check for NULL in 'to_mediatek_gpio' calls Function 'to_mediatek_gpio' cannot return NULL, so this NULL checkings are pointless. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 853817a3cf16..1318003b28d5 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -115,9 +115,6 @@ mediatek_gpio_irq_unmask(struct irq_data *d) unsigned long flags; u32 rise, fall, high, low; - if (!rg) - return; - spin_lock_irqsave(&rg->lock, flags); rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); @@ -139,9 +136,6 @@ mediatek_gpio_irq_mask(struct irq_data *d) unsigned long flags; u32 rise, fall, high, low; - if (!rg) - return; - spin_lock_irqsave(&rg->lock, flags); rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); @@ -162,9 +156,6 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) int pin = d->hwirq; u32 mask = BIT(pin); - if (!rg) - return -1; - if (type == IRQ_TYPE_PROBE) { if ((rg->rising | rg->falling | rg->hlevel | rg->llevel) & mask) From e4550f6e9a134ab5e32a7b0c0baeab5586b37692 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:15 +0200 Subject: [PATCH 144/903] staging: mt7621-gpio: avoid to set up irqs if not defined in dts If there is no interrupt defined in the dts 'irq_of_parse_and_map' returns 0 and we should't set up interrupts for each gpio chip in that case. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 44 ++++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 1318003b28d5..96dee10cd4ff 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -237,30 +237,32 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) return ret; } - /* - * Manually request the irq here instead of passing a flow-handler - * to gpiochip_set_chained_irqchip, because the irq is shared. - */ - ret = devm_request_irq(&pdev->dev, gpio->gpio_irq, - mediatek_gpio_irq_handler, IRQF_SHARED, - "mt7621", &rg->chip); + if (gpio->gpio_irq) { + /* + * Manually request the irq here instead of passing a flow-handler + * to gpiochip_set_chained_irqchip, because the irq is shared. + */ + ret = devm_request_irq(&pdev->dev, gpio->gpio_irq, + mediatek_gpio_irq_handler, IRQF_SHARED, + "mt7621", &rg->chip); - if (ret) { - dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n", - gpio->gpio_irq, ret); - return ret; + if (ret) { + dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n", + gpio->gpio_irq, ret); + return ret; + } + + ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip, + 0, handle_simple_irq, IRQ_TYPE_NONE); + if (ret) { + dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n"); + return ret; + } + + gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip, + gpio->gpio_irq, NULL); } - ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip, - 0, handle_simple_irq, IRQ_TYPE_NONE); - if (ret) { - dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n"); - return ret; - } - - gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip, - gpio->gpio_irq, NULL); - /* set polarity to low for all gpios */ mtk_gpio_w32(rg, GPIO_REG_POL, 0); From 888295597e07e266dd6fa9d1029af015dc40c67b Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:16 +0200 Subject: [PATCH 145/903] staging: mt7621-gpio: avoid one level indentation in interrupt handler There is no need to check for 'pending' before loop over the interrupts using 'for_each_set_bit' if nothing is set the return values will be the same so just avoid this check avoiding also one level intentation and improving readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 96dee10cd4ff..698a95de4a34 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -93,14 +93,12 @@ mediatek_gpio_irq_handler(int irq, void *data) pending = mtk_gpio_r32(rg, GPIO_REG_STAT); - if (pending) { - for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) { - u32 map = irq_find_mapping(gc->irq.domain, bit); + for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) { + u32 map = irq_find_mapping(gc->irq.domain, bit); - generic_handle_irq(map); - mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit)); - ret |= IRQ_HANDLED; - } + generic_handle_irq(map); + mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit)); + ret |= IRQ_HANDLED; } return ret; From c4604a0e5c6b28601613e620de71877ace9a314e Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:17 +0200 Subject: [PATCH 146/903] staging: mt7621-gpio: set different names for each gpio_chip and irq_chip Currently the driver defines 3 gpiochips, one for each bank. /sys/class/gpio/gpiochip416/label:1e000600.gpio /sys/class/gpio/gpiochip448/label:1e000600.gpio /sys/class/gpio/gpiochip480/label:1e000600.gpio Unfortunately they all have the same label Interrupts from /proc/interrupt show the same name which is confusing: /proc/interrupts: 17: 0 0 0 0 MIPS GIC 19 mt7621, mt7621, mt7621 which is the interrupt from the GPIO controller. It is a little weird that all three banks are named "mt7621" here. We also have: 26: 0 0 0 0 GPIO 18 reset which is the interrupt from GPIO which provides the "reset" button. I suspect that if I had interrupts form two different banks they would both be called "GPIO" which would be a little confusing. In order to unify all of this set different names for each chip Use a 'bank-based' name instead the same for all: 'mt7621-bank[0-2]'. Create a new 'mediatek_gpio_bank_name' function which return the name depending on the bank number. This function is allways called with a valid index 0, 1 or 2. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 698a95de4a34..63fb5a1646d4 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -190,13 +190,21 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) } static struct irq_chip mediatek_gpio_irq_chip = { - .name = "GPIO", .irq_unmask = mediatek_gpio_irq_unmask, .irq_mask = mediatek_gpio_irq_mask, .irq_mask_ack = mediatek_gpio_irq_mask, .irq_set_type = mediatek_gpio_irq_type, }; +static inline const char * const mediatek_gpio_bank_name(int bank) +{ + static const char * const bank_names[] = { + "mt7621-bank0", "mt7621-bank1", "mt7621-bank2", + }; + + return bank_names[bank]; +} + static int mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) { @@ -215,6 +223,7 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) spin_lock_init(&rg->lock); rg->chip.of_node = bank; rg->bank = be32_to_cpu(*id); + rg->chip.label = mediatek_gpio_bank_name(rg->bank); dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE); @@ -242,7 +251,7 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) */ ret = devm_request_irq(&pdev->dev, gpio->gpio_irq, mediatek_gpio_irq_handler, IRQF_SHARED, - "mt7621", &rg->chip); + rg->chip.label, &rg->chip); if (ret) { dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n", @@ -250,6 +259,7 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) return ret; } + mediatek_gpio_irq_chip.name = rg->chip.label; ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip, 0, handle_simple_irq, IRQ_TYPE_NONE); if (ret) { From 32c06cdef5c672e47a611f6794368e751034a9b5 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:18 +0200 Subject: [PATCH 147/903] staging: mt7621-gpio: avoid long line in a comment Checkpatch script is complaining about a comment line which exceeds 80 characteres. Just silence it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 63fb5a1646d4..9a4a12fddf11 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -246,8 +246,9 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) if (gpio->gpio_irq) { /* - * Manually request the irq here instead of passing a flow-handler - * to gpiochip_set_chained_irqchip, because the irq is shared. + * Manually request the irq here instead of passing + * a flow-handler to gpiochip_set_chained_irqchip, + * because the irq is shared. */ ret = devm_request_irq(&pdev->dev, gpio->gpio_irq, mediatek_gpio_irq_handler, IRQF_SHARED, From 36913c87abc19833874be792569efae890069585 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:19 +0200 Subject: [PATCH 148/903] staging: mt7621-gpio: update Kconfig with SoC details Kconfig is using a generic 'Mediatek GPIO Support' in description and help which is not specific at all about the current SoC which is MT7621. Update it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index e32facba6cbf..5485dd2d9b61 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -1,8 +1,8 @@ config GPIO_MT7621 - bool "Mediatek GPIO Support" + bool "Mediatek MT7621 GPIO Support" depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST select GPIO_GENERIC select GPIOLIB_IRQCHIP select ARCH_REQUIRE_GPIOLIB help - Say yes here to support the Mediatek SoC GPIO device + Say yes here to support the Mediatek MT7621 SoC GPIO device From 6042985276994d5a99b9f195c8ceac002e66f00d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 18 Jun 2018 11:36:20 +0200 Subject: [PATCH 149/903] staging: mt7621-gpio: avoid use banks in device tree Banks shouldn't be defined in DT if number of resources per bank is not variable. We actually know that this SoC has three banks so take that into account in order to don't overspecify the device tree. Device tree will only have one node making it simple. Update device tree, binding doc and code accordly. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/gbpc1.dts | 10 ++-- drivers/staging/mt7621-dts/mt7621.dtsi | 31 ++-------- drivers/staging/mt7621-gpio/gpio-mt7621.c | 21 +++---- .../mt7621-gpio/mediatek,mt7621-gpio.txt | 59 ++++--------------- 4 files changed, 31 insertions(+), 90 deletions(-) diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index 425ec9539d31..d5b27e224b56 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts @@ -29,7 +29,7 @@ reset { label = "reset"; - gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; + gpios = <&gpio 18 GPIO_ACTIVE_HIGH>; linux,code = ; }; }; @@ -39,22 +39,22 @@ system { label = "gb-pc1:green:system"; - gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; }; status { label = "gb-pc1:green:status"; - gpios = <&gpio0 8 GPIO_ACTIVE_LOW>; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; }; lan1 { label = "gb-pc1:green:lan1"; - gpios = <&gpio0 24 GPIO_ACTIVE_LOW>; + gpios = <&gpio 24 GPIO_ACTIVE_LOW>; }; lan2 { label = "gb-pc1:green:lan2"; - gpios = <&gpio0 25 GPIO_ACTIVE_LOW>; + gpios = <&gpio 25 GPIO_ACTIVE_LOW>; }; }; }; diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 4bd311e94518..a87fcc6d61b2 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -61,37 +61,14 @@ }; gpio: gpio@600 { - #address-cells = <1>; - #size-cells = <0>; - + #gpio-cells = <2>; + #interrupt-cells = <2>; compatible = "mediatek,mt7621-gpio"; + gpio-controller; + interrupt-controller; reg = <0x600 0x100>; - interrupt-parent = <&gic>; interrupts = ; - interrupt-controller; - #interrupt-cells = <2>; - - gpio0: bank@0 { - reg = <0>; - compatible = "mediatek,mt7621-gpio-bank"; - gpio-controller; - #gpio-cells = <2>; - }; - - gpio1: bank@1 { - reg = <1>; - compatible = "mediatek,mt7621-gpio-bank"; - gpio-controller; - #gpio-cells = <2>; - }; - - gpio2: bank@2 { - reg = <2>; - compatible = "mediatek,mt7621-gpio-bank"; - gpio-controller; - #gpio-cells = <2>; - }; }; i2c: i2c@900 { diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 9a4a12fddf11..281e6214d543 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -206,23 +206,20 @@ static inline const char * const mediatek_gpio_bank_name(int bank) } static int -mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) +mediatek_gpio_bank_probe(struct platform_device *pdev, + struct device_node *node, int bank) { struct mtk_data *gpio = dev_get_drvdata(&pdev->dev); - const __be32 *id = of_get_property(bank, "reg", NULL); struct mtk_gc *rg; void __iomem *dat, *set, *ctrl, *diro; int ret; - if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT) - return -EINVAL; - - rg = &gpio->gc_map[be32_to_cpu(*id)]; + rg = &gpio->gc_map[bank]; memset(rg, 0, sizeof(*rg)); spin_lock_init(&rg->lock); - rg->chip.of_node = bank; - rg->bank = be32_to_cpu(*id); + rg->chip.of_node = node; + rg->bank = bank; rg->chip.label = mediatek_gpio_bank_name(rg->bank); dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); @@ -283,9 +280,10 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) static int mediatek_gpio_probe(struct platform_device *pdev) { - struct device_node *bank, *np = pdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct mtk_data *gpio_data; + int i; gpio_data = devm_kzalloc(&pdev->dev, sizeof(*gpio_data), GFP_KERNEL); if (!gpio_data) @@ -299,9 +297,8 @@ mediatek_gpio_probe(struct platform_device *pdev) gpio_data->dev = &pdev->dev; platform_set_drvdata(pdev, gpio_data); - for_each_child_of_node(np, bank) - if (of_device_is_compatible(bank, "mediatek,mt7621-gpio-bank")) - mediatek_gpio_bank_probe(pdev, bank); + for (i = 0; i < MTK_BANK_CNT; i++) + mediatek_gpio_bank_probe(pdev, np, i); return 0; } diff --git a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt index 30d8a0225aa1..ba455589f869 100644 --- a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt +++ b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt @@ -1,68 +1,35 @@ -Mediatek SoC GPIO controller bindings +Mediatek MT7621 SoC GPIO controller bindings The IP core used inside these SoCs has 3 banks of 32 GPIOs each. The registers of all the banks are interwoven inside one single IO range. -We load one GPIO controller instance per bank. To make this possible -we support 2 types of nodes. The parent node defines the memory I/O range and -has 3 children each describing a single bank. Also the GPIO controller can receive +We load one GPIO controller instance per bank. Also the GPIO controller can receive interrupts on any of the GPIOs, either edge or level. It then interrupts the CPU using GIC INT12. Required properties for the top level node: +- #gpio-cells : Should be two. The first cell is the GPIO pin number and the + second cell specifies GPIO flags, as defined in . + Only the GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported. +- #interrupt-cells : Specifies the number of cells needed to encode an + interrupt. Should be 2. The first cell defines the interrupt number, + the second encodes the triger flags encoded as described in + Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - compatible: - "mediatek,mt7621-gpio" for Mediatek controllers - reg : Physical base address and length of the controller's registers - interrupt-parent : phandle of the parent interrupt controller. - interrupts : Interrupt specifier for the controllers interrupt. - interrupt-controller : Mark the device node as an interrupt controller. -- #interrupt-cells : Should be 2. The first cell defines the interrupt number. - The second cell bits[3:0] is used to specify trigger type as follows: - - 1 = low-to-high edge triggered. - - 2 = high-to-low edge triggered. - - 4 = active high level-sensitive. - - 8 = active low level-sensitive. - - -Required properties for the GPIO bank node: -- compatible: - - "mediatek,mt7621-gpio-bank" for Mediatek banks -- #gpio-cells : Should be two. The first cell is the GPIO pin number and the - second cell specifies GPIO flags, as defined in . - Only the GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported. - gpio-controller : Marks the device node as a GPIO controller. -- reg : The id of the bank that the node describes. Example: gpio@600 { - #address-cells = <1>; - #size-cells = <0>; - + #gpio-cells = <2>; + #interrupt-cells = <2>; compatible = "mediatek,mt7621-gpio"; + gpio-controller; + interrupt-controller; reg = <0x600 0x100>; - interrupt-parent = <&gic>; interrupts = ; - interrupt-controller; - #interrupt-cells = <2>; - - gpio0: bank@0 { - reg = <0>; - compatible = "mediatek,mt7621-gpio-bank"; - gpio-controller; - #gpio-cells = <2>; - }; - - gpio1: bank@1 { - reg = <1>; - compatible = "mediatek,mt7621-gpio-bank"; - gpio-controller; - #gpio-cells = <2>; - }; - - gpio2: bank@2 { - reg = <2>; - compatible = "mediatek,mt7621-gpio-bank"; - gpio-controller; - #gpio-cells = <2>; - }; }; From 8c05c98b1a2f0bc8a8fbcc0746adedea01311040 Mon Sep 17 00:00:00 2001 From: Thibaut Robert Date: Tue, 19 Jun 2018 20:44:19 +0200 Subject: [PATCH 150/903] staging: wilc1000: Use common structs to parse ip packets Use structs ethhdr, iphdr and tcphdr instead of manual parsing in tcp_process. This commit fix handling of ip packets containing options. It also fixes the following sparse warning: drivers/staging/wilc1000//wilc_wlan.c:201:19: warning: cast to restricted __be16 Signed-off-by: Thibaut Robert Reviewed-by: Dan Carpenter Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan.c | 43 ++++++++++------------------ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 55755d7fbb30..85af36595e69 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1,4 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#include +#include #include "wilc_wfi_netdevice.h" #include "wilc_wlan_cfg.h" @@ -150,9 +152,8 @@ static inline int add_tcp_pending_ack(u32 ack, u32 session_index, static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) { - u8 *eth_hdr_ptr; - u8 *buffer = tqe->buffer; - unsigned short h_proto; + void *buffer = tqe->buffer; + const struct ethhdr *eth_hdr_ptr = buffer; int i; unsigned long flags; struct wilc_vif *vif; @@ -163,37 +164,23 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) spin_lock_irqsave(&wilc->txq_spinlock, flags); - eth_hdr_ptr = &buffer[0]; - h_proto = ntohs(*((unsigned short *)ð_hdr_ptr[12])); - if (h_proto == ETH_P_IP) { - u8 *ip_hdr_ptr; - u8 protocol; + if (eth_hdr_ptr->h_proto == htons(ETH_P_IP)) { + const struct iphdr *ip_hdr_ptr = buffer + ETH_HLEN; - ip_hdr_ptr = &buffer[ETHERNET_HDR_LEN]; - protocol = ip_hdr_ptr[9]; - - if (protocol == 0x06) { - u8 *tcp_hdr_ptr; + if (ip_hdr_ptr->protocol == IPPROTO_TCP) { + const struct tcphdr *tcp_hdr_ptr; u32 IHL, total_length, data_offset; - tcp_hdr_ptr = &ip_hdr_ptr[IP_HDR_LEN]; - IHL = (ip_hdr_ptr[0] & 0xf) << 2; - total_length = ((u32)ip_hdr_ptr[2] << 8) + - (u32)ip_hdr_ptr[3]; - data_offset = ((u32)tcp_hdr_ptr[12] & 0xf0) >> 2; + IHL = ip_hdr_ptr->ihl << 2; + tcp_hdr_ptr = buffer + ETH_HLEN + IHL; + total_length = ntohs(ip_hdr_ptr->tot_len); + + data_offset = tcp_hdr_ptr->doff << 2; if (total_length == (IHL + data_offset)) { u32 seq_no, ack_no; - seq_no = ((u32)tcp_hdr_ptr[4] << 24) + - ((u32)tcp_hdr_ptr[5] << 16) + - ((u32)tcp_hdr_ptr[6] << 8) + - (u32)tcp_hdr_ptr[7]; - - ack_no = ((u32)tcp_hdr_ptr[8] << 24) + - ((u32)tcp_hdr_ptr[9] << 16) + - ((u32)tcp_hdr_ptr[10] << 8) + - (u32)tcp_hdr_ptr[11]; - + seq_no = ntohl(tcp_hdr_ptr->seq); + ack_no = ntohl(tcp_hdr_ptr->ack_seq); for (i = 0; i < tcp_session; i++) { u32 j = ack_session_info[i].seq_num; From 7233be314e022a9b1f62c986e313d92a86ebb281 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:03 +0530 Subject: [PATCH 151/903] staging: wilc1000: remove host_if_work() to handle TODO list issue Remove multiplexing of command at host_if_work(). Make use of function pointer instead of command ID to track individual work_struct separately. Modified the handler function to take work_struct pointer as argument and its return type is changes to void. Now prototype of 'handle_' function is same work_struct i.e. 'void (*fun)(struct struct *)' to register with work_queue. Removed host_if_work() because its not required now. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 574 +++++++++++----------- 1 file changed, 278 insertions(+), 296 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0aaae33f97b9..4f6008e6bf32 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -184,6 +184,7 @@ struct host_if_msg { union message_body body; struct wilc_vif *vif; struct work_struct work; + void (*fn)(struct work_struct *ws); }; struct join_bss_param { @@ -239,7 +240,6 @@ static u32 clients_count; static void *host_int_parse_join_bss_param(struct network_info *info); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt); -static void host_if_work(struct work_struct *work); /*! * @author syounan @@ -255,7 +255,7 @@ static int wilc_enqueue_cmd(struct host_if_msg *msg) if (!new_msg) return -ENOMEM; - INIT_WORK(&new_msg->work, host_if_work); + INIT_WORK(&new_msg->work, msg->fn); queue_work(hif_workqueue, &new_msg->work); return 0; } @@ -284,9 +284,11 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) return wilc->vif[index]; } -static void handle_set_channel(struct wilc_vif *vif, - struct channel_attr *hif_set_ch) +static void handle_set_channel(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct channel_attr *hif_set_ch = &msg->body.channel_info; int ret = 0; struct wid wid; @@ -300,27 +302,28 @@ static void handle_set_channel(struct wilc_vif *vif, if (ret) netdev_err(vif->ndev, "Failed to set channel\n"); + kfree(msg); + complete(&hif_thread_comp); } -static int handle_set_wfi_drv_handler(struct wilc_vif *vif, - struct drv_handler *hif_drv_handler) +static void handle_set_wfi_drv_handler(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct drv_handler *hif_drv_handler = &msg->body.drv; int ret = 0; struct wid wid; u8 *currbyte, *buffer; struct host_if_drv *hif_drv = NULL; - if (!vif->hif_drv) - return -EINVAL; - - if (!hif_drv_handler) - return -EINVAL; + if (!vif->hif_drv || !hif_drv_handler) + goto free_msg; hif_drv = vif->hif_drv; buffer = kzalloc(DRV_HANDLER_SIZE, GFP_KERNEL); if (!buffer) - return -ENOMEM; + goto free_msg; currbyte = buffer; *currbyte = hif_drv->driver_handler_id & DRV_HANDLER_MASK; @@ -340,20 +343,22 @@ static int handle_set_wfi_drv_handler(struct wilc_vif *vif, ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, hif_drv->driver_handler_id); - if (ret) { + if (ret) netdev_err(vif->ndev, "Failed to set driver handler\n"); - complete(&hif_driver_comp); - kfree(buffer); - return ret; - } + complete(&hif_driver_comp); kfree(buffer); - return 0; + +free_msg: + kfree(msg); + complete(&hif_thread_comp); } -static void handle_set_operation_mode(struct wilc_vif *vif, - struct op_mode *hif_op_mode) +static void handle_set_operation_mode(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct op_mode *hif_op_mode = &msg->body.mode; int ret = 0; struct wid wid; @@ -370,10 +375,16 @@ static void handle_set_operation_mode(struct wilc_vif *vif, if (ret) netdev_err(vif->ndev, "Failed to set driver handler\n"); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx) +static void handle_set_ip_address(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + u8 *ip_addr = msg->body.ip_info.ip_addr; + u8 idx = msg->body.ip_info.idx; int ret = 0; struct wid wid; char firmware_ip_addr[4] = {0}; @@ -395,10 +406,15 @@ static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx) if (ret) netdev_err(vif->ndev, "Failed to set IP address\n"); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) +static void handle_get_ip_address(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + u8 idx = msg->body.ip_info.idx; int ret = 0; struct wid wid; @@ -419,11 +435,15 @@ static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) if (ret) netdev_err(vif->ndev, "Failed to get IP address\n"); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_get_mac_address(struct wilc_vif *vif, - struct get_mac_addr *get_mac_addr) +static void handle_get_mac_address(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct get_mac_addr *get_mac_addr = &msg->body.get_mac_info; int ret = 0; struct wid wid; @@ -438,10 +458,15 @@ static void handle_get_mac_address(struct wilc_vif *vif, if (ret) netdev_err(vif->ndev, "Failed to get mac address\n"); complete(&hif_wait_response); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_cfg_param(struct wilc_vif *vif, struct cfg_param_attr *param) +static void handle_cfg_param(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct cfg_param_attr *param = &msg->body.cfg_info; int ret = 0; struct wid wid_list[32]; struct host_if_drv *hif_drv = vif->hif_drv; @@ -730,10 +755,15 @@ static void handle_cfg_param(struct wilc_vif *vif, struct cfg_param_attr *param) unlock: mutex_unlock(&hif_drv->cfg_values_lock); + kfree(msg); + complete(&hif_thread_comp); } -static s32 handle_scan(struct wilc_vif *vif, struct scan_attr *scan_info) +static void handle_scan(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct scan_attr *scan_info = &msg->body.scan_info; s32 result = 0; struct wid wid_list[5]; u32 index = 0; @@ -843,7 +873,8 @@ error: kfree(hdn_ntwk_wid_val); - return result; + kfree(msg); + complete(&hif_thread_comp); } static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) @@ -885,9 +916,11 @@ static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) } u8 wilc_connected_ssid[6] = {0}; -static s32 handle_connect(struct wilc_vif *vif, - struct connect_attr *conn_attr) +static void handle_connect(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct connect_attr *conn_attr = &msg->body.con_info; s32 result = 0; struct wid wid_list[8]; u32 wid_cnt = 0, dummyval = 0; @@ -895,10 +928,18 @@ static s32 handle_connect(struct wilc_vif *vif, struct join_bss_param *bss_param; struct host_if_drv *hif_drv = vif->hif_drv; + if (msg->vif->hif_drv->usr_scan_req.scan_result) { + result = wilc_enqueue_cmd(msg); + if (result) + goto error; + usleep_range(2 * 1000, 2 * 1000); + kfree(msg); + return; + } + if (memcmp(conn_attr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) { - result = 0; netdev_err(vif->ndev, "Discard connect request\n"); - return result; + goto error; } bss_param = conn_attr->params; @@ -1138,11 +1179,14 @@ error: conn_attr->ies = NULL; kfree(cur_byte); - return result; + kfree(msg); + complete(&hif_thread_comp); } -static s32 handle_connect_timeout(struct wilc_vif *vif) +static void handle_connect_timeout(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; s32 result = 0; struct connect_info info; struct wid wid; @@ -1151,7 +1195,7 @@ static s32 handle_connect_timeout(struct wilc_vif *vif) if (!hif_drv) { netdev_err(vif->ndev, "Driver handler is NULL\n"); - return result; + goto out; } hif_drv->hif_state = HOST_IF_IDLE; @@ -1170,7 +1214,7 @@ static s32 handle_connect_timeout(struct wilc_vif *vif) hif_drv->usr_conn_req.ies_len, GFP_KERNEL); if (!info.req_ies) - return -ENOMEM; + goto out; } hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP, @@ -1206,15 +1250,18 @@ static s32 handle_connect_timeout(struct wilc_vif *vif) eth_zero_addr(wilc_connected_ssid); - return result; +out: + kfree(msg); + complete(&hif_thread_comp); } -static s32 handle_rcvd_ntwrk_info(struct wilc_vif *vif, - struct rcvd_net_info *rcvd_info) +static void handle_rcvd_ntwrk_info(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct rcvd_net_info *rcvd_info = &msg->body.net_info; u32 i; bool found; - s32 result = 0; struct network_info *info = NULL; void *params = NULL; struct host_if_drv *hif_drv = vif->hif_drv; @@ -1228,7 +1275,6 @@ static s32 handle_rcvd_ntwrk_info(struct wilc_vif *vif, wilc_parse_network_info(rcvd_info->buffer, &info); if (!info || !scan_req->scan_result) { netdev_err(vif->ndev, "driver is null\n"); - result = -EINVAL; goto done; } @@ -1274,7 +1320,8 @@ done: kfree(info); } - return result; + kfree(msg); + complete(&hif_thread_comp); } static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, @@ -1411,24 +1458,23 @@ static inline void host_int_handle_disconnect(struct wilc_vif *vif) hif_drv->hif_state = HOST_IF_IDLE; } -static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif, - struct rcvd_async_info *rcvd_info) +static void handle_rcvd_gnrl_async_info(struct work_struct *work) { - s32 result = 0; + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct rcvd_async_info *rcvd_info = &msg->body.async_info; u8 msg_type = 0; u8 mac_status; struct host_if_drv *hif_drv = vif->hif_drv; if (!rcvd_info->buffer) { netdev_err(vif->ndev, "Received buffer is NULL\n"); - return -EINVAL; + goto free_msg; } if (!hif_drv) { netdev_err(vif->ndev, "Driver handler is NULL\n"); - kfree(rcvd_info->buffer); - rcvd_info->buffer = NULL; - return -ENODEV; + goto free_rcvd_info; } if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP || @@ -1436,18 +1482,14 @@ static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif, hif_drv->usr_scan_req.scan_result) { if (!hif_drv->usr_conn_req.conn_result) { netdev_err(vif->ndev, "driver is null\n"); - kfree(rcvd_info->buffer); - rcvd_info->buffer = NULL; - return -EINVAL; + goto free_rcvd_info; } msg_type = rcvd_info->buffer[0]; if ('I' != msg_type) { netdev_err(vif->ndev, "Received Message incorrect.\n"); - kfree(rcvd_info->buffer); - rcvd_info->buffer = NULL; - return -EFAULT; + goto free_rcvd_info; } mac_status = rcvd_info->buffer[7]; @@ -1464,10 +1506,13 @@ static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif, } } +free_rcvd_info: kfree(rcvd_info->buffer); rcvd_info->buffer = NULL; - return result; +free_msg: + kfree(msg); + complete(&hif_thread_comp); } static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) @@ -1504,8 +1549,11 @@ static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) return ret; } -static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) +static void handle_key(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct key_attr *hif_key = &msg->body.key_info; int result = 0; struct wid wid; struct wid wid_list[5]; @@ -1726,11 +1774,14 @@ out_wpa_ptk: if (result) netdev_err(vif->ndev, "Failed to send key config packet\n"); - return result; + kfree(msg); + complete(&hif_thread_comp); } -static void handle_disconnect(struct wilc_vif *vif) +static void handle_disconnect(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; struct wid wid; struct host_if_drv *hif_drv = vif->hif_drv; struct disconnect_info disconn_info; @@ -1798,6 +1849,8 @@ static void handle_disconnect(struct wilc_vif *vif) out: complete(&hif_drv->comp_test_disconn_block); + kfree(msg); + complete(&hif_thread_comp); } void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) @@ -1809,8 +1862,10 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) wilc_disconnect(vif, 1); } -static void handle_get_rssi(struct wilc_vif *vif) +static void handle_get_rssi(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; s32 result = 0; struct wid wid; @@ -1821,19 +1876,21 @@ static void handle_get_rssi(struct wilc_vif *vif) result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to get RSSI value\n"); - result = -EFAULT; - } complete(&vif->hif_drv->comp_get_rssi); + kfree(msg); + complete(&hif_thread_comp); } -static s32 handle_get_statistics(struct wilc_vif *vif, - struct rf_info *stats) +static void handle_get_statistics(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; struct wid wid_list[5]; u32 wid_cnt = 0, result = 0; + struct rf_info *stats = (struct rf_info *)msg->body.data; wid_list[wid_cnt].id = WID_LINKSPEED; wid_list[wid_cnt].type = WID_CHAR; @@ -1880,12 +1937,15 @@ static s32 handle_get_statistics(struct wilc_vif *vif, if (stats != &vif->wilc->dummy_statistics) complete(&hif_wait_response); - return 0; + kfree(msg); + complete(&hif_thread_comp); } -static s32 handle_get_inactive_time(struct wilc_vif *vif, - struct sta_inactive_t *hif_sta_inactive) +static void handle_get_inactive_time(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct sta_inactive_t *hif_sta_inactive = &msg->body.mac_info; s32 result = 0; struct wid wid; struct host_if_drv *hif_drv = vif->hif_drv; @@ -1895,7 +1955,7 @@ static s32 handle_get_inactive_time(struct wilc_vif *vif, wid.size = ETH_ALEN; wid.val = kmalloc(wid.size, GFP_KERNEL); if (!wid.val) - return -ENOMEM; + goto out; ether_addr_copy(wid.val, hif_sta_inactive->mac); @@ -1905,7 +1965,7 @@ static s32 handle_get_inactive_time(struct wilc_vif *vif, if (result) { netdev_err(vif->ndev, "Failed to SET inactive time\n"); - return -EFAULT; + goto out; } wid.id = (u16)WID_GET_INACTIVE_TIME; @@ -1916,18 +1976,21 @@ static s32 handle_get_inactive_time(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to get inactive time\n"); - return -EFAULT; - } +out: complete(&hif_drv->comp_inactive_time); - return result; + kfree(msg); + complete(&hif_thread_comp); } -static void handle_add_beacon(struct wilc_vif *vif, struct beacon_attr *param) +static void handle_add_beacon(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct beacon_attr *param = &msg->body.beacon_info; s32 result = 0; struct wid wid; u8 *cur_byte; @@ -1976,10 +2039,14 @@ error: kfree(wid.val); kfree(param->head); kfree(param->tail); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_del_beacon(struct wilc_vif *vif) +static void handle_del_beacon(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; s32 result = 0; struct wid wid; u8 del_beacon = 0; @@ -1993,6 +2060,8 @@ static void handle_del_beacon(struct wilc_vif *vif) wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send delete beacon\n"); + kfree(msg); + complete(&hif_thread_comp); } static u32 wilc_hif_pack_sta_param(u8 *buff, struct add_sta_param *param) @@ -2025,9 +2094,11 @@ static u32 wilc_hif_pack_sta_param(u8 *buff, struct add_sta_param *param) return cur_byte - buff; } -static void handle_add_station(struct wilc_vif *vif, - struct add_sta_param *param) +static void handle_add_station(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct add_sta_param *param = &msg->body.add_sta_info; s32 result = 0; struct wid wid; u8 *cur_byte; @@ -2051,11 +2122,15 @@ static void handle_add_station(struct wilc_vif *vif, error: kfree(param->rates); kfree(wid.val); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_del_all_sta(struct wilc_vif *vif, - struct del_all_sta *param) +static void handle_del_all_sta(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct del_all_sta *param = &msg->body.del_all_sta_info; s32 result = 0; struct wid wid; u8 *curr_byte; @@ -2092,10 +2167,15 @@ error: kfree(wid.val); complete(&hif_wait_response); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_del_station(struct wilc_vif *vif, struct del_sta *param) +static void handle_del_station(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct del_sta *param = &msg->body.del_sta_info; s32 result = 0; struct wid wid; @@ -2116,11 +2196,15 @@ static void handle_del_station(struct wilc_vif *vif, struct del_sta *param) error: kfree(wid.val); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_edit_station(struct wilc_vif *vif, - struct add_sta_param *param) +static void handle_edit_station(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct add_sta_param *param = &msg->body.edit_sta_info; s32 result = 0; struct wid wid; u8 *cur_byte; @@ -2144,6 +2228,8 @@ static void handle_edit_station(struct wilc_vif *vif, error: kfree(param->rates); kfree(wid.val); + kfree(msg); + complete(&hif_thread_comp); } static int handle_remain_on_chan(struct wilc_vif *vif, @@ -2213,9 +2299,11 @@ error: return result; } -static int handle_register_frame(struct wilc_vif *vif, - struct reg_frame *hif_reg_frame) +static void handle_register_frame(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct reg_frame *hif_reg_frame = &msg->body.reg_frame; s32 result = 0; struct wid wid; u8 *cur_byte; @@ -2224,7 +2312,7 @@ static int handle_register_frame(struct wilc_vif *vif, wid.type = WID_STR; wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL); if (!wid.val) - return -ENOMEM; + goto out; cur_byte = wid.val; @@ -2237,17 +2325,19 @@ static int handle_register_frame(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(wid.val); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to frame register\n"); - result = -EINVAL; - } - return result; +out: + kfree(msg); + complete(&hif_thread_comp); } -static u32 handle_listen_state_expired(struct wilc_vif *vif, - struct remain_ch *hif_remain_ch) +static void handle_listen_state_expired(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct remain_ch *hif_remain_ch = &msg->body.remain_on_ch; u8 remain_on_chan_flag; struct wid wid; s32 result = 0; @@ -2261,7 +2351,7 @@ static u32 handle_listen_state_expired(struct wilc_vif *vif, wid.val = kmalloc(wid.size, GFP_KERNEL); if (!wid.val) - return -ENOMEM; + goto free_msg; wid.val[0] = remain_on_chan_flag; wid.val[1] = FALSE_FRMWR_CHANNEL; @@ -2271,7 +2361,7 @@ static u32 handle_listen_state_expired(struct wilc_vif *vif, kfree(wid.val); if (result != 0) { netdev_err(vif->ndev, "Failed to set remain channel\n"); - return result; + goto free_msg; } if (hif_drv->remain_on_ch.expired) { @@ -2281,10 +2371,11 @@ static u32 handle_listen_state_expired(struct wilc_vif *vif, p2p_listen_state = 0; } else { netdev_dbg(vif->ndev, "Not in listen state\n"); - result = -EFAULT; } - return result; +free_msg: + kfree(msg); + complete(&hif_thread_comp); } static void listen_timer_cb(struct timer_list *t) @@ -2298,7 +2389,7 @@ static void listen_timer_cb(struct timer_list *t) del_timer(&vif->hif_drv->remain_on_ch_timer); memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; + msg.fn = handle_listen_state_expired; msg.vif = vif; msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id; @@ -2307,9 +2398,11 @@ static void listen_timer_cb(struct timer_list *t) netdev_err(vif->ndev, "wilc_mq_send fail\n"); } -static void handle_power_management(struct wilc_vif *vif, - struct power_mgmt_param *pm_param) +static void handle_power_management(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct power_mgmt_param *pm_param = &msg->body.pwr_mgmt_info; s32 result = 0; struct wid wid; s8 power_mode; @@ -2328,11 +2421,15 @@ static void handle_power_management(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send power management\n"); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_set_mcast_filter(struct wilc_vif *vif, - struct set_multicast *hif_set_mc) +static void handle_set_mcast_filter(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct set_multicast *hif_set_mc = &msg->body.multicast_info; s32 result = 0; struct wid wid; u8 *cur_byte; @@ -2366,10 +2463,15 @@ static void handle_set_mcast_filter(struct wilc_vif *vif, error: kfree(wid.val); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr) +static void handle_set_tx_pwr(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + u8 tx_pwr = msg->body.tx_power.tx_pwr; int ret; struct wid wid; @@ -2382,10 +2484,15 @@ static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr) wilc_get_vif_idx(vif)); if (ret) netdev_err(vif->ndev, "Failed to set TX PWR\n"); + kfree(msg); + complete(&hif_thread_comp); } -static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr) +static void handle_get_tx_pwr(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + u8 *tx_pwr = &msg->body.tx_power.tx_pwr; int ret = 0; struct wid wid; @@ -2400,174 +2507,50 @@ static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr) netdev_err(vif->ndev, "Failed to get TX PWR\n"); complete(&hif_wait_response); + kfree(msg); + complete(&hif_thread_comp); } -static void host_if_work(struct work_struct *work) +static void handle_scan_timer(struct work_struct *work) { - struct host_if_msg *msg; - struct wilc *wilc; - int ret = 0; + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - msg = container_of(work, struct host_if_msg, work); - wilc = msg->vif->wilc; + handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); + kfree(msg); + complete(&hif_thread_comp); +} - if (msg->id == HOST_IF_MSG_CONNECT && - msg->vif->hif_drv->usr_scan_req.scan_result) { - wilc_enqueue_cmd(msg); - usleep_range(2 * 1000, 2 * 1000); - goto free_msg; - } - switch (msg->id) { - case HOST_IF_MSG_SCAN: - handle_scan(msg->vif, &msg->body.scan_info); - break; +static void handle_remain_on_chan_work(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - case HOST_IF_MSG_CONNECT: - handle_connect(msg->vif, &msg->body.con_info); - break; + handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch); + kfree(msg); + complete(&hif_thread_comp); +} - case HOST_IF_MSG_RCVD_NTWRK_INFO: - handle_rcvd_ntwrk_info(msg->vif, &msg->body.net_info); - break; +static void handle_hif_exit_work(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: - handle_rcvd_gnrl_async_info(msg->vif, - &msg->body.async_info); - break; + kfree(msg); + complete(&hif_thread_comp); +} - case HOST_IF_MSG_KEY: - handle_key(msg->vif, &msg->body.key_info); - break; +static void handle_scan_complete(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc *wilc = msg->vif->wilc; - case HOST_IF_MSG_CFG_PARAMS: - handle_cfg_param(msg->vif, &msg->body.cfg_info); - break; + del_timer(&msg->vif->hif_drv->scan_timer); - case HOST_IF_MSG_SET_CHANNEL: - handle_set_channel(msg->vif, &msg->body.channel_info); - break; + if (!wilc_wlan_get_num_conn_ifcs(wilc)) + wilc_chip_sleep_manually(wilc); - case HOST_IF_MSG_DISCONNECT: - handle_disconnect(msg->vif); - break; + handle_scan_done(msg->vif, SCAN_EVENT_DONE); - case HOST_IF_MSG_RCVD_SCAN_COMPLETE: - del_timer(&msg->vif->hif_drv->scan_timer); - - if (!wilc_wlan_get_num_conn_ifcs(wilc)) - wilc_chip_sleep_manually(wilc); - - handle_scan_done(msg->vif, SCAN_EVENT_DONE); - - if (msg->vif->hif_drv->remain_on_ch_pending) - handle_remain_on_chan(msg->vif, - &msg->body.remain_on_ch); - - break; - - case HOST_IF_MSG_GET_RSSI: - handle_get_rssi(msg->vif); - break; - - case HOST_IF_MSG_GET_STATISTICS: - handle_get_statistics(msg->vif, - (struct rf_info *)msg->body.data); - break; - - case HOST_IF_MSG_ADD_BEACON: - handle_add_beacon(msg->vif, &msg->body.beacon_info); - break; - - case HOST_IF_MSG_DEL_BEACON: - handle_del_beacon(msg->vif); - break; - - case HOST_IF_MSG_ADD_STATION: - handle_add_station(msg->vif, &msg->body.add_sta_info); - break; - - case HOST_IF_MSG_DEL_STATION: - handle_del_station(msg->vif, &msg->body.del_sta_info); - break; - - case HOST_IF_MSG_EDIT_STATION: - handle_edit_station(msg->vif, &msg->body.edit_sta_info); - break; - - case HOST_IF_MSG_GET_INACTIVETIME: - handle_get_inactive_time(msg->vif, &msg->body.mac_info); - break; - - case HOST_IF_MSG_SCAN_TIMER_FIRED: - handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); - break; - - case HOST_IF_MSG_CONNECT_TIMER_FIRED: - handle_connect_timeout(msg->vif); - break; - - case HOST_IF_MSG_POWER_MGMT: - handle_power_management(msg->vif, - &msg->body.pwr_mgmt_info); - break; - - case HOST_IF_MSG_SET_WFIDRV_HANDLER: - ret = handle_set_wfi_drv_handler(msg->vif, &msg->body.drv); - break; - - case HOST_IF_MSG_SET_OPERATION_MODE: - handle_set_operation_mode(msg->vif, &msg->body.mode); - break; - - case HOST_IF_MSG_SET_IPADDRESS: - handle_set_ip_address(msg->vif, - msg->body.ip_info.ip_addr, - msg->body.ip_info.idx); - break; - - case HOST_IF_MSG_GET_IPADDRESS: - handle_get_ip_address(msg->vif, msg->body.ip_info.idx); - break; - - case HOST_IF_MSG_GET_MAC_ADDRESS: - handle_get_mac_address(msg->vif, - &msg->body.get_mac_info); - break; - - case HOST_IF_MSG_REMAIN_ON_CHAN: + if (msg->vif->hif_drv->remain_on_ch_pending) handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch); - break; - - case HOST_IF_MSG_REGISTER_FRAME: - handle_register_frame(msg->vif, &msg->body.reg_frame); - break; - - case HOST_IF_MSG_LISTEN_TIMER_FIRED: - handle_listen_state_expired(msg->vif, &msg->body.remain_on_ch); - break; - - case HOST_IF_MSG_SET_MULTICAST_FILTER: - handle_set_mcast_filter(msg->vif, &msg->body.multicast_info); - break; - - case HOST_IF_MSG_DEL_ALL_STA: - handle_del_all_sta(msg->vif, &msg->body.del_all_sta_info); - break; - - case HOST_IF_MSG_SET_TX_POWER: - handle_set_tx_pwr(msg->vif, msg->body.tx_power.tx_pwr); - break; - - case HOST_IF_MSG_GET_TX_POWER: - handle_get_tx_pwr(msg->vif, &msg->body.tx_power.tx_pwr); - break; - default: - netdev_err(msg->vif->ndev, "[Host Interface] undefined\n"); - break; - } -free_msg: - if (ret) - netdev_err(msg->vif->ndev, "Host cmd %d failed\n", msg->id); kfree(msg); complete(&hif_thread_comp); } @@ -2580,7 +2563,7 @@ static void timer_scan_cb(struct timer_list *t) memset(&msg, 0, sizeof(struct host_if_msg)); msg.vif = vif; - msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED; + msg.fn = handle_scan_timer; wilc_enqueue_cmd(&msg); } @@ -2594,7 +2577,7 @@ static void timer_connect_cb(struct timer_list *t) memset(&msg, 0, sizeof(struct host_if_msg)); msg.vif = vif; - msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED; + msg.fn = handle_connect_timeout; wilc_enqueue_cmd(&msg); } @@ -2613,7 +2596,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_KEY; + msg.fn = handle_key; msg.body.key_info.type = WEP; msg.body.key_info.action = REMOVEKEY; msg.vif = vif; @@ -2642,7 +2625,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_KEY; + msg.fn = handle_key; msg.body.key_info.type = WEP; msg.body.key_info.action = DEFAULTKEY; msg.vif = vif; @@ -2671,7 +2654,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_KEY; + msg.fn = handle_key; msg.body.key_info.type = WEP; msg.body.key_info.action = ADDKEY; msg.vif = vif; @@ -2707,7 +2690,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_KEY; + msg.fn = handle_key; msg.body.key_info.type = WEP; msg.body.key_info.action = ADDKEY_AP; msg.vif = vif; @@ -2753,7 +2736,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_KEY; + msg.fn = handle_key; msg.body.key_info.type = WPA_PTK; if (mode == AP_MODE) { msg.body.key_info.action = ADDKEY_AP; @@ -2820,7 +2803,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, return -ENOMEM; } - msg.id = HOST_IF_MSG_KEY; + msg.fn = handle_key; msg.body.key_info.type = WPA_RX_GTK; msg.vif = vif; @@ -2872,7 +2855,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_KEY; + msg.fn = handle_key; msg.body.key_info.type = PMKSA; msg.body.key_info.action = ADDKEY; msg.vif = vif; @@ -2898,7 +2881,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_GET_MAC_ADDRESS; + msg.fn = handle_get_mac_address; msg.body.get_mac_info.mac_addr = mac_addr; msg.vif = vif; @@ -2934,8 +2917,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_CONNECT; - + msg.fn = handle_connect; msg.body.con_info.security = security; msg.body.con_info.auth_type = auth_type; msg.body.con_info.ch = channel; @@ -2992,7 +2974,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_DISCONNECT; + msg.fn = handle_disconnect; msg.vif = vif; result = wilc_enqueue_cmd(&msg); @@ -3035,7 +3017,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) struct host_if_msg msg; memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SET_CHANNEL; + msg.fn = handle_set_channel; msg.body.channel_info.set_ch = channel; msg.vif = vif; @@ -3055,7 +3037,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, struct host_if_msg msg; memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER; + msg.fn = handle_set_wfi_drv_handler; msg.body.drv.handler = index; msg.body.drv.mode = mode; msg.body.drv.name = ifc_id; @@ -3076,7 +3058,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) struct host_if_msg msg; memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SET_OPERATION_MODE; + msg.fn = handle_set_operation_mode; msg.body.mode.mode = mode; msg.vif = vif; @@ -3104,7 +3086,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, memset(&msg, 0, sizeof(struct host_if_msg)); memcpy(msg.body.mac_info.mac, mac, ETH_ALEN); - msg.id = HOST_IF_MSG_GET_INACTIVETIME; + msg.fn = handle_get_inactive_time; msg.vif = vif; result = wilc_enqueue_cmd(&msg); @@ -3125,7 +3107,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) struct host_if_drv *hif_drv = vif->hif_drv; memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_GET_RSSI; + msg.fn = handle_get_rssi; msg.vif = vif; result = wilc_enqueue_cmd(&msg); @@ -3152,7 +3134,7 @@ int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) struct host_if_msg msg; memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_GET_STATISTICS; + msg.fn = handle_get_statistics; msg.body.data = (char *)stats; msg.vif = vif; @@ -3184,7 +3166,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SCAN; + msg.fn = handle_scan; if (hidden_network) { scan_info->hidden_network.net_info = hidden_network->net_info; @@ -3234,7 +3216,7 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, } memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_CFG_PARAMS; + msg.fn = handle_cfg_param; msg.body.cfg_info = *cfg_param; msg.vif = vif; @@ -3364,7 +3346,7 @@ int wilc_deinit(struct wilc_vif *vif) memset(&msg, 0, sizeof(struct host_if_msg)); if (clients_count == 1) { - msg.id = HOST_IF_MSG_EXIT; + msg.fn = handle_hif_exit_work; msg.vif = vif; result = wilc_enqueue_cmd(&msg); @@ -3408,7 +3390,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO; + msg.fn = handle_rcvd_ntwrk_info; msg.vif = vif; msg.body.net_info.len = length; @@ -3458,7 +3440,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO; + msg.fn = handle_rcvd_gnrl_async_info; msg.vif = vif; msg.body.async_info.len = length; @@ -3500,7 +3482,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) if (hif_drv->usr_scan_req.scan_result) { memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE; + msg.fn = handle_scan_complete; msg.vif = vif; result = wilc_enqueue_cmd(&msg); @@ -3520,7 +3502,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_REMAIN_ON_CHAN; + msg.fn = handle_remain_on_chan_work; msg.body.remain_on_ch.ch = chan; msg.body.remain_on_ch.expired = expired; msg.body.remain_on_ch.ready = ready; @@ -3550,7 +3532,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) del_timer(&hif_drv->remain_on_ch_timer); memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; + msg.fn = handle_listen_state_expired; msg.vif = vif; msg.body.remain_on_ch.id = session_id; @@ -3568,7 +3550,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_REGISTER_FRAME; + msg.fn = handle_register_frame; switch (frame_type) { case ACTION: msg.body.reg_frame.reg_id = ACTION_FRM_IDX; @@ -3601,7 +3583,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_ADD_BEACON; + msg.fn = handle_add_beacon; msg.vif = vif; beacon_info->interval = interval; beacon_info->dtim_period = dtim_period; @@ -3642,7 +3624,7 @@ int wilc_del_beacon(struct wilc_vif *vif) int result = 0; struct host_if_msg msg; - msg.id = HOST_IF_MSG_DEL_BEACON; + msg.fn = handle_del_beacon; msg.vif = vif; result = wilc_enqueue_cmd(&msg); @@ -3660,7 +3642,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_ADD_STATION; + msg.fn = handle_add_station; msg.vif = vif; memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param)); @@ -3688,7 +3670,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_DEL_STATION; + msg.fn = handle_del_station; msg.vif = vif; if (!mac_addr) @@ -3713,7 +3695,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_DEL_ALL_STA; + msg.fn = handle_del_all_sta; msg.vif = vif; for (i = 0; i < MAX_NUM_STA; i++) { @@ -3746,7 +3728,7 @@ int wilc_edit_station(struct wilc_vif *vif, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_EDIT_STATION; + msg.fn = handle_edit_station; msg.vif = vif; memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param)); @@ -3778,7 +3760,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_POWER_MGMT; + msg.fn = handle_power_management; msg.vif = vif; pwr_mgmt_info->enabled = enabled; @@ -3799,7 +3781,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER; + msg.fn = handle_set_mcast_filter; msg.vif = vif; multicast_filter_param->enabled = enabled; @@ -3983,7 +3965,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SET_IPADDRESS; + msg.fn = handle_set_ip_address; msg.body.ip_info.ip_addr = ip_addr; msg.vif = vif; @@ -4003,7 +3985,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_GET_IPADDRESS; + msg.fn = handle_get_ip_address; msg.body.ip_info.ip_addr = ip_addr; msg.vif = vif; @@ -4023,7 +4005,7 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SET_TX_POWER; + msg.fn = handle_set_tx_pwr; msg.body.tx_power.tx_pwr = tx_power; msg.vif = vif; @@ -4041,7 +4023,7 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_GET_TX_POWER; + msg.fn = handle_get_tx_pwr; msg.vif = vif; ret = wilc_enqueue_cmd(&msg); From 02f08321d0bbf64ffcd709ec664bac0f0ec6b3d8 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:04 +0530 Subject: [PATCH 152/903] staging: wilc1000: remove unused marco related to HIF commands After removing the multiplexing of hif commands in hif_if_work() macros prefix with 'HOST_IF_MSG_' are not required. Also 'id' field in host_if_msg is not required anymore. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 36 ----------------------- 1 file changed, 36 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 4f6008e6bf32..998e0abc4442 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1,41 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "wilc_wfi_netdevice.h" -#define HOST_IF_MSG_SCAN 0 -#define HOST_IF_MSG_CONNECT 1 -#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2 -#define HOST_IF_MSG_KEY 3 -#define HOST_IF_MSG_RCVD_NTWRK_INFO 4 -#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5 -#define HOST_IF_MSG_CFG_PARAMS 6 -#define HOST_IF_MSG_SET_CHANNEL 7 -#define HOST_IF_MSG_DISCONNECT 8 -#define HOST_IF_MSG_GET_RSSI 9 -#define HOST_IF_MSG_ADD_BEACON 11 -#define HOST_IF_MSG_DEL_BEACON 12 -#define HOST_IF_MSG_ADD_STATION 13 -#define HOST_IF_MSG_DEL_STATION 14 -#define HOST_IF_MSG_EDIT_STATION 15 -#define HOST_IF_MSG_SCAN_TIMER_FIRED 16 -#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17 -#define HOST_IF_MSG_POWER_MGMT 18 -#define HOST_IF_MSG_GET_INACTIVETIME 19 -#define HOST_IF_MSG_REMAIN_ON_CHAN 20 -#define HOST_IF_MSG_REGISTER_FRAME 21 -#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22 -#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24 -#define HOST_IF_MSG_GET_MAC_ADDRESS 26 -#define HOST_IF_MSG_SET_OPERATION_MODE 27 -#define HOST_IF_MSG_SET_IPADDRESS 28 -#define HOST_IF_MSG_GET_IPADDRESS 29 -#define HOST_IF_MSG_GET_STATISTICS 31 -#define HOST_IF_MSG_SET_MULTICAST_FILTER 32 -#define HOST_IF_MSG_DEL_BA_SESSION 34 -#define HOST_IF_MSG_DEL_ALL_STA 36 -#define HOST_IF_MSG_SET_TX_POWER 38 -#define HOST_IF_MSG_GET_TX_POWER 39 -#define HOST_IF_MSG_EXIT 100 - #define HOST_IF_SCAN_TIMEOUT 4000 #define HOST_IF_CONNECT_TIMEOUT 9500 @@ -180,7 +145,6 @@ union message_body { }; struct host_if_msg { - u16 id; union message_body body; struct wilc_vif *vif; struct work_struct work; From ff52a57a7a4237ad5e089d32c7d621a68f4a7610 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:05 +0530 Subject: [PATCH 153/903] staging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd() Instead of allocating the host_if_cmd in wilc_enqueue_cmd() now moved the allocation of cmd in the caller. Added the NULL check for 'hif_workqueue' before posting the work queue in wilc_enqueue_cmd(). Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 951 +++++++++++++--------- 1 file changed, 548 insertions(+), 403 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 998e0abc4442..cb627b0fa287 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -205,6 +205,23 @@ static void *host_int_parse_join_bss_param(struct network_info *info); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt); +static struct host_if_msg* +wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *)) +{ + struct host_if_msg *msg; + + if (!work_fun) + return ERR_PTR(-EINVAL); + + msg = kzalloc(sizeof(*msg), GFP_ATOMIC); + if (!msg) + return ERR_PTR(-ENOMEM); + msg->fn = work_fun; + msg->vif = vif; + + return msg; +} + /*! * @author syounan * @date 1 Sep 2010 @@ -213,14 +230,10 @@ static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt); */ static int wilc_enqueue_cmd(struct host_if_msg *msg) { - struct host_if_msg *new_msg; + INIT_WORK(&msg->work, msg->fn); + if (!hif_workqueue || !queue_work(hif_workqueue, &msg->work)) + return -EINVAL; - new_msg = kmemdup(msg, sizeof(*new_msg), GFP_ATOMIC); - if (!new_msg) - return -ENOMEM; - - INIT_WORK(&new_msg->work, msg->fn); - queue_work(hif_workqueue, &new_msg->work); return 0; } @@ -896,8 +909,8 @@ static void handle_connect(struct work_struct *work) result = wilc_enqueue_cmd(msg); if (result) goto error; + usleep_range(2 * 1000, 2 * 1000); - kfree(msg); return; } @@ -2348,18 +2361,21 @@ static void listen_timer_cb(struct timer_list *t) remain_on_ch_timer); struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif; s32 result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; del_timer(&vif->hif_drv->remain_on_ch_timer); - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_listen_state_expired; - msg.vif = vif; - msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id; + msg = wilc_alloc_work(vif, handle_listen_state_expired); + if (IS_ERR(msg)) + return; - result = wilc_enqueue_cmd(&msg); - if (result) + msg->body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id; + + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } } static void handle_power_management(struct work_struct *work) @@ -2452,6 +2468,7 @@ static void handle_set_tx_pwr(struct work_struct *work) complete(&hif_thread_comp); } +/* Note: 'msg' will be free after using data */ static void handle_get_tx_pwr(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -2471,7 +2488,6 @@ static void handle_get_tx_pwr(struct work_struct *work) netdev_err(vif->ndev, "Failed to get TX PWR\n"); complete(&hif_wait_response); - kfree(msg); complete(&hif_thread_comp); } @@ -2523,13 +2539,16 @@ static void timer_scan_cb(struct timer_list *t) { struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer); struct wilc_vif *vif = hif_drv->scan_timer_vif; - struct host_if_msg msg; + struct host_if_msg *msg; + int result; - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.vif = vif; - msg.fn = handle_scan_timer; + msg = wilc_alloc_work(vif, handle_scan_timer); + if (IS_ERR(msg)) + return; - wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); + if (result) + kfree(msg); } static void timer_connect_cb(struct timer_list *t) @@ -2537,19 +2556,22 @@ static void timer_connect_cb(struct timer_list *t) struct host_if_drv *hif_drv = from_timer(hif_drv, t, connect_timer); struct wilc_vif *vif = hif_drv->connect_timer_vif; - struct host_if_msg msg; + struct host_if_msg *msg; + int result; - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.vif = vif; - msg.fn = handle_connect_timeout; + msg = wilc_alloc_work(vif, handle_connect_timeout); + if (IS_ERR(msg)) + return; - wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); + if (result) + kfree(msg); } int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -2558,19 +2580,21 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) return result; } - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_key); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_key; - msg.body.key_info.type = WEP; - msg.body.key_info.action = REMOVEKEY; - msg.vif = vif; - msg.body.key_info.attr.wep.index = index; + msg->body.key_info.type = WEP; + msg->body.key_info.action = REMOVEKEY; + msg->body.key_info.attr.wep.index = index; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "Request to remove WEP key\n"); - else + kfree(msg); + } else { wait_for_completion(&hif_drv->comp_test_key_block); + } return result; } @@ -2578,7 +2602,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -2587,19 +2611,21 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) return result; } - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_key); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_key; - msg.body.key_info.type = WEP; - msg.body.key_info.action = DEFAULTKEY; - msg.vif = vif; - msg.body.key_info.attr.wep.index = index; + msg->body.key_info.type = WEP; + msg->body.key_info.action = DEFAULTKEY; + msg->body.key_info.attr.wep.index = index; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "Default key index\n"); - else + kfree(msg); + } else { wait_for_completion(&hif_drv->comp_test_key_block); + } return result; } @@ -2608,7 +2634,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, u8 index) { int result; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -2616,35 +2642,41 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_key); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_key; - msg.body.key_info.type = WEP; - msg.body.key_info.action = ADDKEY; - msg.vif = vif; - msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); - if (!msg.body.key_info.attr.wep.key) - return -ENOMEM; - - msg.body.key_info.attr.wep.key_len = len; - msg.body.key_info.attr.wep.index = index; - - result = wilc_enqueue_cmd(&msg); - if (result) { - netdev_err(vif->ndev, "STA - WEP Key\n"); - kfree(msg.body.key_info.attr.wep.key); - return result; + msg->body.key_info.type = WEP; + msg->body.key_info.action = ADDKEY; + msg->body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); + if (!msg->body.key_info.attr.wep.key) { + result = -ENOMEM; + goto free_msg; } + msg->body.key_info.attr.wep.key_len = len; + msg->body.key_info.attr.wep.index = index; + + result = wilc_enqueue_cmd(msg); + if (result) + goto free_key; + wait_for_completion(&hif_drv->comp_test_key_block); return 0; + +free_key: + kfree(msg->body.key_info.attr.wep.key); + +free_msg: + kfree(msg); + return result; } int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, u8 index, u8 mode, enum AUTHTYPE auth_type) { int result; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -2652,30 +2684,36 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_key); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_key; - msg.body.key_info.type = WEP; - msg.body.key_info.action = ADDKEY_AP; - msg.vif = vif; - msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); - if (!msg.body.key_info.attr.wep.key) - return -ENOMEM; - - msg.body.key_info.attr.wep.key_len = len; - msg.body.key_info.attr.wep.index = index; - msg.body.key_info.attr.wep.mode = mode; - msg.body.key_info.attr.wep.auth_type = auth_type; - - result = wilc_enqueue_cmd(&msg); - if (result) { - netdev_err(vif->ndev, "AP - WEP Key\n"); - kfree(msg.body.key_info.attr.wep.key); - return result; + msg->body.key_info.type = WEP; + msg->body.key_info.action = ADDKEY_AP; + msg->body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); + if (!msg->body.key_info.attr.wep.key) { + result = -ENOMEM; + goto free_msg; } + msg->body.key_info.attr.wep.key_len = len; + msg->body.key_info.attr.wep.index = index; + msg->body.key_info.attr.wep.mode = mode; + msg->body.key_info.attr.wep.auth_type = auth_type; + + result = wilc_enqueue_cmd(msg); + if (result) + goto free_key; + wait_for_completion(&hif_drv->comp_test_key_block); return 0; + +free_key: + kfree(msg->body.key_info.attr.wep.key); + +free_msg: + kfree(msg); + return result; } int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, @@ -2683,7 +2721,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, u8 mode, u8 cipher_mode, u8 index) { int result; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; u8 key_len = ptk_key_len; @@ -2698,43 +2736,51 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, if (tx_mic) key_len += TX_MIC_KEY_LEN; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_key); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_key; - msg.body.key_info.type = WPA_PTK; + msg->body.key_info.type = WPA_PTK; if (mode == AP_MODE) { - msg.body.key_info.action = ADDKEY_AP; - msg.body.key_info.attr.wpa.index = index; + msg->body.key_info.action = ADDKEY_AP; + msg->body.key_info.attr.wpa.index = index; } if (mode == STATION_MODE) - msg.body.key_info.action = ADDKEY; + msg->body.key_info.action = ADDKEY; - msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL); - if (!msg.body.key_info.attr.wpa.key) - return -ENOMEM; + msg->body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL); + if (!msg->body.key_info.attr.wpa.key) { + result = -ENOMEM; + goto free_msg; + } if (rx_mic) - memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, + memcpy(msg->body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN); if (tx_mic) - memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, + memcpy(msg->body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN); - msg.body.key_info.attr.wpa.key_len = key_len; - msg.body.key_info.attr.wpa.mac_addr = mac_addr; - msg.body.key_info.attr.wpa.mode = cipher_mode; - msg.vif = vif; + msg->body.key_info.attr.wpa.key_len = key_len; + msg->body.key_info.attr.wpa.mac_addr = mac_addr; + msg->body.key_info.attr.wpa.mode = cipher_mode; - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "PTK Key\n"); - kfree(msg.body.key_info.attr.wpa.key); - return result; + goto free_key; } wait_for_completion(&hif_drv->comp_test_key_block); return 0; + +free_key: + kfree(msg->body.key_info.attr.wpa.key); + +free_msg: + kfree(msg); + return result; } int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, @@ -2743,7 +2789,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, u8 cipher_mode) { int result; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; u8 key_len = gtk_key_len; @@ -2751,7 +2797,10 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); + + msg = wilc_alloc_work(vif, handle_key); + if (IS_ERR(msg)) + return PTR_ERR(msg); if (rx_mic) key_len += RX_MIC_KEY_LEN; @@ -2760,80 +2809,88 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, key_len += TX_MIC_KEY_LEN; if (key_rsc) { - msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc, - key_rsc_len, - GFP_KERNEL); - if (!msg.body.key_info.attr.wpa.seq) - return -ENOMEM; + msg->body.key_info.attr.wpa.seq = kmemdup(key_rsc, + key_rsc_len, + GFP_KERNEL); + if (!msg->body.key_info.attr.wpa.seq) { + result = -ENOMEM; + goto free_msg; + } } - msg.fn = handle_key; - msg.body.key_info.type = WPA_RX_GTK; - msg.vif = vif; + msg->body.key_info.type = WPA_RX_GTK; if (mode == AP_MODE) { - msg.body.key_info.action = ADDKEY_AP; - msg.body.key_info.attr.wpa.mode = cipher_mode; + msg->body.key_info.action = ADDKEY_AP; + msg->body.key_info.attr.wpa.mode = cipher_mode; } if (mode == STATION_MODE) - msg.body.key_info.action = ADDKEY; + msg->body.key_info.action = ADDKEY; - msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk, - key_len, - GFP_KERNEL); - if (!msg.body.key_info.attr.wpa.key) { - kfree(msg.body.key_info.attr.wpa.seq); - return -ENOMEM; + msg->body.key_info.attr.wpa.key = kmemdup(rx_gtk, key_len, GFP_KERNEL); + if (!msg->body.key_info.attr.wpa.key) { + result = -ENOMEM; + goto free_seq; } if (rx_mic) - memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, + memcpy(msg->body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN); if (tx_mic) - memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, + memcpy(msg->body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN); - msg.body.key_info.attr.wpa.index = index; - msg.body.key_info.attr.wpa.key_len = key_len; - msg.body.key_info.attr.wpa.seq_len = key_rsc_len; + msg->body.key_info.attr.wpa.index = index; + msg->body.key_info.attr.wpa.key_len = key_len; + msg->body.key_info.attr.wpa.seq_len = key_rsc_len; - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "RX GTK\n"); - kfree(msg.body.key_info.attr.wpa.seq); - kfree(msg.body.key_info.attr.wpa.key); - return result; + goto free_key; } wait_for_completion(&hif_drv->comp_test_key_block); return 0; + +free_key: + kfree(msg->body.key_info.attr.wpa.key); + +free_seq: + kfree(msg->body.key_info.attr.wpa.seq); + +free_msg: + kfree(msg); + return result; } int wilc_set_pmkid_info(struct wilc_vif *vif, struct host_if_pmkid_attr *pmkid) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; int i; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_key); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_key; - msg.body.key_info.type = PMKSA; - msg.body.key_info.action = ADDKEY; - msg.vif = vif; + msg->body.key_info.type = PMKSA; + msg->body.key_info.action = ADDKEY; for (i = 0; i < pmkid->numpmkid; i++) { - memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, + memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].bssid, &pmkid->pmkidlist[i].bssid, ETH_ALEN); - memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, + memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pmkid->pmkidlist[i].pmkid, PMKID_LEN); } - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "PMKID Info\n"); + kfree(msg); + } return result; } @@ -2841,17 +2898,18 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_get_mac_address); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_get_mac_address; - msg.body.get_mac_info.mac_addr = mac_addr; - msg.vif = vif; + msg->body.get_mac_info.mac_addr = mac_addr; - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "Failed to send get mac address\n"); + kfree(msg); return -EFAULT; } @@ -2866,7 +2924,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, u8 channel, void *join_params) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv || !connect_result) { @@ -2879,56 +2937,75 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_connect); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_connect; - msg.body.con_info.security = security; - msg.body.con_info.auth_type = auth_type; - msg.body.con_info.ch = channel; - msg.body.con_info.result = connect_result; - msg.body.con_info.arg = user_arg; - msg.body.con_info.params = join_params; - msg.vif = vif; + msg->body.con_info.security = security; + msg->body.con_info.auth_type = auth_type; + msg->body.con_info.ch = channel; + msg->body.con_info.result = connect_result; + msg->body.con_info.arg = user_arg; + msg->body.con_info.params = join_params; if (bssid) { - msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL); - if (!msg.body.con_info.bssid) - return -ENOMEM; + msg->body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL); + if (!msg->body.con_info.bssid) { + result = -ENOMEM; + goto free_msg; + } } if (ssid) { - msg.body.con_info.ssid_len = ssid_len; - msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL); - if (!msg.body.con_info.ssid) - return -ENOMEM; + msg->body.con_info.ssid_len = ssid_len; + msg->body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL); + if (!msg->body.con_info.ssid) { + result = -ENOMEM; + goto free_bssid; + } } if (ies) { - msg.body.con_info.ies_len = ies_len; - msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!msg.body.con_info.ies) - return -ENOMEM; + msg->body.con_info.ies_len = ies_len; + msg->body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!msg->body.con_info.ies) { + result = -ENOMEM; + goto free_ssid; + } } if (hif_drv->hif_state < HOST_IF_CONNECTING) hif_drv->hif_state = HOST_IF_CONNECTING; - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "send message: Set join request\n"); - return -EFAULT; + goto free_ies; } hif_drv->connect_timer_vif = vif; mod_timer(&hif_drv->connect_timer, jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT)); + return 0; + +free_ies: + kfree(msg->body.con_info.ies); + +free_ssid: + kfree(msg->body.con_info.ssid); + +free_bssid: + kfree(msg->body.con_info.bssid); + +free_msg: + kfree(msg); return result; } int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -2936,16 +3013,17 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_disconnect); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_disconnect; - msg.vif = vif; - - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "Failed to send message: disconnect\n"); - else + kfree(msg); + } else { wait_for_completion(&hif_drv->comp_test_disconn_block); + } return result; } @@ -2978,39 +3056,41 @@ static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) { int result; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_set_channel; - msg.body.channel_info.set_ch = channel; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_set_channel); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); + msg->body.channel_info.set_ch = channel; + + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); - return -EINVAL; + kfree(msg); } - return 0; + return result; } int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, u8 ifc_id) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_set_wfi_drv_handler; - msg.body.drv.handler = index; - msg.body.drv.mode = mode; - msg.body.drv.name = ifc_id; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_set_wfi_drv_handler); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); + msg->body.drv.handler = index; + msg->body.drv.mode = mode; + msg->body.drv.name = ifc_id; + + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); - result = -EINVAL; + kfree(msg); } return result; @@ -3019,17 +3099,17 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_set_operation_mode; - msg.body.mode.mode = mode; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_set_operation_mode); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); + msg->body.mode.mode = mode; + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); - result = -EINVAL; + kfree(msg); } return result; @@ -3039,7 +3119,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) { s32 result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -3047,17 +3127,19 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); - memcpy(msg.body.mac_info.mac, mac, ETH_ALEN); + msg = wilc_alloc_work(vif, handle_get_inactive_time); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_get_inactive_time; - msg.vif = vif; + memcpy(msg->body.mac_info.mac, mac, ETH_ALEN); - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "Failed to send get host ch param\n"); - else + kfree(msg); + } else { wait_for_completion(&hif_drv->comp_inactive_time); + } *out_val = inactive_time; @@ -3067,17 +3149,18 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_get_rssi; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_get_rssi); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "Failed to send get host ch param\n"); - return -EFAULT; + kfree(msg); + return result; } wait_for_completion(&hif_drv->comp_get_rssi); @@ -3095,17 +3178,19 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_get_statistics; - msg.body.data = (char *)stats; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_get_statistics); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); + msg->body.data = (char *)stats; + + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "Failed to send get host channel\n"); - return -EFAULT; + kfree(msg); + return result; } if (stats != &vif->wilc->dummy_statistics) @@ -3119,8 +3204,8 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, struct hidden_network *hidden_network) { int result = 0; - struct host_if_msg msg; - struct scan_attr *scan_info = &msg.body.scan_info; + struct host_if_msg *msg; + struct scan_attr *scan_info; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv || !scan_result) { @@ -3128,16 +3213,17 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_scan); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_scan; + scan_info = &msg->body.scan_info; if (hidden_network) { scan_info->hidden_network.net_info = hidden_network->net_info; scan_info->hidden_network.n_ssids = hidden_network->n_ssids; } - msg.vif = vif; scan_info->src = scan_source; scan_info->type = scan_type; scan_info->result = scan_result; @@ -3147,44 +3233,63 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, scan_info->ch_freq_list = kmemdup(ch_freq_list, ch_list_len, GFP_KERNEL); - if (!scan_info->ch_freq_list) - return -ENOMEM; + if (!scan_info->ch_freq_list) { + result = -ENOMEM; + goto free_msg; + } scan_info->ies_len = ies_len; scan_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!scan_info->ies) - return -ENOMEM; + if (!scan_info->ies) { + result = -ENOMEM; + goto free_freq_list; + } - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "Error in sending message queue\n"); - return -EINVAL; + goto free_ies; } hif_drv->scan_timer_vif = vif; mod_timer(&hif_drv->scan_timer, jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT)); + return 0; + +free_ies: + kfree(scan_info->ies); + +free_freq_list: + kfree(scan_info->ch_freq_list); + +free_msg: + kfree(msg); return result; } int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *cfg_param) { - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; + int result; if (!hif_drv) { netdev_err(vif->ndev, "hif_drv NULL\n"); return -EFAULT; } - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_cfg_param; - msg.body.cfg_info = *cfg_param; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_cfg_param); + if (IS_ERR(msg)) + return PTR_ERR(msg); - return wilc_enqueue_cmd(&msg); + msg->body.cfg_info = *cfg_param; + result = wilc_enqueue_cmd(msg); + if (result) + kfree(msg); + + return result; } static void get_periodic_rssi(struct timer_list *unused) @@ -3278,7 +3383,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) int wilc_deinit(struct wilc_vif *vif) { int result = 0; - struct host_if_msg msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -3307,14 +3411,15 @@ int wilc_deinit(struct wilc_vif *vif) hif_drv->hif_state = HOST_IF_IDLE; - memset(&msg, 0, sizeof(struct host_if_msg)); - if (clients_count == 1) { - msg.fn = handle_hif_exit_work; - msg.vif = vif; + struct host_if_msg *msg; - result = wilc_enqueue_cmd(&msg); - if (result != 0) + msg = wilc_alloc_work(vif, handle_hif_exit_work); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + result = wilc_enqueue_cmd(msg); + if (result) netdev_err(vif->ndev, "deinit : Error(%d)\n", result); else wait_for_completion(&hif_thread_comp); @@ -3333,7 +3438,7 @@ int wilc_deinit(struct wilc_vif *vif) void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) { s32 result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; int id; struct host_if_drv *hif_drv = NULL; struct wilc_vif *vif; @@ -3352,27 +3457,29 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - memset(&msg, 0, sizeof(struct host_if_msg)); - - msg.fn = handle_rcvd_ntwrk_info; - msg.vif = vif; - - msg.body.net_info.len = length; - msg.body.net_info.buffer = kmemdup(buffer, length, GFP_KERNEL); - if (!msg.body.net_info.buffer) + msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info); + if (IS_ERR(msg)) return; - result = wilc_enqueue_cmd(&msg); + msg->body.net_info.len = length; + msg->body.net_info.buffer = kmemdup(buffer, length, GFP_KERNEL); + if (!msg->body.net_info.buffer) { + kfree(msg); + return; + } + + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "message parameters (%d)\n", result); - kfree(msg.body.net_info.buffer); + kfree(msg->body.net_info.buffer); + kfree(msg); } } void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) { s32 result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; int id; struct host_if_drv *hif_drv = NULL; struct wilc_vif *vif; @@ -3402,22 +3509,25 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - memset(&msg, 0, sizeof(struct host_if_msg)); - - msg.fn = handle_rcvd_gnrl_async_info; - msg.vif = vif; - - msg.body.async_info.len = length; - msg.body.async_info.buffer = kmemdup(buffer, length, GFP_KERNEL); - if (!msg.body.async_info.buffer) { + msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info); + if (IS_ERR(msg)) { mutex_unlock(&hif_deinit_lock); return; } - result = wilc_enqueue_cmd(&msg); + msg->body.async_info.len = length; + msg->body.async_info.buffer = kmemdup(buffer, length, GFP_KERNEL); + if (!msg->body.async_info.buffer) { + kfree(msg); + mutex_unlock(&hif_deinit_lock); + return; + } + + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "synchronous info (%d)\n", result); - kfree(msg.body.async_info.buffer); + kfree(msg->body.async_info.buffer); + kfree(msg); } mutex_unlock(&hif_deinit_lock); @@ -3426,7 +3536,6 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) { s32 result = 0; - struct host_if_msg msg; int id; struct host_if_drv *hif_drv = NULL; struct wilc_vif *vif; @@ -3444,14 +3553,17 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) return; if (hif_drv->usr_scan_req.scan_result) { - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; - msg.fn = handle_scan_complete; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_scan_complete); + if (IS_ERR(msg)) + return; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "complete param (%d)\n", result); + kfree(msg); + } } } @@ -3462,22 +3574,24 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, void *user_arg) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_remain_on_chan_work); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_remain_on_chan_work; - msg.body.remain_on_ch.ch = chan; - msg.body.remain_on_ch.expired = expired; - msg.body.remain_on_ch.ready = ready; - msg.body.remain_on_ch.arg = user_arg; - msg.body.remain_on_ch.duration = duration; - msg.body.remain_on_ch.id = session_id; - msg.vif = vif; + msg->body.remain_on_ch.ch = chan; + msg->body.remain_on_ch.expired = expired; + msg->body.remain_on_ch.ready = ready; + msg->body.remain_on_ch.arg = user_arg; + msg->body.remain_on_ch.duration = duration; + msg->body.remain_on_ch.id = session_id; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); + kfree(msg); + } return result; } @@ -3485,7 +3599,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { @@ -3495,14 +3609,17 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) del_timer(&hif_drv->remain_on_ch_timer); - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.fn = handle_listen_state_expired; - msg.vif = vif; - msg.body.remain_on_ch.id = session_id; + msg = wilc_alloc_work(vif, handle_listen_state_expired); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); - if (result) + msg->body.remain_on_ch.id = session_id; + + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); + kfree(msg); + } return result; } @@ -3510,30 +3627,32 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_register_frame); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_register_frame; switch (frame_type) { case ACTION: - msg.body.reg_frame.reg_id = ACTION_FRM_IDX; + msg->body.reg_frame.reg_id = ACTION_FRM_IDX; break; case PROBE_REQ: - msg.body.reg_frame.reg_id = PROBE_REQ_IDX; + msg->body.reg_frame.reg_id = PROBE_REQ_IDX; break; default: break; } - msg.body.reg_frame.frame_type = frame_type; - msg.body.reg_frame.reg = reg; - msg.vif = vif; + msg->body.reg_frame.frame_type = frame_type; + msg->body.reg_frame.reg = reg; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); + kfree(msg); + } return result; } @@ -3542,13 +3661,14 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, u32 head_len, u8 *head, u32 tail_len, u8 *tail) { int result = 0; - struct host_if_msg msg; - struct beacon_attr *beacon_info = &msg.body.beacon_info; + struct host_if_msg *msg; + struct beacon_attr *beacon_info; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_add_beacon); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_add_beacon; - msg.vif = vif; + beacon_info = &msg->body.beacon_info; beacon_info->interval = interval; beacon_info->dtim_period = dtim_period; beacon_info->head_len = head_len; @@ -3569,15 +3689,15 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, beacon_info->tail = NULL; } - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) netdev_err(vif->ndev, "wilc mq send fail\n"); error: if (result) { kfree(beacon_info->head); - kfree(beacon_info->tail); + kfree(msg); } return result; @@ -3586,14 +3706,17 @@ error: int wilc_del_beacon(struct wilc_vif *vif) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - msg.fn = handle_del_beacon; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_del_beacon); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3601,27 +3724,30 @@ int wilc_del_beacon(struct wilc_vif *vif) int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) { int result = 0; - struct host_if_msg msg; - struct add_sta_param *add_sta_info = &msg.body.add_sta_info; + struct host_if_msg *msg; + struct add_sta_param *add_sta_info; - memset(&msg, 0, sizeof(struct host_if_msg)); - - msg.fn = handle_add_station; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_add_station); + if (IS_ERR(msg)) + return PTR_ERR(msg); + add_sta_info = &msg->body.add_sta_info; memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param)); if (add_sta_info->rates_len > 0) { add_sta_info->rates = kmemdup(sta_param->rates, add_sta_info->rates_len, GFP_KERNEL); - if (!add_sta_info->rates) + if (!add_sta_info->rates) { + kfree(msg); return -ENOMEM; + } } - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(add_sta_info->rates); + kfree(msg); } return result; } @@ -3629,38 +3755,42 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) { int result = 0; - struct host_if_msg msg; - struct del_sta *del_sta_info = &msg.body.del_sta_info; + struct host_if_msg *msg; + struct del_sta *del_sta_info; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_del_station); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_del_station; - msg.vif = vif; + del_sta_info = &msg->body.del_sta_info; if (!mac_addr) eth_broadcast_addr(del_sta_info->mac_addr); else memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN); - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) { int result = 0; - struct host_if_msg msg; - struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info; + struct host_if_msg *msg; + struct del_all_sta *del_all_sta_info; u8 zero_addr[ETH_ALEN] = {0}; int i; u8 assoc_sta = 0; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_del_all_sta); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_del_all_sta; - msg.vif = vif; + del_all_sta_info = &msg->body.del_all_sta_info; for (i = 0; i < MAX_NUM_STA; i++) { if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) { @@ -3669,16 +3799,20 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) assoc_sta++; } } - if (!assoc_sta) - return result; + if (!assoc_sta) { + kfree(msg); + return 0; + } del_all_sta_info->assoc_sta = assoc_sta; - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); - if (result) + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); - else + kfree(msg); + } else { wait_for_completion(&hif_wait_response); + } return result; } @@ -3687,27 +3821,30 @@ int wilc_edit_station(struct wilc_vif *vif, struct add_sta_param *sta_param) { int result = 0; - struct host_if_msg msg; - struct add_sta_param *add_sta_info = &msg.body.add_sta_info; + struct host_if_msg *msg; + struct add_sta_param *add_sta_info; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_edit_station); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_edit_station; - msg.vif = vif; - - memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param)); + add_sta_info = &msg->body.add_sta_info; + memcpy(add_sta_info, sta_param, sizeof(*add_sta_info)); if (add_sta_info->rates_len > 0) { add_sta_info->rates = kmemdup(sta_param->rates, add_sta_info->rates_len, GFP_KERNEL); - if (!add_sta_info->rates) + if (!add_sta_info->rates) { + kfree(msg); return -ENOMEM; + } } - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_cmd(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(add_sta_info->rates); + kfree(msg); } return result; @@ -3716,23 +3853,23 @@ int wilc_edit_station(struct wilc_vif *vif, int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) { int result = 0; - struct host_if_msg msg; - struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info; + struct host_if_msg *msg; if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled) return 0; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_power_management); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_power_management; - msg.vif = vif; + msg->body.pwr_mgmt_info.enabled = enabled; + msg->body.pwr_mgmt_info.timeout = timeout; - pwr_mgmt_info->enabled = enabled; - pwr_mgmt_info->timeout = timeout; - - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3740,20 +3877,20 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count) { int result = 0; - struct host_if_msg msg; - struct set_multicast *multicast_filter_param = &msg.body.multicast_info; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_set_mcast_filter); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_set_mcast_filter; - msg.vif = vif; + msg->body.multicast_info.enabled = enabled; + msg->body.multicast_info.cnt = count; - multicast_filter_param->enabled = enabled; - multicast_filter_param->cnt = count; - - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3925,19 +4062,20 @@ static void *host_int_parse_join_bss_param(struct network_info *info) int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_set_ip_address); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_set_ip_address; + msg->body.ip_info.ip_addr = ip_addr; + msg->body.ip_info.idx = idx; - msg.body.ip_info.ip_addr = ip_addr; - msg.vif = vif; - msg.body.ip_info.idx = idx; - - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3945,19 +4083,20 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_get_ip_address); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_get_ip_address; + msg->body.ip_info.ip_addr = ip_addr; + msg->body.ip_info.idx = idx; - msg.body.ip_info.ip_addr = ip_addr; - msg.vif = vif; - msg.body.ip_info.idx = idx; - - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_cmd(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3965,17 +4104,19 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) { int ret = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_set_tx_pwr); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_set_tx_pwr; - msg.body.tx_power.tx_pwr = tx_power; - msg.vif = vif; + msg->body.tx_power.tx_pwr = tx_power; - ret = wilc_enqueue_cmd(&msg); - if (ret) + ret = wilc_enqueue_cmd(msg); + if (ret) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return ret; } @@ -3983,19 +4124,23 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) { int ret = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - memset(&msg, 0, sizeof(struct host_if_msg)); + msg = wilc_alloc_work(vif, handle_get_tx_pwr); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.fn = handle_get_tx_pwr; - msg.vif = vif; - - ret = wilc_enqueue_cmd(&msg); - if (ret) + ret = wilc_enqueue_cmd(msg); + if (ret) { netdev_err(vif->ndev, "Failed to get TX PWR\n"); + kfree(msg); + return ret; + } wait_for_completion(&hif_wait_response); - *tx_power = msg.body.tx_power.tx_pwr; + *tx_power = msg->body.tx_power.tx_pwr; + /* free 'msg' after copying data */ + kfree(msg); return ret; } From 5e6f8a8ae2923e0f9a8425320d5edb490a73abf0 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:06 +0530 Subject: [PATCH 154/903] staging: wilc1000: added 'work_comp' completion as part of host_if_msg Added 'work_comp' completion in 'host_if_msg'. It allows handling the sync call to wait for sepecific completion event. The commands can be run in sync way waiting for their specific completion event. Added is_sync flag in wilc_create_work_queue() to handle the sync call to host interface. After adding completion as part of host_if_msg now below completion are not required comp_test_key_block; comp_test_disconn_block comp_get_rssi comp_inactive_time hif_wait_response Modified wilc_get_statistics() API to handle get statistic in sync & async way. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 262 +++++++++--------- drivers/staging/wilc1000/host_interface.h | 7 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 3 files changed, 135 insertions(+), 136 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index cb627b0fa287..27516f76eec0 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -149,6 +149,8 @@ struct host_if_msg { struct wilc_vif *vif; struct work_struct work; void (*fn)(struct work_struct *ws); + struct completion work_comp; + bool is_sync; }; struct join_bss_param { @@ -186,7 +188,6 @@ static u8 p2p_listen_state; static struct workqueue_struct *hif_workqueue; static struct completion hif_thread_comp; static struct completion hif_driver_comp; -static struct completion hif_wait_response; static struct mutex hif_deinit_lock; static struct timer_list periodic_rssi; static struct wilc_vif *periodic_rssi_vif; @@ -205,8 +206,10 @@ static void *host_int_parse_join_bss_param(struct network_info *info); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt); +/* 'msg' should be free by the caller for syc */ static struct host_if_msg* -wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *)) +wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *), + bool is_sync) { struct host_if_msg *msg; @@ -218,6 +221,9 @@ wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *)) return ERR_PTR(-ENOMEM); msg->fn = work_fun; msg->vif = vif; + msg->is_sync = is_sync; + if (is_sync) + init_completion(&msg->work_comp); return msg; } @@ -434,8 +440,8 @@ static void handle_get_mac_address(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Failed to get mac address\n"); - complete(&hif_wait_response); - kfree(msg); + complete(&msg->work_comp); + /* free 'msg' data later, in caller */ complete(&hif_thread_comp); } @@ -1618,7 +1624,7 @@ static void handle_key(struct work_struct *work) wilc_get_vif_idx(vif)); } out_wep: - complete(&hif_drv->comp_test_key_block); + complete(&msg->work_comp); break; case WPA_RX_GTK: @@ -1682,7 +1688,7 @@ out_wep: kfree(key_buf); } out_wpa_rx_gtk: - complete(&hif_drv->comp_test_key_block); + complete(&msg->work_comp); kfree(hif_key->attr.wpa.key); kfree(hif_key->attr.wpa.seq); break; @@ -1739,19 +1745,21 @@ out_wpa_rx_gtk: } out_wpa_ptk: - complete(&hif_drv->comp_test_key_block); + complete(&msg->work_comp); kfree(hif_key->attr.wpa.key); break; case PMKSA: result = wilc_pmksa_key_copy(vif, hif_key); + /*free 'msg', this case it not a sync call*/ + kfree(msg); break; } if (result) netdev_err(vif->ndev, "Failed to send key config packet\n"); - kfree(msg); + /* free 'msg' data in caller sync call */ complete(&hif_thread_comp); } @@ -1825,8 +1833,8 @@ static void handle_disconnect(struct work_struct *work) out: - complete(&hif_drv->comp_test_disconn_block); - kfree(msg); + complete(&msg->work_comp); + /* free 'msg' in caller after receiving completion */ complete(&hif_thread_comp); } @@ -1856,8 +1864,8 @@ static void handle_get_rssi(struct work_struct *work) if (result) netdev_err(vif->ndev, "Failed to get RSSI value\n"); - complete(&vif->hif_drv->comp_get_rssi); - kfree(msg); + complete(&msg->work_comp); + /* free 'msg' data in caller */ complete(&hif_thread_comp); } @@ -1912,9 +1920,12 @@ static void handle_get_statistics(struct work_struct *work) else if (stats->link_speed != DEFAULT_LINK_SPEED) wilc_enable_tcp_ack_filter(false); - if (stats != &vif->wilc->dummy_statistics) - complete(&hif_wait_response); - kfree(msg); + /* free 'msg' for async command, for sync caller will free it */ + if (msg->is_sync) + complete(&msg->work_comp); + else + kfree(msg); + complete(&hif_thread_comp); } @@ -1925,7 +1936,6 @@ static void handle_get_inactive_time(struct work_struct *work) struct sta_inactive_t *hif_sta_inactive = &msg->body.mac_info; s32 result = 0; struct wid wid; - struct host_if_drv *hif_drv = vif->hif_drv; wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME; wid.type = WID_STR; @@ -1957,9 +1967,8 @@ static void handle_get_inactive_time(struct work_struct *work) netdev_err(vif->ndev, "Failed to get inactive time\n"); out: - complete(&hif_drv->comp_inactive_time); - - kfree(msg); + /* free 'msg' data in caller */ + complete(&msg->work_comp); complete(&hif_thread_comp); } @@ -2143,8 +2152,8 @@ static void handle_del_all_sta(struct work_struct *work) error: kfree(wid.val); - complete(&hif_wait_response); - kfree(msg); + /* free 'msg' data in caller */ + complete(&msg->work_comp); complete(&hif_thread_comp); } @@ -2365,7 +2374,7 @@ static void listen_timer_cb(struct timer_list *t) del_timer(&vif->hif_drv->remain_on_ch_timer); - msg = wilc_alloc_work(vif, handle_listen_state_expired); + msg = wilc_alloc_work(vif, handle_listen_state_expired, false); if (IS_ERR(msg)) return; @@ -2487,7 +2496,7 @@ static void handle_get_tx_pwr(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Failed to get TX PWR\n"); - complete(&hif_wait_response); + complete(&msg->work_comp); complete(&hif_thread_comp); } @@ -2513,8 +2522,8 @@ static void handle_hif_exit_work(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - kfree(msg); - complete(&hif_thread_comp); + /* free 'msg' data in caller */ + complete(&msg->work_comp); } static void handle_scan_complete(struct work_struct *work) @@ -2542,7 +2551,7 @@ static void timer_scan_cb(struct timer_list *t) struct host_if_msg *msg; int result; - msg = wilc_alloc_work(vif, handle_scan_timer); + msg = wilc_alloc_work(vif, handle_scan_timer, false); if (IS_ERR(msg)) return; @@ -2559,7 +2568,7 @@ static void timer_connect_cb(struct timer_list *t) struct host_if_msg *msg; int result; - msg = wilc_alloc_work(vif, handle_connect_timeout); + msg = wilc_alloc_work(vif, handle_connect_timeout, false); if (IS_ERR(msg)) return; @@ -2580,7 +2589,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) return result; } - msg = wilc_alloc_work(vif, handle_key); + msg = wilc_alloc_work(vif, handle_key, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2589,13 +2598,12 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) msg->body.key_info.attr.wep.index = index; result = wilc_enqueue_cmd(msg); - if (result) { + if (result) netdev_err(vif->ndev, "Request to remove WEP key\n"); - kfree(msg); - } else { - wait_for_completion(&hif_drv->comp_test_key_block); - } + else + wait_for_completion(&msg->work_comp); + kfree(msg); return result; } @@ -2611,7 +2619,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) return result; } - msg = wilc_alloc_work(vif, handle_key); + msg = wilc_alloc_work(vif, handle_key, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2620,13 +2628,12 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) msg->body.key_info.attr.wep.index = index; result = wilc_enqueue_cmd(msg); - if (result) { + if (result) netdev_err(vif->ndev, "Default key index\n"); - kfree(msg); - } else { - wait_for_completion(&hif_drv->comp_test_key_block); - } + else + wait_for_completion(&msg->work_comp); + kfree(msg); return result; } @@ -2642,7 +2649,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_key); + msg = wilc_alloc_work(vif, handle_key, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2661,7 +2668,8 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, if (result) goto free_key; - wait_for_completion(&hif_drv->comp_test_key_block); + wait_for_completion(&msg->work_comp); + kfree(msg); return 0; free_key: @@ -2684,7 +2692,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_key); + msg = wilc_alloc_work(vif, handle_key, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2705,7 +2713,8 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, if (result) goto free_key; - wait_for_completion(&hif_drv->comp_test_key_block); + wait_for_completion(&msg->work_comp); + kfree(msg); return 0; free_key: @@ -2736,7 +2745,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, if (tx_mic) key_len += TX_MIC_KEY_LEN; - msg = wilc_alloc_work(vif, handle_key); + msg = wilc_alloc_work(vif, handle_key, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2772,7 +2781,8 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, goto free_key; } - wait_for_completion(&hif_drv->comp_test_key_block); + wait_for_completion(&msg->work_comp); + kfree(msg); return 0; free_key: @@ -2798,7 +2808,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_key); + msg = wilc_alloc_work(vif, handle_key, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2851,7 +2861,8 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, goto free_key; } - wait_for_completion(&hif_drv->comp_test_key_block); + wait_for_completion(&msg->work_comp); + kfree(msg); return 0; free_key: @@ -2872,7 +2883,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, struct host_if_msg *msg; int i; - msg = wilc_alloc_work(vif, handle_key); + msg = wilc_alloc_work(vif, handle_key, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2900,20 +2911,20 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_get_mac_address); + msg = wilc_alloc_work(vif, handle_get_mac_address, true); if (IS_ERR(msg)) return PTR_ERR(msg); msg->body.get_mac_info.mac_addr = mac_addr; result = wilc_enqueue_cmd(msg); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to send get mac address\n"); - kfree(msg); - return -EFAULT; - } + else + wait_for_completion(&msg->work_comp); + + kfree(msg); - wait_for_completion(&hif_wait_response); return result; } @@ -2937,7 +2948,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_connect); + msg = wilc_alloc_work(vif, handle_connect, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3013,18 +3024,17 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) return -EFAULT; } - msg = wilc_alloc_work(vif, handle_disconnect); + msg = wilc_alloc_work(vif, handle_disconnect, true); if (IS_ERR(msg)) return PTR_ERR(msg); result = wilc_enqueue_cmd(msg); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to send message: disconnect\n"); - kfree(msg); - } else { - wait_for_completion(&hif_drv->comp_test_disconn_block); - } + else + wait_for_completion(&msg->work_comp); + kfree(msg); return result; } @@ -3058,7 +3068,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) int result; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_channel); + msg = wilc_alloc_work(vif, handle_set_channel, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3079,7 +3089,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_wfi_drv_handler); + msg = wilc_alloc_work(vif, handle_set_wfi_drv_handler, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3101,7 +3111,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_operation_mode); + msg = wilc_alloc_work(vif, handle_set_operation_mode, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3127,21 +3137,20 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_get_inactive_time); + msg = wilc_alloc_work(vif, handle_get_inactive_time, true); if (IS_ERR(msg)) return PTR_ERR(msg); memcpy(msg->body.mac_info.mac, mac, ETH_ALEN); result = wilc_enqueue_cmd(msg); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to send get host ch param\n"); - kfree(msg); - } else { - wait_for_completion(&hif_drv->comp_inactive_time); - } + else + wait_for_completion(&msg->work_comp); *out_val = inactive_time; + kfree(msg); return result; } @@ -3150,37 +3159,36 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) { int result = 0; struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - - msg = wilc_alloc_work(vif, handle_get_rssi); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - result = wilc_enqueue_cmd(msg); - if (result) { - netdev_err(vif->ndev, "Failed to send get host ch param\n"); - kfree(msg); - return result; - } - - wait_for_completion(&hif_drv->comp_get_rssi); if (!rssi_level) { netdev_err(vif->ndev, "RSS pointer value is null\n"); return -EFAULT; } - *rssi_level = rssi; + msg = wilc_alloc_work(vif, handle_get_rssi, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + result = wilc_enqueue_cmd(msg); + if (result) { + netdev_err(vif->ndev, "Failed to send get host ch param\n"); + } else { + wait_for_completion(&msg->work_comp); + *rssi_level = rssi; + } + + kfree(msg); return result; } -int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) +int +wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync) { int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_get_statistics); + msg = wilc_alloc_work(vif, handle_get_statistics, is_sync); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3193,8 +3201,11 @@ int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) return result; } - if (stats != &vif->wilc->dummy_statistics) - wait_for_completion(&hif_wait_response); + if (is_sync) { + wait_for_completion(&msg->work_comp); + kfree(msg); + } + return result; } @@ -3213,7 +3224,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_scan); + msg = wilc_alloc_work(vif, handle_scan, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3280,7 +3291,7 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_cfg_param); + msg = wilc_alloc_work(vif, handle_cfg_param, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3302,7 +3313,7 @@ static void get_periodic_rssi(struct timer_list *unused) } if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) - wilc_get_statistics(vif, &vif->wilc->dummy_statistics); + wilc_get_statistics(vif, &vif->wilc->dummy_statistics, false); mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000)); } @@ -3317,8 +3328,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) vif = netdev_priv(dev); wilc = vif->wilc; - init_completion(&hif_wait_response); - hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); if (!hif_drv) return -ENOMEM; @@ -3339,11 +3348,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) mutex_init(&hif_deinit_lock); } - init_completion(&hif_drv->comp_test_key_block); - init_completion(&hif_drv->comp_test_disconn_block); - init_completion(&hif_drv->comp_get_rssi); - init_completion(&hif_drv->comp_inactive_time); - if (clients_count == 0) { hif_workqueue = create_singlethread_workqueue("WILC_wq"); if (!hif_workqueue) { @@ -3414,7 +3418,7 @@ int wilc_deinit(struct wilc_vif *vif) if (clients_count == 1) { struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_hif_exit_work); + msg = wilc_alloc_work(vif, handle_hif_exit_work, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3422,8 +3426,8 @@ int wilc_deinit(struct wilc_vif *vif) if (result) netdev_err(vif->ndev, "deinit : Error(%d)\n", result); else - wait_for_completion(&hif_thread_comp); - + wait_for_completion(&msg->work_comp); + kfree(msg); destroy_workqueue(hif_workqueue); } @@ -3457,7 +3461,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info); + msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info, false); if (IS_ERR(msg)) return; @@ -3509,7 +3513,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info); + msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false); if (IS_ERR(msg)) { mutex_unlock(&hif_deinit_lock); return; @@ -3555,7 +3559,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) if (hif_drv->usr_scan_req.scan_result) { struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_scan_complete); + msg = wilc_alloc_work(vif, handle_scan_complete, false); if (IS_ERR(msg)) return; @@ -3576,7 +3580,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_remain_on_chan_work); + msg = wilc_alloc_work(vif, handle_remain_on_chan_work, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3609,7 +3613,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) del_timer(&hif_drv->remain_on_ch_timer); - msg = wilc_alloc_work(vif, handle_listen_state_expired); + msg = wilc_alloc_work(vif, handle_listen_state_expired, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3629,7 +3633,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_register_frame); + msg = wilc_alloc_work(vif, handle_register_frame, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3664,7 +3668,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, struct host_if_msg *msg; struct beacon_attr *beacon_info; - msg = wilc_alloc_work(vif, handle_add_beacon); + msg = wilc_alloc_work(vif, handle_add_beacon, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3708,7 +3712,7 @@ int wilc_del_beacon(struct wilc_vif *vif) int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_del_beacon); + msg = wilc_alloc_work(vif, handle_del_beacon, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3727,7 +3731,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) struct host_if_msg *msg; struct add_sta_param *add_sta_info; - msg = wilc_alloc_work(vif, handle_add_station); + msg = wilc_alloc_work(vif, handle_add_station, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3758,7 +3762,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) struct host_if_msg *msg; struct del_sta *del_sta_info; - msg = wilc_alloc_work(vif, handle_del_station); + msg = wilc_alloc_work(vif, handle_del_station, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3786,7 +3790,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) int i; u8 assoc_sta = 0; - msg = wilc_alloc_work(vif, handle_del_all_sta); + msg = wilc_alloc_work(vif, handle_del_all_sta, true); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3807,12 +3811,12 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) del_all_sta_info->assoc_sta = assoc_sta; result = wilc_enqueue_cmd(msg); - if (result) { + if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); - kfree(msg); - } else { - wait_for_completion(&hif_wait_response); - } + else + wait_for_completion(&msg->work_comp); + + kfree(msg); return result; } @@ -3824,7 +3828,7 @@ int wilc_edit_station(struct wilc_vif *vif, struct host_if_msg *msg; struct add_sta_param *add_sta_info; - msg = wilc_alloc_work(vif, handle_edit_station); + msg = wilc_alloc_work(vif, handle_edit_station, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3858,7 +3862,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled) return 0; - msg = wilc_alloc_work(vif, handle_power_management); + msg = wilc_alloc_work(vif, handle_power_management, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -3879,7 +3883,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_mcast_filter); + msg = wilc_alloc_work(vif, handle_set_mcast_filter, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -4064,7 +4068,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_ip_address); + msg = wilc_alloc_work(vif, handle_set_ip_address, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -4085,7 +4089,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) int result = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_get_ip_address); + msg = wilc_alloc_work(vif, handle_get_ip_address, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -4106,7 +4110,7 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) int ret = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_tx_pwr); + msg = wilc_alloc_work(vif, handle_set_tx_pwr, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -4126,20 +4130,18 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) int ret = 0; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_get_tx_pwr); + msg = wilc_alloc_work(vif, handle_get_tx_pwr, true); if (IS_ERR(msg)) return PTR_ERR(msg); ret = wilc_enqueue_cmd(msg); if (ret) { netdev_err(vif->ndev, "Failed to get TX PWR\n"); - kfree(msg); - return ret; + } else { + wait_for_completion(&msg->work_comp); + *tx_power = msg->body.tx_power.tx_pwr; } - wait_for_completion(&hif_wait_response); - - *tx_power = msg->body.tx_power.tx_pwr; /* free 'msg' after copying data */ kfree(msg); return ret; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 068b587a9df4..0ea22abd66a3 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -273,10 +273,6 @@ struct host_if_drv { struct cfg_param_attr cfg_values; /*lock to protect concurrent setting of cfg params*/ struct mutex cfg_values_lock; - struct completion comp_test_key_block; - struct completion comp_test_disconn_block; - struct completion comp_get_rssi; - struct completion comp_inactive_time; struct timer_list scan_timer; struct wilc_vif *scan_timer_vif; @@ -359,7 +355,8 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg); int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, u8 ifc_id); int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode); -int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats); +int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, + bool is_sync); void wilc_resolve_disconnect_aberration(struct wilc_vif *vif); int wilc_get_vif_idx(struct wilc_vif *vif); int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index e248702ee519..1f09925b38df 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1148,7 +1148,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, } else if (vif->iftype == STATION_MODE) { struct rf_info stats; - wilc_get_statistics(vif, &stats); + wilc_get_statistics(vif, &stats, true); sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | BIT(NL80211_STA_INFO_RX_PACKETS) | From 708d96fb2abe4a1a356e9d44ed5a6a470dab3204 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:07 +0530 Subject: [PATCH 155/903] staging: wilc1000: remove 'hif_thread_comp' completions Remove 'hif_thread_comp' completions as its not required after adding completion event as part work data to handle each sync call. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 35 ----------------------- 1 file changed, 35 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 27516f76eec0..17c20b92d0e5 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -186,7 +186,6 @@ static struct host_if_drv *terminated_handle; bool wilc_optaining_ip; static u8 p2p_listen_state; static struct workqueue_struct *hif_workqueue; -static struct completion hif_thread_comp; static struct completion hif_driver_comp; static struct mutex hif_deinit_lock; static struct timer_list periodic_rssi; @@ -286,7 +285,6 @@ static void handle_set_channel(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Failed to set channel\n"); kfree(msg); - complete(&hif_thread_comp); } static void handle_set_wfi_drv_handler(struct work_struct *work) @@ -334,7 +332,6 @@ static void handle_set_wfi_drv_handler(struct work_struct *work) free_msg: kfree(msg); - complete(&hif_thread_comp); } static void handle_set_operation_mode(struct work_struct *work) @@ -359,7 +356,6 @@ static void handle_set_operation_mode(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Failed to set driver handler\n"); kfree(msg); - complete(&hif_thread_comp); } static void handle_set_ip_address(struct work_struct *work) @@ -390,7 +386,6 @@ static void handle_set_ip_address(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Failed to set IP address\n"); kfree(msg); - complete(&hif_thread_comp); } static void handle_get_ip_address(struct work_struct *work) @@ -419,7 +414,6 @@ static void handle_get_ip_address(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Failed to get IP address\n"); kfree(msg); - complete(&hif_thread_comp); } static void handle_get_mac_address(struct work_struct *work) @@ -442,7 +436,6 @@ static void handle_get_mac_address(struct work_struct *work) netdev_err(vif->ndev, "Failed to get mac address\n"); complete(&msg->work_comp); /* free 'msg' data later, in caller */ - complete(&hif_thread_comp); } static void handle_cfg_param(struct work_struct *work) @@ -739,7 +732,6 @@ static void handle_cfg_param(struct work_struct *work) unlock: mutex_unlock(&hif_drv->cfg_values_lock); kfree(msg); - complete(&hif_thread_comp); } static void handle_scan(struct work_struct *work) @@ -857,7 +849,6 @@ error: kfree(hdn_ntwk_wid_val); kfree(msg); - complete(&hif_thread_comp); } static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) @@ -1163,7 +1154,6 @@ error: kfree(cur_byte); kfree(msg); - complete(&hif_thread_comp); } static void handle_connect_timeout(struct work_struct *work) @@ -1235,7 +1225,6 @@ static void handle_connect_timeout(struct work_struct *work) out: kfree(msg); - complete(&hif_thread_comp); } static void handle_rcvd_ntwrk_info(struct work_struct *work) @@ -1304,7 +1293,6 @@ done: } kfree(msg); - complete(&hif_thread_comp); } static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, @@ -1495,7 +1483,6 @@ free_rcvd_info: free_msg: kfree(msg); - complete(&hif_thread_comp); } static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) @@ -1760,7 +1747,6 @@ out_wpa_ptk: netdev_err(vif->ndev, "Failed to send key config packet\n"); /* free 'msg' data in caller sync call */ - complete(&hif_thread_comp); } static void handle_disconnect(struct work_struct *work) @@ -1835,7 +1821,6 @@ out: complete(&msg->work_comp); /* free 'msg' in caller after receiving completion */ - complete(&hif_thread_comp); } void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) @@ -1866,7 +1851,6 @@ static void handle_get_rssi(struct work_struct *work) complete(&msg->work_comp); /* free 'msg' data in caller */ - complete(&hif_thread_comp); } static void handle_get_statistics(struct work_struct *work) @@ -1925,8 +1909,6 @@ static void handle_get_statistics(struct work_struct *work) complete(&msg->work_comp); else kfree(msg); - - complete(&hif_thread_comp); } static void handle_get_inactive_time(struct work_struct *work) @@ -1969,7 +1951,6 @@ static void handle_get_inactive_time(struct work_struct *work) out: /* free 'msg' data in caller */ complete(&msg->work_comp); - complete(&hif_thread_comp); } static void handle_add_beacon(struct work_struct *work) @@ -2026,7 +2007,6 @@ error: kfree(param->head); kfree(param->tail); kfree(msg); - complete(&hif_thread_comp); } static void handle_del_beacon(struct work_struct *work) @@ -2047,7 +2027,6 @@ static void handle_del_beacon(struct work_struct *work) if (result) netdev_err(vif->ndev, "Failed to send delete beacon\n"); kfree(msg); - complete(&hif_thread_comp); } static u32 wilc_hif_pack_sta_param(u8 *buff, struct add_sta_param *param) @@ -2109,7 +2088,6 @@ error: kfree(param->rates); kfree(wid.val); kfree(msg); - complete(&hif_thread_comp); } static void handle_del_all_sta(struct work_struct *work) @@ -2154,7 +2132,6 @@ error: /* free 'msg' data in caller */ complete(&msg->work_comp); - complete(&hif_thread_comp); } static void handle_del_station(struct work_struct *work) @@ -2183,7 +2160,6 @@ static void handle_del_station(struct work_struct *work) error: kfree(wid.val); kfree(msg); - complete(&hif_thread_comp); } static void handle_edit_station(struct work_struct *work) @@ -2215,7 +2191,6 @@ error: kfree(param->rates); kfree(wid.val); kfree(msg); - complete(&hif_thread_comp); } static int handle_remain_on_chan(struct wilc_vif *vif, @@ -2316,7 +2291,6 @@ static void handle_register_frame(struct work_struct *work) out: kfree(msg); - complete(&hif_thread_comp); } static void handle_listen_state_expired(struct work_struct *work) @@ -2361,7 +2335,6 @@ static void handle_listen_state_expired(struct work_struct *work) free_msg: kfree(msg); - complete(&hif_thread_comp); } static void listen_timer_cb(struct timer_list *t) @@ -2411,7 +2384,6 @@ static void handle_power_management(struct work_struct *work) if (result) netdev_err(vif->ndev, "Failed to send power management\n"); kfree(msg); - complete(&hif_thread_comp); } static void handle_set_mcast_filter(struct work_struct *work) @@ -2453,7 +2425,6 @@ static void handle_set_mcast_filter(struct work_struct *work) error: kfree(wid.val); kfree(msg); - complete(&hif_thread_comp); } static void handle_set_tx_pwr(struct work_struct *work) @@ -2474,7 +2445,6 @@ static void handle_set_tx_pwr(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Failed to set TX PWR\n"); kfree(msg); - complete(&hif_thread_comp); } /* Note: 'msg' will be free after using data */ @@ -2497,7 +2467,6 @@ static void handle_get_tx_pwr(struct work_struct *work) netdev_err(vif->ndev, "Failed to get TX PWR\n"); complete(&msg->work_comp); - complete(&hif_thread_comp); } static void handle_scan_timer(struct work_struct *work) @@ -2506,7 +2475,6 @@ static void handle_scan_timer(struct work_struct *work) handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); kfree(msg); - complete(&hif_thread_comp); } static void handle_remain_on_chan_work(struct work_struct *work) @@ -2515,7 +2483,6 @@ static void handle_remain_on_chan_work(struct work_struct *work) handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch); kfree(msg); - complete(&hif_thread_comp); } static void handle_hif_exit_work(struct work_struct *work) @@ -2541,7 +2508,6 @@ static void handle_scan_complete(struct work_struct *work) if (msg->vif->hif_drv->remain_on_ch_pending) handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch); kfree(msg); - complete(&hif_thread_comp); } static void timer_scan_cb(struct timer_list *t) @@ -3343,7 +3309,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) wilc_optaining_ip = false; if (clients_count == 0) { - init_completion(&hif_thread_comp); init_completion(&hif_driver_comp); mutex_init(&hif_deinit_lock); } From c6a358d56476274c0ed4c4604565959692569762 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:08 +0530 Subject: [PATCH 156/903] staging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work() Rename wilc_enqueue_cmd() to wilc_enqueue_work() because its used to enqueue the work queue. Also removed the function header comment for wilc_enqueue_cmd() as its not correct. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 90 +++++++++++------------ 1 file changed, 42 insertions(+), 48 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 17c20b92d0e5..6d27a9dc246f 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -227,13 +227,7 @@ wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *), return msg; } -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -static int wilc_enqueue_cmd(struct host_if_msg *msg) +static int wilc_enqueue_work(struct host_if_msg *msg) { INIT_WORK(&msg->work, msg->fn); if (!hif_workqueue || !queue_work(hif_workqueue, &msg->work)) @@ -903,7 +897,7 @@ static void handle_connect(struct work_struct *work) struct host_if_drv *hif_drv = vif->hif_drv; if (msg->vif->hif_drv->usr_scan_req.scan_result) { - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) goto error; @@ -2353,7 +2347,7 @@ static void listen_timer_cb(struct timer_list *t) msg->body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -2521,7 +2515,7 @@ static void timer_scan_cb(struct timer_list *t) if (IS_ERR(msg)) return; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) kfree(msg); } @@ -2538,7 +2532,7 @@ static void timer_connect_cb(struct timer_list *t) if (IS_ERR(msg)) return; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) kfree(msg); } @@ -2563,7 +2557,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) msg->body.key_info.action = REMOVEKEY; msg->body.key_info.attr.wep.index = index; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Request to remove WEP key\n"); else @@ -2593,7 +2587,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) msg->body.key_info.action = DEFAULTKEY; msg->body.key_info.attr.wep.index = index; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Default key index\n"); else @@ -2630,7 +2624,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, msg->body.key_info.attr.wep.key_len = len; msg->body.key_info.attr.wep.index = index; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) goto free_key; @@ -2675,7 +2669,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, msg->body.key_info.attr.wep.mode = mode; msg->body.key_info.attr.wep.auth_type = auth_type; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) goto free_key; @@ -2741,7 +2735,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, msg->body.key_info.attr.wpa.mac_addr = mac_addr; msg->body.key_info.attr.wpa.mode = cipher_mode; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "PTK Key\n"); goto free_key; @@ -2821,7 +2815,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, msg->body.key_info.attr.wpa.key_len = key_len; msg->body.key_info.attr.wpa.seq_len = key_rsc_len; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "RX GTK\n"); goto free_key; @@ -2863,7 +2857,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, &pmkid->pmkidlist[i].pmkid, PMKID_LEN); } - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "PMKID Info\n"); kfree(msg); @@ -2883,7 +2877,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) msg->body.get_mac_info.mac_addr = mac_addr; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Failed to send get mac address\n"); else @@ -2953,7 +2947,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, if (hif_drv->hif_state < HOST_IF_CONNECTING) hif_drv->hif_state = HOST_IF_CONNECTING; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "send message: Set join request\n"); goto free_ies; @@ -2994,7 +2988,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) if (IS_ERR(msg)) return PTR_ERR(msg); - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Failed to send message: disconnect\n"); else @@ -3040,7 +3034,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) msg->body.channel_info.set_ch = channel; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); kfree(msg); @@ -3063,7 +3057,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, msg->body.drv.mode = mode; msg->body.drv.name = ifc_id; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); kfree(msg); @@ -3082,7 +3076,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) return PTR_ERR(msg); msg->body.mode.mode = mode; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); kfree(msg); @@ -3109,7 +3103,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, memcpy(msg->body.mac_info.mac, mac, ETH_ALEN); - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Failed to send get host ch param\n"); else @@ -3135,7 +3129,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) if (IS_ERR(msg)) return PTR_ERR(msg); - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "Failed to send get host ch param\n"); } else { @@ -3160,7 +3154,7 @@ wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync) msg->body.data = (char *)stats; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "Failed to send get host channel\n"); kfree(msg); @@ -3222,7 +3216,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, goto free_freq_list; } - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "Error in sending message queue\n"); goto free_ies; @@ -3262,7 +3256,7 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, return PTR_ERR(msg); msg->body.cfg_info = *cfg_param; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) kfree(msg); @@ -3387,7 +3381,7 @@ int wilc_deinit(struct wilc_vif *vif) if (IS_ERR(msg)) return PTR_ERR(msg); - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "deinit : Error(%d)\n", result); else @@ -3437,7 +3431,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "message parameters (%d)\n", result); kfree(msg->body.net_info.buffer); @@ -3492,7 +3486,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "synchronous info (%d)\n", result); kfree(msg->body.async_info.buffer); @@ -3528,7 +3522,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) if (IS_ERR(msg)) return; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "complete param (%d)\n", result); kfree(msg); @@ -3556,7 +3550,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, msg->body.remain_on_ch.duration = duration; msg->body.remain_on_ch.id = session_id; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); kfree(msg); @@ -3584,7 +3578,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) msg->body.remain_on_ch.id = session_id; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); kfree(msg); @@ -3617,7 +3611,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) msg->body.reg_frame.frame_type = frame_type; msg->body.reg_frame.reg = reg; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); kfree(msg); @@ -3658,7 +3652,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, beacon_info->tail = NULL; } - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "wilc mq send fail\n"); @@ -3681,7 +3675,7 @@ int wilc_del_beacon(struct wilc_vif *vif) if (IS_ERR(msg)) return PTR_ERR(msg); - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -3712,7 +3706,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) } } - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(add_sta_info->rates); @@ -3738,7 +3732,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) else memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN); - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -3774,7 +3768,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) } del_all_sta_info->assoc_sta = assoc_sta; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); @@ -3809,7 +3803,7 @@ int wilc_edit_station(struct wilc_vif *vif, } } - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(add_sta_info->rates); @@ -3834,7 +3828,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) msg->body.pwr_mgmt_info.enabled = enabled; msg->body.pwr_mgmt_info.timeout = timeout; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -3855,7 +3849,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, msg->body.multicast_info.enabled = enabled; msg->body.multicast_info.cnt = count; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -4040,7 +4034,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) msg->body.ip_info.ip_addr = ip_addr; msg->body.ip_info.idx = idx; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -4061,7 +4055,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) msg->body.ip_info.ip_addr = ip_addr; msg->body.ip_info.idx = idx; - result = wilc_enqueue_cmd(msg); + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -4081,7 +4075,7 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) msg->body.tx_power.tx_pwr = tx_power; - ret = wilc_enqueue_cmd(msg); + ret = wilc_enqueue_work(msg); if (ret) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(msg); @@ -4099,7 +4093,7 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) if (IS_ERR(msg)) return PTR_ERR(msg); - ret = wilc_enqueue_cmd(msg); + ret = wilc_enqueue_work(msg); if (ret) { netdev_err(vif->ndev, "Failed to get TX PWR\n"); } else { From e6ea187b5b2acff5ed07dacff37306d0f56d6d43 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:09 +0530 Subject: [PATCH 157/903] staging: wilc1000: handle freeing of key data in wep add key Modified the code to free the allocated memory, used to store the key in wilc_add_wep_key_bss_sta() and wilc_add_wep_key_bss_ap(). After work completion notification is received, free the memory allocated to avoid missing of free in work function. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 6d27a9dc246f..2cc968953ba0 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1551,8 +1551,6 @@ static void handle_key(struct work_struct *work) memcpy(&key_buf[2], hif_key->attr.wep.key, hif_key->attr.wep.key_len); - kfree(hif_key->attr.wep.key); - wid_list[2].id = (u16)WID_WEP_KEY_VALUE; wid_list[2].type = WID_STR; wid_list[2].size = hif_key->attr.wep.key_len + 2; @@ -1573,7 +1571,6 @@ static void handle_key(struct work_struct *work) memcpy(key_buf + 1, &hif_key->attr.wep.key_len, 1); memcpy(key_buf + 2, hif_key->attr.wep.key, hif_key->attr.wep.key_len); - kfree(hif_key->attr.wep.key); wid.id = (u16)WID_ADD_WEP_KEY; wid.type = WID_STR; @@ -2629,8 +2626,6 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, goto free_key; wait_for_completion(&msg->work_comp); - kfree(msg); - return 0; free_key: kfree(msg->body.key_info.attr.wep.key); @@ -2674,8 +2669,6 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, goto free_key; wait_for_completion(&msg->work_comp); - kfree(msg); - return 0; free_key: kfree(msg->body.key_info.attr.wep.key); From 5b9be6713a7ca8bf0a82778c4fdd2cdbf4434767 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:10 +0530 Subject: [PATCH 158/903] staging: wilc1000: handle freeing of key data in wilc_add_ptk() Handle freeing of memory allocated to store the 'key' in wilc_add_ptk() function. Once work completion notification is received, free the memory allocated to avoid missing of free in work function sepecially for error scenario. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2cc968953ba0..2062f4e6f3f3 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1724,7 +1724,6 @@ out_wpa_rx_gtk: out_wpa_ptk: complete(&msg->work_comp); - kfree(hif_key->attr.wpa.key); break; case PMKSA: @@ -2735,8 +2734,6 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, } wait_for_completion(&msg->work_comp); - kfree(msg); - return 0; free_key: kfree(msg->body.key_info.attr.wpa.key); From 56b408e513baeaff715acadbe98472f94e4cdbf3 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:11 +0530 Subject: [PATCH 159/903] staging: wilc1000: handle freeing of 'key' & 'seq' data in wilc_add_rx_gtk() Handle freeing of memory allocated to keep 'key' & 'seq' in wilc_add_rx_gtk(). Once completion event is received, free the memory allocated for to avoid missing of free in work function. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2062f4e6f3f3..2251c39f659a 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1667,8 +1667,6 @@ out_wep: } out_wpa_rx_gtk: complete(&msg->work_comp); - kfree(hif_key->attr.wpa.key); - kfree(hif_key->attr.wpa.seq); break; case WPA_PTK: @@ -2812,8 +2810,6 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, } wait_for_completion(&msg->work_comp); - kfree(msg); - return 0; free_key: kfree(msg->body.key_info.attr.wpa.key); From 6566dc0416084e7e6d607024b8c04ed08ad8011e Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:12 +0530 Subject: [PATCH 160/903] staging: wilc1000: avoid use of static variable 'inactive_time' Avoided the use of static variable 'inactive_time' and move it as part of 'sta_inactive_t' structure. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2251c39f659a..f61a20d61d93 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -110,6 +110,7 @@ struct set_ip_addr { }; struct sta_inactive_t { + u32 inactive_time; u8 mac[6]; }; @@ -198,7 +199,6 @@ static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE]; static s8 rssi; static u8 set_ip[2][4]; static u8 get_ip[2][4]; -static u32 inactive_time; static u32 clients_count; static void *host_int_parse_join_bss_param(struct network_info *info); @@ -1927,7 +1927,7 @@ static void handle_get_inactive_time(struct work_struct *work) wid.id = (u16)WID_GET_INACTIVE_TIME; wid.type = WID_INT; - wid.val = (s8 *)&inactive_time; + wid.val = (s8 *)&hif_sta_inactive->inactive_time; wid.size = sizeof(u32); result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, @@ -3095,7 +3095,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, else wait_for_completion(&msg->work_comp); - *out_val = inactive_time; + *out_val = msg->body.mac_info.inactive_time; kfree(msg); return result; From 688a45ea203010ed9145596f8f84bd6eed930d84 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:13 +0530 Subject: [PATCH 161/903] staging: wilc1000: avoid use of static variable 'rssi' Instead of static variable now allocating the data and passing to handle_get_rssi() to fill the rssi information. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index f61a20d61d93..52c0c1066375 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -196,7 +196,6 @@ u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE]; -static s8 rssi; static u8 set_ip[2][4]; static u8 get_ip[2][4]; static u32 clients_count; @@ -1829,7 +1828,7 @@ static void handle_get_rssi(struct work_struct *work) wid.id = (u16)WID_RSSI; wid.type = WID_CHAR; - wid.val = &rssi; + wid.val = msg->body.data; wid.size = sizeof(char); result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, @@ -3115,14 +3114,21 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) if (IS_ERR(msg)) return PTR_ERR(msg); + msg->body.data = kzalloc(sizeof(s8), GFP_KERNEL); + if (!msg->body.data) { + kfree(msg); + return -ENOMEM; + } + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "Failed to send get host ch param\n"); } else { wait_for_completion(&msg->work_comp); - *rssi_level = rssi; + *rssi_level = *msg->body.data; } + kfree(msg->body.data); kfree(msg); return result; From 5c6d0dbb023d9c55b60aae3d2d2617bd05cc6199 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 26 Jun 2018 11:37:14 +0530 Subject: [PATCH 162/903] staging: wilc1000: updated TODO file Item [1] in TODO list is already addressed, so removed it from TODO file. [1]. Move handling for each individual members of 'union message_body' out into a separate 'struct work_struct' and completely remove the multiplexerthat is currently part of host_if_work(), allowing movement of the implementation of each message handler into the callsite of the function that currently queues the 'host_if_msg'. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/TODO | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO index d123324bd5c9..725bedee08c0 100644 --- a/drivers/staging/wilc1000/TODO +++ b/drivers/staging/wilc1000/TODO @@ -1,10 +1,5 @@ TODO: - rework comments and function headers(also coding style) -- Move handling for each individual members of 'union message_body' out - into a separate 'struct work_struct' and completely remove the multiplexer - that is currently part of host_if_work(), allowing movement of the - implementation of each message handler into the callsite of the function - that currently queues the 'host_if_msg'. - make spi and sdio components coexist in one build - support soft-ap and p2p mode - support resume/suspend function From 59848d6aded59a644bd3199033a9dc5a66d528f5 Mon Sep 17 00:00:00 2001 From: Alistair Strachan Date: Tue, 19 Jun 2018 17:57:34 -0700 Subject: [PATCH 163/903] staging: android: ashmem: Remove use of unlikely() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no speed difference, and it makes the code harder to read. Cc: Greg Kroah-Hartman Cc: Arve HjønnevÃ¥g Cc: Todd Kjos Cc: Martijn Coenen Cc: devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org Cc: kernel-team@android.com Cc: Joel Fernandes Suggested-by: Greg Kroah-Hartman Signed-off-by: Alistair Strachan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.c | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index a1a0025b59e0..c6386e4f5c9b 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -178,7 +178,7 @@ static int range_alloc(struct ashmem_area *asma, struct ashmem_range *range; range = kmem_cache_zalloc(ashmem_range_cachep, GFP_KERNEL); - if (unlikely(!range)) + if (!range) return -ENOMEM; range->asma = asma; @@ -246,11 +246,11 @@ static int ashmem_open(struct inode *inode, struct file *file) int ret; ret = generic_file_open(inode, file); - if (unlikely(ret)) + if (ret) return ret; asma = kmem_cache_zalloc(ashmem_area_cachep, GFP_KERNEL); - if (unlikely(!asma)) + if (!asma) return -ENOMEM; INIT_LIST_HEAD(&asma->unpinned_list); @@ -361,14 +361,14 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) mutex_lock(&ashmem_mutex); /* user needs to SET_SIZE before mapping */ - if (unlikely(!asma->size)) { + if (!asma->size) { ret = -EINVAL; goto out; } /* requested protection bits must match our allowed protection mask */ - if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & - calc_vm_prot_bits(PROT_MASK, 0))) { + if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & + calc_vm_prot_bits(PROT_MASK, 0)) { ret = -EPERM; goto out; } @@ -486,7 +486,7 @@ static int set_prot_mask(struct ashmem_area *asma, unsigned long prot) mutex_lock(&ashmem_mutex); /* the user can only remove, not add, protection bits */ - if (unlikely((asma->prot_mask & prot) != prot)) { + if ((asma->prot_mask & prot) != prot) { ret = -EINVAL; goto out; } @@ -524,7 +524,7 @@ static int set_name(struct ashmem_area *asma, void __user *name) local_name[ASHMEM_NAME_LEN - 1] = '\0'; mutex_lock(&ashmem_mutex); /* cannot change an existing mapping's name */ - if (unlikely(asma->file)) + if (asma->file) ret = -EINVAL; else strcpy(asma->name + ASHMEM_NAME_PREFIX_LEN, local_name); @@ -563,7 +563,7 @@ static int get_name(struct ashmem_area *asma, void __user *name) * Now we are just copying from the stack variable to userland * No lock held */ - if (unlikely(copy_to_user(name, local_name, len))) + if (copy_to_user(name, local_name, len)) ret = -EFAULT; return ret; } @@ -701,25 +701,25 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd, size_t pgstart, pgend; int ret = -EINVAL; - if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) + if (copy_from_user(&pin, p, sizeof(pin))) return -EFAULT; mutex_lock(&ashmem_mutex); - if (unlikely(!asma->file)) + if (!asma->file) goto out_unlock; /* per custom, you can pass zero for len to mean "everything onward" */ if (!pin.len) pin.len = PAGE_ALIGN(asma->size) - pin.offset; - if (unlikely((pin.offset | pin.len) & ~PAGE_MASK)) + if ((pin.offset | pin.len) & ~PAGE_MASK) goto out_unlock; - if (unlikely(((__u32)-1) - pin.offset < pin.len)) + if (((__u32)-1) - pin.offset < pin.len) goto out_unlock; - if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len)) + if (PAGE_ALIGN(asma->size) < pin.offset + pin.len) goto out_unlock; pgstart = pin.offset / PAGE_SIZE; @@ -856,7 +856,7 @@ static int __init ashmem_init(void) ashmem_area_cachep = kmem_cache_create("ashmem_area_cache", sizeof(struct ashmem_area), 0, 0, NULL); - if (unlikely(!ashmem_area_cachep)) { + if (!ashmem_area_cachep) { pr_err("failed to create slab cache\n"); goto out; } @@ -864,13 +864,13 @@ static int __init ashmem_init(void) ashmem_range_cachep = kmem_cache_create("ashmem_range_cache", sizeof(struct ashmem_range), 0, 0, NULL); - if (unlikely(!ashmem_range_cachep)) { + if (!ashmem_range_cachep) { pr_err("failed to create slab cache\n"); goto out_free1; } ret = misc_register(&ashmem_misc); - if (unlikely(ret)) { + if (ret) { pr_err("failed to register misc device!\n"); goto out_free2; } From 8632c614565d0c5fdde527889601c018e97b6384 Mon Sep 17 00:00:00 2001 From: Alistair Strachan Date: Tue, 19 Jun 2018 17:57:35 -0700 Subject: [PATCH 164/903] staging: android: ashmem: Fix mmap size validation The ashmem driver did not check that the size/offset of the vma passed to its .mmap() function was not larger than the ashmem object being mapped. This could cause mmap() to succeed, even though accessing parts of the mapping would later fail with a segmentation fault. Ensure an error is returned by the ashmem_mmap() function if the vma size is larger than the ashmem object size. This enables safer handling of the problem in userspace. Cc: Todd Kjos Cc: devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org Cc: kernel-team@android.com Cc: Joel Fernandes Signed-off-by: Alistair Strachan Acked-by: Joel Fernandes (Google) Reviewed-by: Martijn Coenen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index c6386e4f5c9b..e392358ec244 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -366,6 +366,12 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) goto out; } + /* requested mapping size larger than object size */ + if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { + ret = -EINVAL; + goto out; + } + /* requested protection bits must match our allowed protection mask */ if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & calc_vm_prot_bits(PROT_MASK, 0)) { From 10c553b154c725e27da2f09e45692222f97beb6e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 18 Jun 2018 17:09:09 +0200 Subject: [PATCH 165/903] staging: android/vsoc: stop using 'timespec' The timespec structure suffers from the y2038 overflow and should not be used. This changes handle_vsoc_cond_wait() to use ktime_t directly. Signed-off-by: Arnd Bergmann Reviewed-by: Martijn Coenen Tested-by: Alistair Strachan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/vsoc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/android/vsoc.c b/drivers/staging/android/vsoc.c index 806beda1040b..22571abcaa4e 100644 --- a/drivers/staging/android/vsoc.c +++ b/drivers/staging/android/vsoc.c @@ -405,7 +405,7 @@ static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg) int ret = 0; struct vsoc_device_region *region_p = vsoc_region_from_filep(filp); atomic_t *address = NULL; - struct timespec ts; + ktime_t wake_time; /* Ensure that the offset is aligned */ if (arg->offset & (sizeof(uint32_t) - 1)) @@ -433,14 +433,13 @@ static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg) * We do things this way to flatten differences between 32 bit * and 64 bit timespecs. */ - ts.tv_sec = arg->wake_time_sec; - ts.tv_nsec = arg->wake_time_nsec; - - if (!timespec_valid(&ts)) + if (arg->wake_time_nsec >= NSEC_PER_SEC) return -EINVAL; + wake_time = ktime_set(arg->wake_time_sec, arg->wake_time_nsec); + hrtimer_init_on_stack(&to->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); - hrtimer_set_expires_range_ns(&to->timer, timespec_to_ktime(ts), + hrtimer_set_expires_range_ns(&to->timer, wake_time, current->timer_slack_ns); hrtimer_init_sleeper(to, current); From 983000d7fa5d7538915810b58c9e63cb6118eb1e Mon Sep 17 00:00:00 2001 From: Hugo Lefeuvre Date: Wed, 20 Jun 2018 09:37:19 -0400 Subject: [PATCH 166/903] staging: pi433: fix race condition in pi433_open The device structure contains a useless non-atomic users counter which is subject to race conditions. It has probably been created to handle the case where remove is executed while operations are still executing on open fds but this will never happen because of reference counts. Drop the users counter and move rx buffer {de,}allocation to probe() and remove(). Remove associated dead code from open() and release(). Remove related TODO entry from ioctl(). Signed-off-by: Hugo Lefeuvre Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 41 ++++++++++---------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 94e0bfcec991..0638fd5f14d9 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -78,7 +78,6 @@ struct pi433_device { struct device *dev; struct cdev *cdev; struct spi_device *spi; - unsigned int users; /* irq related values */ struct gpio_desc *gpiod[NUM_DIO]; @@ -887,9 +886,6 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (_IOC_TYPE(cmd) != PI433_IOC_MAGIC) return -ENOTTY; - /* TODO? guard against device removal before, or while, - * we issue this ioctl. --> device_get() - */ instance = filp->private_data; device = instance->device; @@ -963,19 +959,9 @@ static int pi433_open(struct inode *inode, struct file *filp) return -ENODEV; } - if (!device->rx_buffer) { - device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); - if (!device->rx_buffer) - return -ENOMEM; - } - - device->users++; instance = kzalloc(sizeof(*instance), GFP_KERNEL); - if (!instance) { - kfree(device->rx_buffer); - device->rx_buffer = NULL; + if (!instance) return -ENOMEM; - } /* setup instance data*/ instance->device = device; @@ -992,23 +978,11 @@ static int pi433_open(struct inode *inode, struct file *filp) static int pi433_release(struct inode *inode, struct file *filp) { struct pi433_instance *instance; - struct pi433_device *device; instance = filp->private_data; - device = instance->device; kfree(instance); filp->private_data = NULL; - /* last close? */ - device->users--; - - if (!device->users) { - kfree(device->rx_buffer); - device->rx_buffer = NULL; - if (!device->spi) - kfree(device); - } - return 0; } @@ -1178,6 +1152,13 @@ static int pi433_probe(struct spi_device *spi) device->tx_active = false; device->interrupt_rx_allowed = false; + /* init rx buffer */ + device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); + if (!device->rx_buffer) { + retval = -ENOMEM; + goto RX_failed; + } + /* init wait queues */ init_waitqueue_head(&device->tx_wait_queue); init_waitqueue_head(&device->rx_wait_queue); @@ -1280,6 +1261,8 @@ device_create_failed: minor_failed: free_gpio(device); GPIO_failed: + kfree(device->rx_buffer); +RX_failed: kfree(device); return retval; @@ -1303,8 +1286,8 @@ static int pi433_remove(struct spi_device *spi) pi433_free_minor(device); - if (device->users == 0) - kfree(device); + kfree(device->rx_buffer); + kfree(device); return 0; } From 8679339524c11497b7b7019fa7e24fe8e9a78a91 Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Sun, 24 Jun 2018 18:31:38 +0200 Subject: [PATCH 167/903] staging: pi433: replace simple switch statements Use const array to map switch cases to resulting values. Signed-off-by: Valentin Vidic Reviewed-by: Marcus Wolf Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/rf69.c | 233 ++++++++++++++--------------------- 1 file changed, 93 insertions(+), 140 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 90280e9b006d..341d6901a801 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, int rf69_set_mode(struct spi_device *spi, enum mode mode) { - switch (mode) { - case transmit: - return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, - OPMODE_MODE_TRANSMIT); - case receive: - return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, - OPMODE_MODE_RECEIVE); - case synthesizer: - return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, - OPMODE_MODE_SYNTHESIZER); - case standby: - return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, - OPMODE_MODE_STANDBY); - case mode_sleep: - return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, - OPMODE_MODE_SLEEP); - default: + static const u8 mode_map[] = { + [transmit] = OPMODE_MODE_TRANSMIT, + [receive] = OPMODE_MODE_RECEIVE, + [synthesizer] = OPMODE_MODE_SYNTHESIZER, + [standby] = OPMODE_MODE_STANDBY, + [mode_sleep] = OPMODE_MODE_SLEEP, + }; + + if (unlikely(mode >= ARRAY_SIZE(mode_map))) { dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; } + return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, + mode_map[mode]); + // we are using packet mode, so this check is not really needed // but waiting for mode ready is necessary when going from sleep because the FIFO may not be immediately available from previous mode //while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady @@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode) int rf69_set_modulation(struct spi_device *spi, enum modulation modulation) { - switch (modulation) { - case OOK: - return rf69_read_mod_write(spi, REG_DATAMODUL, - MASK_DATAMODUL_MODULATION_TYPE, - DATAMODUL_MODULATION_TYPE_OOK); - case FSK: - return rf69_read_mod_write(spi, REG_DATAMODUL, - MASK_DATAMODUL_MODULATION_TYPE, - DATAMODUL_MODULATION_TYPE_FSK); - default: + static const u8 modulation_map[] = { + [OOK] = DATAMODUL_MODULATION_TYPE_OOK, + [FSK] = DATAMODUL_MODULATION_TYPE_FSK, + }; + + if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) { dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; } + + return rf69_read_mod_write(spi, REG_DATAMODUL, + MASK_DATAMODUL_MODULATION_TYPE, + modulation_map[modulation]); } static enum modulation rf69_get_modulation(struct spi_device *spi) @@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 power_level) int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp) { - switch (pa_ramp) { - case ramp3400: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400); - case ramp2000: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000); - case ramp1000: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000); - case ramp500: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_500); - case ramp250: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_250); - case ramp125: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_125); - case ramp100: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_100); - case ramp62: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_62); - case ramp50: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_50); - case ramp40: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_40); - case ramp31: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_31); - case ramp25: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_25); - case ramp20: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_20); - case ramp15: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_15); - case ramp12: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_12); - case ramp10: - return rf69_write_reg(spi, REG_PARAMP, PARAMP_10); - default: + static const u8 pa_ramp_map[] = { + [ramp3400] = PARAMP_3400, + [ramp2000] = PARAMP_2000, + [ramp1000] = PARAMP_1000, + [ramp500] = PARAMP_500, + [ramp250] = PARAMP_250, + [ramp125] = PARAMP_125, + [ramp100] = PARAMP_100, + [ramp62] = PARAMP_62, + [ramp50] = PARAMP_50, + [ramp40] = PARAMP_40, + [ramp31] = PARAMP_31, + [ramp25] = PARAMP_25, + [ramp20] = PARAMP_20, + [ramp15] = PARAMP_15, + [ramp10] = PARAMP_10, + }; + + if (unlikely(pa_ramp >= ARRAY_SIZE(pa_ramp_map))) { dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; } + + return rf69_write_reg(spi, REG_PARAMP, pa_ramp_map[pa_ramp]); } int rf69_set_antenna_impedance(struct spi_device *spi, @@ -428,32 +410,23 @@ int rf69_set_antenna_impedance(struct spi_device *spi, int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain) { - switch (lna_gain) { - case automatic: - return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, - LNA_GAIN_AUTO); - case max: - return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, - LNA_GAIN_MAX); - case max_minus_6: - return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, - LNA_GAIN_MAX_MINUS_6); - case max_minus_12: - return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, - LNA_GAIN_MAX_MINUS_12); - case max_minus_24: - return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, - LNA_GAIN_MAX_MINUS_24); - case max_minus_36: - return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, - LNA_GAIN_MAX_MINUS_36); - case max_minus_48: - return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, - LNA_GAIN_MAX_MINUS_48); - default: + static const u8 lna_gain_map[] = { + [automatic] = LNA_GAIN_AUTO, + [max] = LNA_GAIN_MAX, + [max_minus_6] = LNA_GAIN_MAX_MINUS_6, + [max_minus_12] = LNA_GAIN_MAX_MINUS_12, + [max_minus_24] = LNA_GAIN_MAX_MINUS_24, + [max_minus_36] = LNA_GAIN_MAX_MINUS_36, + [max_minus_48] = LNA_GAIN_MAX_MINUS_48, + }; + + if (unlikely(lna_gain >= ARRAY_SIZE(lna_gain_map))) { dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; } + + return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, + lna_gain_map[lna_gain]); } static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg, @@ -516,43 +489,24 @@ int rf69_set_bandwidth_during_afc(struct spi_device *spi, int rf69_set_ook_threshold_dec(struct spi_device *spi, enum threshold_decrement threshold_decrement) { - switch (threshold_decrement) { - case dec_every8th: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_EVERY_8TH); - case dec_every4th: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_EVERY_4TH); - case dec_every2nd: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_EVERY_2ND); - case dec_once: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_ONCE); - case dec_twice: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_TWICE); - case dec_4times: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_4_TIMES); - case dec_8times: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_8_TIMES); - case dec_16times: - return rf69_read_mod_write(spi, REG_OOKPEAK, - MASK_OOKPEAK_THRESDEC, - OOKPEAK_THRESHDEC_16_TIMES); - default: + static const u8 td_map[] = { + [dec_every8th] = OOKPEAK_THRESHDEC_EVERY_8TH, + [dec_every4th] = OOKPEAK_THRESHDEC_EVERY_4TH, + [dec_every2nd] = OOKPEAK_THRESHDEC_EVERY_2ND, + [dec_once] = OOKPEAK_THRESHDEC_ONCE, + [dec_twice] = OOKPEAK_THRESHDEC_TWICE, + [dec_4times] = OOKPEAK_THRESHDEC_4_TIMES, + [dec_8times] = OOKPEAK_THRESHDEC_8_TIMES, + [dec_16times] = OOKPEAK_THRESHDEC_16_TIMES, + }; + + if (unlikely(threshold_decrement >= ARRAY_SIZE(td_map))) { dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; } + + return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, + td_map[threshold_decrement]); } int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value) @@ -749,23 +703,21 @@ int rf69_disable_crc(struct spi_device *spi) int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering address_filtering) { - switch (address_filtering) { - case filtering_off: - return rf69_read_mod_write(spi, REG_PACKETCONFIG1, - MASK_PACKETCONFIG1_ADDRESSFILTERING, - PACKETCONFIG1_ADDRESSFILTERING_OFF); - case node_address: - return rf69_read_mod_write(spi, REG_PACKETCONFIG1, - MASK_PACKETCONFIG1_ADDRESSFILTERING, - PACKETCONFIG1_ADDRESSFILTERING_NODE); - case node_or_broadcast_address: - return rf69_read_mod_write(spi, REG_PACKETCONFIG1, - MASK_PACKETCONFIG1_ADDRESSFILTERING, - PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST); - default: + static const u8 af_map[] = { + [filtering_off] = PACKETCONFIG1_ADDRESSFILTERING_OFF, + [node_address] = PACKETCONFIG1_ADDRESSFILTERING_NODE, + [node_or_broadcast_address] = + PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST, + }; + + if (unlikely(address_filtering >= ARRAY_SIZE(af_map))) { dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; } + + return rf69_read_mod_write(spi, REG_PACKETCONFIG1, + MASK_PACKETCONFIG1_ADDRESSFILTERING, + af_map[address_filtering]); } int rf69_set_payload_length(struct spi_device *spi, u8 payload_length) @@ -824,17 +776,18 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold) int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) { - switch (dagc) { - case normal_mode: - return rf69_write_reg(spi, REG_TESTDAGC, DAGC_NORMAL); - case improve: - return rf69_write_reg(spi, REG_TESTDAGC, DAGC_IMPROVED_LOWBETA0); - case improve_for_low_modulation_index: - return rf69_write_reg(spi, REG_TESTDAGC, DAGC_IMPROVED_LOWBETA1); - default: + static const u8 dagc_map[] = { + [normal_mode] = DAGC_NORMAL, + [improve] = DAGC_IMPROVED_LOWBETA0, + [improve_for_low_modulation_index] = DAGC_IMPROVED_LOWBETA1, + }; + + if (unlikely(dagc >= ARRAY_SIZE(dagc_map))) { dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; } + + return rf69_write_reg(spi, REG_TESTDAGC, dagc_map[dagc]); } /*-------------------------------------------------------------------------*/ From ecfacacf3ff0feef2387b4c7440b256aa798065d Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Mon, 25 Jun 2018 13:52:23 +0200 Subject: [PATCH 168/903] staging: pi433: add SPDX-License-Identifier tag Use GPL-2.0+ based on the license text in each of the files. Signed-off-by: Valentin Vidic Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 1 + drivers/staging/pi433/pi433_if.h | 3 ++- drivers/staging/pi433/rf69.c | 1 + drivers/staging/pi433/rf69.h | 3 ++- drivers/staging/pi433/rf69_enum.h | 3 ++- drivers/staging/pi433/rf69_registers.h | 3 ++- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 0638fd5f14d9..293602d87c0f 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * userspace interface for pi433 radio module * diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index b6e214c29ddf..0e0c1b0ab1a6 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -1,4 +1,5 @@ -/* +/* SPDX-License-Identifier: GPL-2.0+ + * * include/linux/TODO * * userspace interface for pi433 radio module diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 341d6901a801..724c24ce1428 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * abstraction of the spi interface of HopeRf rf69 radio module * diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index c131ffbdc2db..2cec9a9c34d2 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -1,4 +1,5 @@ -/* +/* SPDX-License-Identifier: GPL-2.0+ + * * hardware abstraction/register access for HopeRf rf69 radio module * * Copyright (C) 2016 Wolf-Entwicklungen diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi433/rf69_enum.h index 493bd0025453..de3b7e32dad7 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -1,4 +1,5 @@ -/* +/* SPDX-License-Identifier: GPL-2.0+ + * * enumerations for HopeRf rf69 radio module * * Copyright (C) 2016 Wolf-Entwicklungen diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h index 33fd91518bb0..ea19c1ca7509 100644 --- a/drivers/staging/pi433/rf69_registers.h +++ b/drivers/staging/pi433/rf69_registers.h @@ -1,4 +1,5 @@ -/* +/* SPDX-License-Identifier: GPL-2.0+ + * * register description for HopeRf rf69 radio module * * Copyright (C) 2016 Wolf-Entwicklungen From e8b8fc8a38b5ea3c10e2eb88b7805187ae7be6c5 Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Mon, 25 Jun 2018 14:04:41 +0200 Subject: [PATCH 169/903] staging: pi433: cleanup comments in rf69.h Fixes checkpatch warning: WARNING: line over 80 characters Signed-off-by: Valentin Vidic Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/rf69.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 2cec9a9c34d2..319b86c14234 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -21,10 +21,11 @@ #include "rf69_enum.h" #include "rf69_registers.h" -#define F_OSC 32000000 /* in Hz */ -#define FREQUENCY 433920000 /* in Hz, modifying this value impacts CE certification */ -#define FIFO_SIZE 66 /* in byte */ -#define FIFO_THRESHOLD 15 /* in byte */ +/* NOTE: Modifying FREQUENCY value impacts CE certification */ +#define F_OSC 32000000 /* Hz */ +#define FREQUENCY 433920000 /* Hz */ +#define FIFO_SIZE 66 /* bytes */ +#define FIFO_THRESHOLD 15 /* bytes */ int rf69_set_mode(struct spi_device *spi, enum mode mode); int rf69_set_data_mode(struct spi_device *spi, u8 data_mode); From 26472590a6b7b9ec24ce9a00247a79a6bead4ba6 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:30 -0700 Subject: [PATCH 170/903] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()'. Wrap lines longer than 80 characters where possible, delete double newlines, and fix alignment per the kernel coding style guidelines. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/hal/hal_com_phycfg.c | 108 ++++++++++-------- 1 file changed, 58 insertions(+), 50 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 3922d0308a81..5f727a7c16fd 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1612,46 +1612,45 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel) return channelIndex; } -s8 PHY_GetTxPowerLimit( - struct adapter *Adapter, - u32 RegPwrTblSel, - enum BAND_TYPE Band, - enum CHANNEL_WIDTH Bandwidth, - u8 RfPath, - u8 DataRate, - u8 Channel -) +s8 PHY_GetTxPowerLimit(struct adapter *Adapter, u32 RegPwrTblSel, + enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth, + u8 RfPath, u8 DataRate, u8 Channel) { - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - s16 band = -1, regulation = -1, bandwidth = -1, rateSection = -1, channel = -1; + s16 band = -1; + s16 regulation = -1; + s16 bandwidth = -1; + s16 rateSection = -1; + s16 channel = -1; s8 powerLimit = MAX_POWER_INDEX; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - if ((Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory != 1) || - Adapter->registrypriv.RegEnableTxPowerLimit == 0) + if (((Adapter->registrypriv.RegEnableTxPowerLimit == 2) && + (pHalData->EEPROMRegulatory != 1)) || + (Adapter->registrypriv.RegEnableTxPowerLimit == 0)) return MAX_POWER_INDEX; switch (Adapter->registrypriv.RegPwrTblSel) { case 1: - regulation = TXPWR_LMT_ETSI; - break; + regulation = TXPWR_LMT_ETSI; + break; case 2: - regulation = TXPWR_LMT_MKK; - break; + regulation = TXPWR_LMT_MKK; + break; case 3: - regulation = TXPWR_LMT_FCC; - break; - + regulation = TXPWR_LMT_FCC; + break; case 4: - regulation = TXPWR_LMT_WW; - break; - + regulation = TXPWR_LMT_WW; + break; default: - regulation = (Band == BAND_ON_2_4G) ? pHalData->Regulation2_4G : pHalData->Regulation5G; - break; + regulation = (Band == BAND_ON_2_4G) ? + pHalData->Regulation2_4G : + pHalData->Regulation5G; + break; } - /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", Adapter->registrypriv.RegPwrTblSel, regulation); */ - + /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", */ + /* Adapter->registrypriv.RegPwrTblSel, regulation); */ if (Band == BAND_ON_2_4G) band = 0; @@ -1730,8 +1729,8 @@ s8 PHY_GetTxPowerLimit( break; } - if (Band == BAND_ON_5G && rateSection == 0) - DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate); + if (Band == BAND_ON_5G && rateSection == 0) + DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate); /* workaround for wrong index combination to obtain tx power limit, */ /* OFDM only exists in BW 20M */ @@ -1745,22 +1744,26 @@ s8 PHY_GetTxPowerLimit( /* workaround for wrong indxe combination to obtain tx power limit, */ /* HT on 80M will reference to HT on 40M */ - if ((rateSection == 2 || rateSection == 3) && Band == BAND_ON_5G && bandwidth == 2) { + if ((rateSection == 2 || rateSection == 3) && + Band == BAND_ON_5G && bandwidth == 2) { bandwidth = 1; } if (Band == BAND_ON_2_4G) - channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, Channel); + channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, + Channel); else if (Band == BAND_ON_5G) - channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, Channel); + channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, + Channel); else if (Band == BAND_ON_BOTH) { /* BAND_ON_BOTH don't care temporarily */ } if (band == -1 || regulation == -1 || bandwidth == -1 || - rateSection == -1 || channel == -1) { + rateSection == -1 || channel == -1) { /* DBG_871X("Wrong index value to access power limit table [band %d][regulation %d][bandwidth %d][rf_path %d][rate_section %d][chnlGroup %d]\n", */ - /* band, regulation, bandwidth, RfPath, rateSection, channelGroup); */ + /* band, regulation, bandwidth, RfPath, */ + /* rateSection, channelGroup); */ return MAX_POWER_INDEX; } @@ -1768,18 +1771,26 @@ s8 PHY_GetTxPowerLimit( if (Band == BAND_ON_2_4G) { s8 limits[10] = {0}; u8 i = 0; for (i = 0; i < MAX_REGULATION_NUM; i++) - limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth][rateSection][channel][RfPath]; + limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth] + [rateSection] + [channel][RfPath]; - powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : - pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channel][RfPath]; + powerLimit = (regulation == TXPWR_LMT_WW) ? + phy_GetWorldWideLimit(limits) : + pHalData->TxPwrLimit_2_4G[regulation][bandwidth] + [rateSection][channel][RfPath]; } else if (Band == BAND_ON_5G) { s8 limits[10] = {0}; u8 i = 0; for (i = 0; i < MAX_REGULATION_NUM; ++i) - limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth][rateSection][channel][RfPath]; + limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth] + [rateSection] + [channel][RfPath]; - powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : - pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channel][RfPath]; + powerLimit = (regulation == TXPWR_LMT_WW) ? + phy_GetWorldWideLimit(limits) : + pHalData->TxPwrLimit_5G[regulation][bandwidth] + [rateSection][channel][RfPath]; } else DBG_871X("No power limit table of the specified band\n"); @@ -1789,22 +1800,20 @@ s8 PHY_GetTxPowerLimit( if (Band == BAND_ON_5G && powerLimit == MAX_POWER_INDEX) { if (bandwidth == 0 || bandwidth == 1) { RT_TRACE(COMP_INIT, DBG_LOUD, ("No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n", - band, bandwidth, rateSection, RfPath)); + band, bandwidth, + rateSection, RfPath)); if (rateSection == 2) - powerLimit = pHalData->TxPwrLimit_5G[regulation] - [bandwidth][4][channelGroup][RfPath]; + powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][4][channelGroup][RfPath]; else if (rateSection == 4) - powerLimit = pHalData->TxPwrLimit_5G[regulation] - [bandwidth][2][channelGroup][RfPath]; + powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][2][channelGroup][RfPath]; else if (rateSection == 3) - powerLimit = pHalData->TxPwrLimit_5G[regulation] - [bandwidth][5][channelGroup][RfPath]; + powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][5][channelGroup][RfPath]; else if (rateSection == 5) - powerLimit = pHalData->TxPwrLimit_5G[regulation] - [bandwidth][3][channelGroup][RfPath]; + powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][3][channelGroup][RfPath]; } } */ + /* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */ /* regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit); */ return powerLimit; @@ -3294,4 +3303,3 @@ void phy_free_filebuf(struct adapter *padapter) vfree(pHalData->rf_tx_pwr_lmt); } - From cc2231a3bbcfcdd858cbbed1f2a0fbb9c230438b Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:31 -0700 Subject: [PATCH 171/903] staging: rtl8723bs: Rename PHY_GetTxPowerLimit(). Rename camel-case 'PHY_GetTxPowerLimit()' to 'phy_get_tx_pwr_lmt()'. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 6 +++--- drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c | 2 +- drivers/staging/rtl8723bs/include/hal_com_phycfg.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 5f727a7c16fd..4ab624f5ece0 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1612,9 +1612,9 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel) return channelIndex; } -s8 PHY_GetTxPowerLimit(struct adapter *Adapter, u32 RegPwrTblSel, - enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth, - u8 RfPath, u8 DataRate, u8 Channel) +s8 phy_get_tx_pwr_lmt(struct adapter *Adapter, u32 RegPwrTblSel, + enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth, + u8 RfPath, u8 DataRate, u8 Channel) { s16 band = -1; s16 regulation = -1; diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c index 50428f688859..78a4828ecb65 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c @@ -688,7 +688,7 @@ u8 PHY_GetTxPowerIndex_8723B( txPower = (s8) PHY_GetTxPowerIndexBase(padapter, RFPath, Rate, BandWidth, Channel, &bIn24G); powerDiffByRate = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, ODM_RF_PATH_A, RF_1TX, Rate); - limit = PHY_GetTxPowerLimit( + limit = phy_get_tx_pwr_lmt( padapter, padapter->registrypriv.RegPwrTblSel, (u8)(!bIn24G), diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h index c5184315f82f..f841546584a7 100644 --- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h +++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h @@ -177,7 +177,7 @@ u8 Channel, bool *bIn24G ); -s8 PHY_GetTxPowerLimit (struct adapter *adapter, u32 RegPwrTblSel, +s8 phy_get_tx_pwr_lmt (struct adapter *adapter, u32 RegPwrTblSel, enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth, u8 RfPath, u8 DataRate, From 717209ec616cb4216732e4598afd4aa587ea54c2 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:32 -0700 Subject: [PATCH 172/903] staging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt(). Change camel-case names to snake-case names; to avoid variable name conflicts, rename table index variables to idx_*. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/hal/hal_com_phycfg.c | 192 +++++++++--------- 1 file changed, 101 insertions(+), 91 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 4ab624f5ece0..7e27d7ff29fa 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1612,211 +1612,221 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel) return channelIndex; } -s8 phy_get_tx_pwr_lmt(struct adapter *Adapter, u32 RegPwrTblSel, - enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth, - u8 RfPath, u8 DataRate, u8 Channel) +s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, + enum BAND_TYPE band_type, enum CHANNEL_WIDTH bandwidth, + u8 rf_path, u8 data_rate, u8 channel) { - s16 band = -1; - s16 regulation = -1; - s16 bandwidth = -1; - s16 rateSection = -1; - s16 channel = -1; - s8 powerLimit = MAX_POWER_INDEX; - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + s16 idx_band = -1; + s16 idx_regulation = -1; + s16 idx_bandwidth = -1; + s16 idx_rate_sctn = -1; + s16 idx_channel = -1; + s8 pwr_lmt = MAX_POWER_INDEX; + struct hal_com_data *hal_data = GET_HAL_DATA(adapter); - if (((Adapter->registrypriv.RegEnableTxPowerLimit == 2) && - (pHalData->EEPROMRegulatory != 1)) || - (Adapter->registrypriv.RegEnableTxPowerLimit == 0)) + if (((adapter->registrypriv.RegEnableTxPowerLimit == 2) && + (hal_data->EEPROMRegulatory != 1)) || + (adapter->registrypriv.RegEnableTxPowerLimit == 0)) return MAX_POWER_INDEX; - switch (Adapter->registrypriv.RegPwrTblSel) { + switch (adapter->registrypriv.RegPwrTblSel) { case 1: - regulation = TXPWR_LMT_ETSI; + idx_regulation = TXPWR_LMT_ETSI; break; case 2: - regulation = TXPWR_LMT_MKK; + idx_regulation = TXPWR_LMT_MKK; break; case 3: - regulation = TXPWR_LMT_FCC; + idx_regulation = TXPWR_LMT_FCC; break; case 4: - regulation = TXPWR_LMT_WW; + idx_regulation = TXPWR_LMT_WW; break; default: - regulation = (Band == BAND_ON_2_4G) ? - pHalData->Regulation2_4G : - pHalData->Regulation5G; + idx_regulation = (band_type == BAND_ON_2_4G) ? + hal_data->Regulation2_4G : + hal_data->Regulation5G; break; } /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", */ - /* Adapter->registrypriv.RegPwrTblSel, regulation); */ + /* adapter->registrypriv.RegPwrTblSel, idx_regulation); */ - if (Band == BAND_ON_2_4G) - band = 0; - else if (Band == BAND_ON_5G) - band = 1; + if (band_type == BAND_ON_2_4G) + idx_band = 0; + else if (band_type == BAND_ON_5G) + idx_band = 1; - if (Bandwidth == CHANNEL_WIDTH_20) - bandwidth = 0; - else if (Bandwidth == CHANNEL_WIDTH_40) - bandwidth = 1; - else if (Bandwidth == CHANNEL_WIDTH_80) - bandwidth = 2; - else if (Bandwidth == CHANNEL_WIDTH_160) - bandwidth = 3; + if (bandwidth == CHANNEL_WIDTH_20) + idx_bandwidth = 0; + else if (bandwidth == CHANNEL_WIDTH_40) + idx_bandwidth = 1; + else if (bandwidth == CHANNEL_WIDTH_80) + idx_bandwidth = 2; + else if (bandwidth == CHANNEL_WIDTH_160) + idx_bandwidth = 3; - switch (DataRate) { + switch (data_rate) { case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M: - rateSection = 0; + idx_rate_sctn = 0; break; case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M: case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M: - rateSection = 1; + idx_rate_sctn = 1; break; case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3: case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7: - rateSection = 2; + idx_rate_sctn = 2; break; case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11: case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15: - rateSection = 3; + idx_rate_sctn = 3; break; case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19: case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23: - rateSection = 4; + idx_rate_sctn = 4; break; case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27: case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31: - rateSection = 5; + idx_rate_sctn = 5; break; case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2: case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5: case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8: case MGN_VHT1SS_MCS9: - rateSection = 6; + idx_rate_sctn = 6; break; case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2: case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5: case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8: case MGN_VHT2SS_MCS9: - rateSection = 7; + idx_rate_sctn = 7; break; case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2: case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5: case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8: case MGN_VHT3SS_MCS9: - rateSection = 8; + idx_rate_sctn = 8; break; case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2: case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5: case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8: case MGN_VHT4SS_MCS9: - rateSection = 9; + idx_rate_sctn = 9; break; default: - DBG_871X("Wrong rate 0x%x\n", DataRate); + DBG_871X("Wrong rate 0x%x\n", data_rate); break; } - if (Band == BAND_ON_5G && rateSection == 0) + if (band_type == BAND_ON_5G && idx_rate_sctn == 0) DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate); /* workaround for wrong index combination to obtain tx power limit, */ /* OFDM only exists in BW 20M */ - if (rateSection == 1) - bandwidth = 0; + if (idx_rate_sctn == 1) + idx_bandwidth = 0; /* workaround for wrong index combination to obtain tx power limit, */ /* CCK table will only be given in BW 20M */ - if (rateSection == 0) - bandwidth = 0; + if (idx_rate_sctn == 0) + idx_bandwidth = 0; /* workaround for wrong indxe combination to obtain tx power limit, */ /* HT on 80M will reference to HT on 40M */ - if ((rateSection == 2 || rateSection == 3) && - Band == BAND_ON_5G && bandwidth == 2) { - bandwidth = 1; + if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) && + band_type == BAND_ON_5G && idx_bandwidth == 2) { + idx_bandwidth = 1; } - if (Band == BAND_ON_2_4G) + if (band_type == BAND_ON_2_4G) channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, - Channel); - else if (Band == BAND_ON_5G) + channel); + else if (band_type == BAND_ON_5G) channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, - Channel); - else if (Band == BAND_ON_BOTH) { + channel); + else if (band_type == BAND_ON_BOTH) { /* BAND_ON_BOTH don't care temporarily */ } - if (band == -1 || regulation == -1 || bandwidth == -1 || - rateSection == -1 || channel == -1) { + if (idx_band == -1 || idx_regulation == -1 || idx_bandwidth == -1 || + idx_rate_sctn == -1 || idx_channel == -1) { /* DBG_871X("Wrong index value to access power limit table [band %d][regulation %d][bandwidth %d][rf_path %d][rate_section %d][chnlGroup %d]\n", */ - /* band, regulation, bandwidth, RfPath, */ - /* rateSection, channelGroup); */ + /* idx_band, idx_regulation, idx_bandwidth, rf_path, */ + /* idx_rate_sctn, channel); */ return MAX_POWER_INDEX; } - if (Band == BAND_ON_2_4G) { + if (band_type == BAND_ON_2_4G) { s8 limits[10] = {0}; u8 i = 0; for (i = 0; i < MAX_REGULATION_NUM; i++) - limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth] - [rateSection] - [channel][RfPath]; + limits[i] = hal_data->TxPwrLimit_2_4G[i] + [idx_bandwidth] + [idx_rate_sctn] + [idx_channel] + [rf_path]; - powerLimit = (regulation == TXPWR_LMT_WW) ? + pwr_lmt = (idx_regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : - pHalData->TxPwrLimit_2_4G[regulation][bandwidth] - [rateSection][channel][RfPath]; + hal_data->TxPwrLimit_2_4G[idx_regulation] + [idx_bandwidth] + [idx_rate_sctn] + [idx_channel] + [rf_path]; - } else if (Band == BAND_ON_5G) { + } else if (band_type == BAND_ON_5G) { s8 limits[10] = {0}; u8 i = 0; for (i = 0; i < MAX_REGULATION_NUM; ++i) - limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth] - [rateSection] - [channel][RfPath]; + limits[i] = hal_data->TxPwrLimit_5G[i] + [idx_bandwidth] + [idx_rate_sctn] + [idx_channel] + [rf_path]; - powerLimit = (regulation == TXPWR_LMT_WW) ? + pwr_lmt = (idx_regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : - pHalData->TxPwrLimit_5G[regulation][bandwidth] - [rateSection][channel][RfPath]; + hal_data->TxPwrLimit_5G[idx_regulation] + [idx_bandwidth] + [idx_rate_sctn] + [idx_channel] + [rf_path]; } else DBG_871X("No power limit table of the specified band\n"); /* combine 5G VHT & HT rate */ /* 5G 20M and 40M HT and VHT can cross reference */ /* - if (Band == BAND_ON_5G && powerLimit == MAX_POWER_INDEX) { - if (bandwidth == 0 || bandwidth == 1) { + if (band_type == BAND_ON_5G && pwr_lmt == MAX_POWER_INDEX) { + if (idx_bandwidth == 0 || idx_bandwidth == 1) { RT_TRACE(COMP_INIT, DBG_LOUD, ("No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n", - band, bandwidth, - rateSection, RfPath)); - if (rateSection == 2) - powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][4][channelGroup][RfPath]; - else if (rateSection == 4) - powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][2][channelGroup][RfPath]; - else if (rateSection == 3) - powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][5][channelGroup][RfPath]; - else if (rateSection == 5) - powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][3][channelGroup][RfPath]; + idx_band, idx_bandwidth, + idx_rate_sctn, rf_path)); + if (idx_rate_sctn == 2) + pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][4][idx_channel][rf_path]; + else if (idx_rate_sctn == 4) + pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][2][idx_channel][rf_path]; + else if (idx_rate_sctn == 3) + pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][5][idx_channel][rf_path]; + else if (idx_rate_sctn == 5) + pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][3][idx_channel][rf_path]; } } */ /* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */ - /* regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit); */ - return powerLimit; + /* idx_regulation, hal_data->CurrentBandType, bandwidth, rf_path, data_rate, channel, pwr_lmt); */ + return pwr_lmt; } static void phy_CrossReferenceHTAndVHTTxPowerLimit(struct adapter *padapter) From fdf620d6970c93d9bfe8975130d49d2a060153c1 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:33 -0700 Subject: [PATCH 173/903] staging: rtl8723bs: Combine if statements with equivalent body. Two if statements that carry out the same operation can be combined with a logical OR. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 7e27d7ff29fa..5d44aee44eb1 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1734,12 +1734,8 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, /* workaround for wrong index combination to obtain tx power limit, */ /* OFDM only exists in BW 20M */ - if (idx_rate_sctn == 1) - idx_bandwidth = 0; - - /* workaround for wrong index combination to obtain tx power limit, */ /* CCK table will only be given in BW 20M */ - if (idx_rate_sctn == 0) + if (idx_rate_sctn == 0 || idx_rate_sctn == 1) idx_bandwidth = 0; /* workaround for wrong indxe combination to obtain tx power limit, */ From ac41f631d4187f072e9e693fbdb4423e2e0f0e00 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:34 -0700 Subject: [PATCH 174/903] staging: rtl8723bs: Remove empty else-if conditional. This else-if conditional block does nothing; remove it. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 5d44aee44eb1..6ae646ec3d06 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1751,9 +1751,6 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, else if (band_type == BAND_ON_5G) channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, channel); - else if (band_type == BAND_ON_BOTH) { - /* BAND_ON_BOTH don't care temporarily */ - } if (idx_band == -1 || idx_regulation == -1 || idx_bandwidth == -1 || idx_rate_sctn == -1 || idx_channel == -1) { From 9ca65c3041fd296af74ff7e356865217fba58e50 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:35 -0700 Subject: [PATCH 175/903] staging: rtl8723bs: Move rate section index lookup to new function. The rate section lookup is a large switch statement in the middle of 'phy_get_tx_pwr_lmt()'; refactor this statement into it's own function for increased readability. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/hal/hal_com_phycfg.c | 109 ++++++++---------- 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 6ae646ec3d06..4b5219481b33 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1612,6 +1612,52 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel) return channelIndex; } +static s16 get_rate_sctn_idx(const u8 rate) +{ + switch (rate) { + case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M: + return 0; + case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M: + case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M: + return 1; + case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3: + case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7: + return 2; + case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11: + case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15: + return 3; + case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19: + case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23: + return 4; + case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27: + case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31: + return 5; + case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2: + case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5: + case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8: + case MGN_VHT1SS_MCS9: + return 6; + case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2: + case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5: + case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8: + case MGN_VHT2SS_MCS9: + return 7; + case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2: + case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5: + case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8: + case MGN_VHT3SS_MCS9: + return 8; + case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2: + case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5: + case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8: + case MGN_VHT4SS_MCS9: + return 9; + default: + DBG_871X("Wrong rate 0x%x\n", rate); + return -1; + } +} + s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, enum BAND_TYPE band_type, enum CHANNEL_WIDTH bandwidth, u8 rf_path, u8 data_rate, u8 channel) @@ -1666,68 +1712,7 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, else if (bandwidth == CHANNEL_WIDTH_160) idx_bandwidth = 3; - switch (data_rate) { - case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M: - idx_rate_sctn = 0; - break; - - case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M: - case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M: - idx_rate_sctn = 1; - break; - - case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3: - case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7: - idx_rate_sctn = 2; - break; - - case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11: - case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15: - idx_rate_sctn = 3; - break; - - case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19: - case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23: - idx_rate_sctn = 4; - break; - - case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27: - case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31: - idx_rate_sctn = 5; - break; - - case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2: - case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5: - case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8: - case MGN_VHT1SS_MCS9: - idx_rate_sctn = 6; - break; - - case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2: - case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5: - case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8: - case MGN_VHT2SS_MCS9: - idx_rate_sctn = 7; - break; - - case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2: - case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5: - case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8: - case MGN_VHT3SS_MCS9: - idx_rate_sctn = 8; - break; - - case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2: - case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5: - case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8: - case MGN_VHT4SS_MCS9: - idx_rate_sctn = 9; - break; - - default: - DBG_871X("Wrong rate 0x%x\n", data_rate); - break; - } + idx_rate_sctn = get_rate_sctn_idx(data_rate); if (band_type == BAND_ON_5G && idx_rate_sctn == 0) DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate); From 81dff62b3d03e9050a6ab4da3d1c8fd8f14b2495 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:36 -0700 Subject: [PATCH 176/903] staging: rtl8723bs: Move bandwidth index lookup to new function. Factoring out the conditional lookup of bandwidth index into the power limit table into it's own function simplifies the logic of 'phy_get_tx_pwr_lmt()'. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/hal/hal_com_phycfg.c | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 4b5219481b33..6d8a07ac7bb3 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1612,6 +1612,22 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel) return channelIndex; } +static s16 get_bandwidth_idx(const enum CHANNEL_WIDTH bandwidth) +{ + switch (bandwidth) { + case CHANNEL_WIDTH_20: + return 0; + case CHANNEL_WIDTH_40: + return 1; + case CHANNEL_WIDTH_80: + return 2; + case CHANNEL_WIDTH_160: + return 3; + default: + return -1; + } +} + static s16 get_rate_sctn_idx(const u8 rate) { switch (rate) { @@ -1703,15 +1719,7 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, else if (band_type == BAND_ON_5G) idx_band = 1; - if (bandwidth == CHANNEL_WIDTH_20) - idx_bandwidth = 0; - else if (bandwidth == CHANNEL_WIDTH_40) - idx_bandwidth = 1; - else if (bandwidth == CHANNEL_WIDTH_80) - idx_bandwidth = 2; - else if (bandwidth == CHANNEL_WIDTH_160) - idx_bandwidth = 3; - + idx_bandwidth = get_bandwidth_idx(bandwidth); idx_rate_sctn = get_rate_sctn_idx(data_rate); if (band_type == BAND_ON_5G && idx_rate_sctn == 0) From 871081d4e95778120b7dbe150b627a6b854e3141 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:37 -0700 Subject: [PATCH 177/903] staging: rtl8723bs: Fix spelling mistake in comment. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 6d8a07ac7bb3..dd097df86fa3 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1731,7 +1731,7 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, if (idx_rate_sctn == 0 || idx_rate_sctn == 1) idx_bandwidth = 0; - /* workaround for wrong indxe combination to obtain tx power limit, */ + /* workaround for wrong index combination to obtain tx power limit, */ /* HT on 80M will reference to HT on 40M */ if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) && band_type == BAND_ON_5G && idx_bandwidth == 2) { From f5746848212021db200ad6a24d394cbadf4f17cf Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:38 -0700 Subject: [PATCH 178/903] staging: rtl8723bs: Merge conditionals with similar bodies. Two conditionals that set 'channel' based on 'band_type' in 'phy_get_tx_pwr_lmt()' can be simplified into one single-line conditional. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index dd097df86fa3..9e6dc238c028 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1738,12 +1738,8 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, idx_bandwidth = 1; } - if (band_type == BAND_ON_2_4G) - channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, - channel); - else if (band_type == BAND_ON_5G) - channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, - channel); + if (band_type == BAND_ON_2_4G || band_type == BAND_ON_5G) + channel = phy_GetChannelIndexOfTxPowerLimit(band_type, channel); if (idx_band == -1 || idx_regulation == -1 || idx_bandwidth == -1 || idx_rate_sctn == -1 || idx_channel == -1) { From 904604397d163ca391862b7c71d3387416463aab Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:39 -0700 Subject: [PATCH 179/903] staging: rtl8723bs: Merge workaround conditionals into single else-if. The if conditionals used to work around wrong TX power limit indices can be condensed into a single if/else-if statement for more concise expression. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 9e6dc238c028..0e49f0973c12 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1728,15 +1728,12 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, /* workaround for wrong index combination to obtain tx power limit, */ /* OFDM only exists in BW 20M */ /* CCK table will only be given in BW 20M */ + /* HT on 80M will reference to HT on 40M */ if (idx_rate_sctn == 0 || idx_rate_sctn == 1) idx_bandwidth = 0; - - /* workaround for wrong index combination to obtain tx power limit, */ - /* HT on 80M will reference to HT on 40M */ - if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) && - band_type == BAND_ON_5G && idx_bandwidth == 2) { + else if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) && + (band_type == BAND_ON_5G) && (idx_bandwidth == 2)) idx_bandwidth = 1; - } if (band_type == BAND_ON_2_4G || band_type == BAND_ON_5G) channel = phy_GetChannelIndexOfTxPowerLimit(band_type, channel); From 8cc46a2cc2a1060538e7051f54bd921e8575f039 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Sat, 16 Jun 2018 22:30:40 -0700 Subject: [PATCH 180/903] staging: rtl8723bs: Add missing curly braces on else statement. Fix 'braces {} should be used on all arms of this statement' coding style problem in 'phy_get_tx_pwr_lmt()'. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 0e49f0973c12..0d2c61b67d0e 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1780,8 +1780,9 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, [idx_rate_sctn] [idx_channel] [rf_path]; - } else + } else { DBG_871X("No power limit table of the specified band\n"); + } /* combine 5G VHT & HT rate */ /* 5G 20M and 40M HT and VHT can cross reference */ From 8498887660dfc9a07659ad545bfec389eb1d1d3f Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 18 Jun 2018 17:06:50 +0200 Subject: [PATCH 181/903] staging: rtl8723bs: remove get_monotonic_boottime() get_monotonic_boottime() is deprecated because it uses the old 'timespec' structure. This replaces one of the last callers with a call to ktime_get_boottime, which also simplifies it a bit by avoiding a double conversion. Signed-off-by: Arnd Bergmann Reviewed-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 02178e25fbb8..73fc3a742f74 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -233,13 +233,6 @@ static int rtw_ieee80211_channel_to_frequency(int chan, int band) return 0; /* not supported */ } -static u64 rtw_get_systime_us(void) -{ - struct timespec ts; - get_monotonic_boottime(&ts); - return ((u64)ts.tv_sec*1000000) + ts.tv_nsec / 1000; -} - #define MAX_BSSINFO_LEN 1000 struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wlan_network *pnetwork) { @@ -331,7 +324,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl notify_channel = ieee80211_get_channel(wiphy, freq); - notify_timestamp = rtw_get_systime_us(); + notify_timestamp = ktime_to_us(ktime_get_boottime()); notify_interval = le16_to_cpu(*(__le16 *)rtw_get_beacon_interval_from_ie(pnetwork->network.IEs)); notify_capability = le16_to_cpu(*(__le16 *)rtw_get_capability_from_ie(pnetwork->network.IEs)); From 05e540b27718fee5135655e9d60ae05069dcba36 Mon Sep 17 00:00:00 2001 From: Jia-Ju Bai Date: Wed, 20 Jun 2018 17:50:16 +0800 Subject: [PATCH 182/903] staging: rtl8723bs: Fix two possible sleep-in-atomic-context bugs in translate_scan() The driver may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16.7 are: [FUNC] kzalloc(GFP_KERNEL) drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 323: kzalloc in translate_scan drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1554: translate_scan in rtw_wx_get_scan drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1533: spin_lock_bh in rtw_wx_get_scan [FUNC] kzalloc(GFP_KERNEL) drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 455: kzalloc in translate_scan drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1554: translate_scan in rtw_wx_get_scan drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1533: spin_lock_bh in rtw_wx_get_scan To fix these bugs, GFP_KERNEL is replaced with GFP_ATOMIC. These bugs are found by my static analysis tool (DSAC-2) and checked by my code review. Signed-off-by: Jia-Ju Bai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 39502156f652..5f029198bcaf 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -313,7 +313,7 @@ static char *translate_scan(struct adapter *padapter, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); - buf = kzalloc(MAX_WPA_IE_LEN*2, GFP_KERNEL); + buf = kzalloc(MAX_WPA_IE_LEN*2, GFP_ATOMIC); if (!buf) return start; if (wpa_len > 0) { @@ -445,7 +445,7 @@ static char *translate_scan(struct adapter *padapter, u8 *buf; u8 *p, *pos; - buf = kzalloc(MAX_WPA_IE_LEN, GFP_KERNEL); + buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC); if (!buf) goto exit; p = buf; From 3520c7a47b390e08531c145275f9c8a040458cff Mon Sep 17 00:00:00 2001 From: Henriette Hofmeier Date: Fri, 22 Jun 2018 16:01:57 +0200 Subject: [PATCH 183/903] staging: rtl8723bs: Move definition open brace Move open braces of definitions to the next line to comply with codestyle. Criticized by checkpatch. Signed-off-by: Henriette Hofmeier Signed-off-by: Florian Harbecke Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index a81e13011c49..0952d15f6d40 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -331,7 +331,8 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) static int has_channel(RT_CHANNEL_INFO *channel_set, u8 chanset_size, - u8 chan) { + u8 chan) +{ int i; for (i = 0; i < chanset_size; i++) { @@ -345,7 +346,8 @@ static int has_channel(RT_CHANNEL_INFO *channel_set, static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel_set, u8 chanset_size, - struct p2p_channels *channel_list) { + struct p2p_channels *channel_list) +{ struct p2p_oper_class_map op_class[] = { { IEEE80211G, 81, 1, 13, 1, BW20 }, From cbb2cb50c05600b32d6d198f2d3588299c053e12 Mon Sep 17 00:00:00 2001 From: Henriette Hofmeier Date: Fri, 22 Jun 2018 16:01:58 +0200 Subject: [PATCH 184/903] staging: rtl8723bs: Remove unnecessary initializations Remove initializations of global variables with 0. Criticized by checkpatch. Signed-off-by: Henriette Hofmeier Signed-off-by: Florian Harbecke Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_efuse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c index bbf6f3fa21ea..9d265f49d035 100644 --- a/drivers/staging/rtl8723bs/core/rtw_efuse.c +++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c @@ -13,18 +13,18 @@ /*------------------------Define local variable------------------------------*/ -u8 fakeEfuseBank = 0; -u32 fakeEfuseUsedBytes = 0; +u8 fakeEfuseBank; +u32 fakeEfuseUsedBytes; u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE] = {0}; u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN] = {0}; u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN] = {0}; -u32 BTEfuseUsedBytes = 0; +u32 BTEfuseUsedBytes; u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; -u32 fakeBTEfuseUsedBytes = 0; +u32 fakeBTEfuseUsedBytes; u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; From e8466ea7bc3affde1733663cf17d657b7587f03c Mon Sep 17 00:00:00 2001 From: Henriette Hofmeier Date: Fri, 22 Jun 2018 16:01:59 +0200 Subject: [PATCH 185/903] staging: rtl8723bs: Fix comment on variable init Change comment from 'local variable' to 'global variables' and change style to comply with coding-style. Signed-off-by: Henriette Hofmeier Signed-off-by: Florian Harbecke Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_efuse.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c index 9d265f49d035..c306ad7e395c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_efuse.c +++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c @@ -12,7 +12,7 @@ #include -/*------------------------Define local variable------------------------------*/ +/* Define global variables */ u8 fakeEfuseBank; u32 fakeEfuseUsedBytes; u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE] = {0}; @@ -28,12 +28,9 @@ u32 fakeBTEfuseUsedBytes; u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; -/*------------------------Define local variable------------------------------*/ -/* */ #define REG_EFUSE_CTRL 0x0030 #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ -/* */ bool Efuse_Read1ByteFromFakeContent( From 7c5746c4487349976d524596f8779c63ac063728 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 25 Jun 2018 16:50:25 +0200 Subject: [PATCH 186/903] staging: rtl8723bs: remove rtw_set_tx_chksum_offload() The function rtw_set_tx_chksum_offload() has empty definition. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 -- drivers/staging/rtl8723bs/include/xmit_osdep.h | 2 -- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 5 ----- 3 files changed, 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index aaabffb0a199..3e7c1f07b8b4 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -845,8 +845,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib /* pattrib->priority = 5; force to used VI queue, for testing */ - rtw_set_tx_chksum_offload(pkt, pattrib); - exit: return res; } diff --git a/drivers/staging/rtl8723bs/include/xmit_osdep.h b/drivers/staging/rtl8723bs/include/xmit_osdep.h index 377b453de199..a61412b54ec0 100644 --- a/drivers/staging/rtl8723bs/include/xmit_osdep.h +++ b/drivers/staging/rtl8723bs/include/xmit_osdep.h @@ -33,8 +33,6 @@ void rtw_os_xmit_schedule(struct adapter *padapter); int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag); void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag); -extern void rtw_set_tx_chksum_offload(_pkt *pkt, struct pkt_attrib *pattrib); - extern uint rtw_remainder_len(struct pkt_file *pfile); extern void _rtw_open_pktfile(_pkt *pkt, struct pkt_file *pfile); extern uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen); diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index 4da0c6f323d1..2cf903c66854 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -46,11 +46,6 @@ sint rtw_endofpktfile(struct pkt_file *pfile) return false; } -void rtw_set_tx_chksum_offload(_pkt *pkt, struct pkt_attrib *pattrib) -{ - -} - int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag) { if (alloc_sz > 0) { From efc8f3b2f3177c3946f12db838ed58fa032f74c0 Mon Sep 17 00:00:00 2001 From: Marcin Ciupak Date: Fri, 15 Jun 2018 14:21:09 +0000 Subject: [PATCH 187/903] staging: most: fix sparse warning Using plain integer as NULL pointer This patch fixes following sparse warning: Using plain integer as NULL pointer in drivers/staging/most/dim2/dim2.c Signed-off-by: Marcin Ciupak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/dim2/dim2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c index fe90a7cb56f7..31fbc1a75b06 100644 --- a/drivers/staging/most/dim2/dim2.c +++ b/drivers/staging/most/dim2/dim2.c @@ -785,7 +785,7 @@ static int dim2_probe(struct platform_device *pdev) if (ret) return ret; - dev->disable_platform = pdata ? pdata->disable : 0; + dev->disable_platform = pdata ? pdata->disable : NULL; dev_info(&pdev->dev, "sync: num of frames per sub-buffer: %u\n", fcnt); hal_ret = dim_startup(dev->io_base, dev->clk_speed, fcnt); From 5c6a5eb3aa86ecde00fe45410fc384363ee9bc92 Mon Sep 17 00:00:00 2001 From: Omer Efrat Date: Mon, 18 Jun 2018 17:18:11 +0300 Subject: [PATCH 188/903] staging: use BIT_ULL for NL80211_STA_INFO_* attribute types The BIT macro uses unsigned long which some architectures handle as 32 bit and therefore might cause macro's shift to overflow when used on a value equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards). Since 'filled' member in station_info changed to u64, BIT_ULL macro should be used with all NL80211_STA_INFO_* attribute types instead of BIT to prevent future possible bugs when one will use BIT macro for higher attributes by mistake. This commit cleans up all usages of BIT macro with the above field in cfg80211 by changing it to BIT_ULL instead. Signed-off-by: Omer Efrat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 10 +++++----- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 14 +++++++------- drivers/staging/wlan-ng/cfg80211.c | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 73fc3a742f74..af2234798fa8 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1266,16 +1266,16 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, goto exit; } - sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); sinfo->signal = translate_percentage_to_dbm(padapter->recvpriv.signal_strength); - sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); sinfo->txrate.legacy = rtw_get_cur_max_rate(padapter); - sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); sinfo->rx_packets = sta_rx_data_pkts(psta); - sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); sinfo->tx_packets = psta->sta_stats.tx_pkts; } @@ -3006,7 +3006,7 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *nde goto exit; } memcpy(mac, psta->hwaddr, ETH_ALEN); - sinfo->filled = BIT(NL80211_STA_INFO_SIGNAL); + sinfo->filled = BIT_ULL(NL80211_STA_INFO_SIGNAL); sinfo->signal = psta->rssi; exit: diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 1f09925b38df..e96163f38e7b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1141,7 +1141,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, return -ENOENT; } - sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME); wilc_get_inactive_time(vif, mac, &inactive_time); sinfo->inactive_time = 1000 * inactive_time; @@ -1150,11 +1150,11 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, wilc_get_statistics(vif, &stats, true); - sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | - BIT(NL80211_STA_INFO_RX_PACKETS) | - BIT(NL80211_STA_INFO_TX_PACKETS) | - BIT(NL80211_STA_INFO_TX_FAILED) | - BIT(NL80211_STA_INFO_TX_BITRATE); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL) | + BIT_ULL(NL80211_STA_INFO_RX_PACKETS) | + BIT_ULL(NL80211_STA_INFO_TX_PACKETS) | + BIT_ULL(NL80211_STA_INFO_TX_FAILED) | + BIT_ULL(NL80211_STA_INFO_TX_BITRATE); sinfo->signal = stats.rssi; sinfo->rx_packets = stats.rx_cnt; @@ -1775,7 +1775,7 @@ static int dump_station(struct wiphy *wiphy, struct net_device *dev, priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); - sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); wilc_get_rssi(vif, &sinfo->signal); diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 42912257e2b9..07c52e396387 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -282,9 +282,9 @@ static int prism2_get_station(struct wiphy *wiphy, struct net_device *dev, if (result == 0) { sinfo->txrate.legacy = quality.txrate.data; - sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); sinfo->signal = quality.level.data; - sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); } return result; From c238d7b1e5fd6416458d7a7295a6d20ab56a3baa Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 18 Jun 2018 16:38:02 +0200 Subject: [PATCH 189/903] staging: rtsx: remove rtsx_trace() and related code The driver has rather excessive amount of tracing code, which would be better done using ftrace. This is obviously not a main feature of the driver, and it should work just as well without it. Removing it saves over 1300 lines of code and likely makes the driver a bit faster by avoiding lots of calls into the timekeeping code. I came across this while cleaning up the last users of the deprecated getnstimeofday64() function, of which there is one in the now-removed get_current_time() function of the rtsx driver that was only used for tracing. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/Makefile | 2 +- drivers/staging/rts5208/ms.c | 337 ----------------------- drivers/staging/rts5208/rtsx.h | 25 -- drivers/staging/rts5208/rtsx_card.c | 29 -- drivers/staging/rts5208/rtsx_card.h | 1 - drivers/staging/rts5208/rtsx_chip.c | 140 ---------- drivers/staging/rts5208/rtsx_chip.h | 18 -- drivers/staging/rts5208/rtsx_scsi.c | 216 --------------- drivers/staging/rts5208/rtsx_transport.c | 1 - drivers/staging/rts5208/sd.c | 326 ---------------------- drivers/staging/rts5208/spi.c | 71 ----- drivers/staging/rts5208/trace.c | 27 -- drivers/staging/rts5208/trace.h | 40 --- drivers/staging/rts5208/xd.c | 112 -------- 14 files changed, 1 insertion(+), 1344 deletions(-) delete mode 100644 drivers/staging/rts5208/trace.c delete mode 100644 drivers/staging/rts5208/trace.h diff --git a/drivers/staging/rts5208/Makefile b/drivers/staging/rts5208/Makefile index f7fd03a94e5f..17b4471c4d6d 100644 --- a/drivers/staging/rts5208/Makefile +++ b/drivers/staging/rts5208/Makefile @@ -3,4 +3,4 @@ obj-$(CONFIG_RTS5208) := rts5208.o ccflags-y := -Idrivers/scsi rts5208-y := rtsx.o rtsx_chip.o rtsx_transport.o rtsx_scsi.o \ - rtsx_card.o general.o sd.o xd.o ms.o spi.o trace.o + rtsx_card.o general.o sd.o xd.o ms.o spi.o diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index b89ef15e3c20..3a71dbb6d24a 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c @@ -44,7 +44,6 @@ static inline int ms_check_err_code(struct rtsx_chip *chip, u8 err_code) static int ms_parse_err_code(struct rtsx_chip *chip) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -76,7 +75,6 @@ static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode, if (retval < 0) { rtsx_clear_ms_error(chip); ms_set_err_code(chip, MS_TO_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } @@ -85,14 +83,12 @@ static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode, if (!(tpc & 0x08)) { /* Read Packet */ if (*ptr & MS_CRC16_ERR) { ms_set_err_code(chip, MS_CRC16_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } } else { /* Write Packet */ if (CHK_MSPRO(ms_card) && !(*ptr & 0x80)) { if (*ptr & (MS_INT_ERR | MS_INT_CMDNK)) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return ms_parse_err_code(chip); } } @@ -101,7 +97,6 @@ static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode, if (*ptr & MS_RDY_TIMEOUT) { rtsx_clear_ms_error(chip); ms_set_err_code(chip, MS_TO_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } @@ -117,7 +112,6 @@ static int ms_transfer_data(struct rtsx_chip *chip, u8 trans_mode, enum dma_data_direction dir; if (!buf || !buf_len) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -128,7 +122,6 @@ static int ms_transfer_data(struct rtsx_chip *chip, u8 trans_mode, dir = DMA_TO_DEVICE; err_code = MS_FLASH_WRITE_ERROR; } else { - rtsx_trace(chip); return STATUS_FAIL; } @@ -165,17 +158,14 @@ static int ms_transfer_data(struct rtsx_chip *chip, u8 trans_mode, else retval = STATUS_FAIL; - rtsx_trace(chip); return retval; } retval = rtsx_read_register(chip, MS_TRANS_CFG, &val); if (retval) { - rtsx_trace(chip); return retval; } if (val & (MS_INT_CMDNK | MS_INT_ERR | MS_CRC16_ERR | MS_RDY_TIMEOUT)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -189,7 +179,6 @@ static int ms_write_bytes(struct rtsx_chip *chip, int retval, i; if (!data || (data_len < cnt)) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -225,14 +214,12 @@ static int ms_write_bytes(struct rtsx_chip *chip, if (!(tpc & 0x08)) { if (val & MS_CRC16_ERR) { ms_set_err_code(chip, MS_CRC16_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } } else { if (CHK_MSPRO(ms_card) && !(val & 0x80)) { if (val & (MS_INT_ERR | MS_INT_CMDNK)) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return ms_parse_err_code(chip); } } @@ -240,12 +227,10 @@ static int ms_write_bytes(struct rtsx_chip *chip, if (val & MS_RDY_TIMEOUT) { ms_set_err_code(chip, MS_TO_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } ms_set_err_code(chip, MS_TO_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } @@ -260,7 +245,6 @@ static int ms_read_bytes(struct rtsx_chip *chip, u8 *ptr; if (!data) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -296,14 +280,12 @@ static int ms_read_bytes(struct rtsx_chip *chip, if (!(tpc & 0x08)) { if (val & MS_CRC16_ERR) { ms_set_err_code(chip, MS_CRC16_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } } else { if (CHK_MSPRO(ms_card) && !(val & 0x80)) { if (val & (MS_INT_ERR | MS_INT_CMDNK)) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return ms_parse_err_code(chip); } } @@ -311,12 +293,10 @@ static int ms_read_bytes(struct rtsx_chip *chip, if (val & MS_RDY_TIMEOUT) { ms_set_err_code(chip, MS_TO_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } ms_set_err_code(chip, MS_TO_ERROR); - rtsx_trace(chip); return ms_parse_err_code(chip); } @@ -353,7 +333,6 @@ static int ms_set_rw_reg_addr(struct rtsx_chip *chip, u8 read_start, rtsx_clear_ms_error(chip); } - rtsx_trace(chip); return STATUS_FAIL; } @@ -393,13 +372,11 @@ static int ms_set_init_para(struct rtsx_chip *chip) retval = switch_clock(chip, ms_card->ms_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = select_card(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -413,13 +390,11 @@ static int ms_switch_clock(struct rtsx_chip *chip) retval = select_card(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = switch_clock(chip, ms_card->ms_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -435,41 +410,35 @@ static int ms_pull_ctl_disable(struct rtsx_chip *chip) MS_D1_PD | MS_D2_PD | MS_CLK_PD | MS_D6_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, MS_D3_PD | MS_D0_PD | MS_BS_PD | XD_D4_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF, MS_D7_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF, XD_RDY_PD | SD_D3_PD | SD_D2_PD | XD_ALE_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF, MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF, MS_D5_PD | MS_D4_PD); if (retval) { - rtsx_trace(chip); return retval; } } else if (CHECK_PID(chip, 0x5288)) { @@ -477,25 +446,21 @@ static int ms_pull_ctl_disable(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_PULL_CTL1, 0xFF, 0x55); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, 0x55); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF, 0x4B); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF, 0x69); if (retval) { - rtsx_trace(chip); return retval; } } @@ -538,7 +503,6 @@ static int ms_pull_ctl_enable(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, MS_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -560,7 +524,6 @@ static int ms_prepare_reset(struct rtsx_chip *chip) retval = ms_power_off_card3v3(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -569,21 +532,18 @@ static int ms_prepare_reset(struct rtsx_chip *chip) retval = enable_card_clock(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (chip->asic_code) { retval = ms_pull_ctl_enable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { retval = rtsx_write_register(chip, FPGA_PULL_CTL, FPGA_MS_PULL_CTL_BIT | 0x20, 0); if (retval) { - rtsx_trace(chip); return retval; } } @@ -591,7 +551,6 @@ static int ms_prepare_reset(struct rtsx_chip *chip) if (!chip->ft2_fast_mode) { retval = card_power_on(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -606,7 +565,6 @@ static int ms_prepare_reset(struct rtsx_chip *chip) if (chip->ocp_stat & oc_mask) { dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n", chip->ocp_stat); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -615,7 +573,6 @@ static int ms_prepare_reset(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, MS_OUTPUT_EN); if (retval) { - rtsx_trace(chip); return retval; } @@ -626,7 +583,6 @@ static int ms_prepare_reset(struct rtsx_chip *chip) NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1); if (retval) { - rtsx_trace(chip); return retval; } } else { @@ -636,26 +592,22 @@ static int ms_prepare_reset(struct rtsx_chip *chip) NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1); if (retval) { - rtsx_trace(chip); return retval; } } retval = rtsx_write_register(chip, MS_TRANS_CFG, 0xFF, NO_WAIT_INT | NO_AUTO_READ_INT_REG); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_STOP, MS_STOP | MS_CLR_ERR, MS_STOP | MS_CLR_ERR); if (retval) { - rtsx_trace(chip); return retval; } retval = ms_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -670,7 +622,6 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) retval = ms_set_rw_reg_addr(chip, Pro_StatusReg, 6, SystemParm, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -681,13 +632,11 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, PPBUF_BASE2 + 2, &val); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "Type register: 0x%x\n", val); @@ -695,32 +644,27 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) if (val != 0x02) ms_card->check_ms_flow = 1; - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, PPBUF_BASE2 + 4, &val); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "Category register: 0x%x\n", val); if (val != 0) { ms_card->check_ms_flow = 1; - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, PPBUF_BASE2 + 5, &val); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "Class register: 0x%x\n", val); if (val == 0) { retval = rtsx_read_register(chip, PPBUF_BASE2, &val); if (retval) { - rtsx_trace(chip); return retval; } if (val & WRT_PRTCT) @@ -732,7 +676,6 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) chip->card_wp |= MS_CARD; } else { ms_card->check_ms_flow = 1; - rtsx_trace(chip); return STATUS_FAIL; } @@ -740,7 +683,6 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) retval = rtsx_read_register(chip, PPBUF_BASE2 + 3, &val); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "IF Mode register: 0x%x\n", val); @@ -753,7 +695,6 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) ms_card->ms_type &= 0x0F; } else { - rtsx_trace(chip); return STATUS_FAIL; } @@ -770,7 +711,6 @@ static int ms_confirm_cpu_startup(struct rtsx_chip *chip) do { if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { ms_set_err_code(chip, MS_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -781,12 +721,10 @@ static int ms_confirm_cpu_startup(struct rtsx_chip *chip) break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } if (k > 100) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -800,7 +738,6 @@ static int ms_confirm_cpu_startup(struct rtsx_chip *chip) break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -808,7 +745,6 @@ static int ms_confirm_cpu_startup(struct rtsx_chip *chip) if (val & INT_REG_CMDNK) { chip->card_wp |= (MS_CARD); } else { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -831,7 +767,6 @@ static int ms_switch_parallel_bus(struct rtsx_chip *chip) break; } if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -853,20 +788,17 @@ static int ms_switch_8bit_bus(struct rtsx_chip *chip) break; } if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, MS_CFG, 0x98, MS_BUS_WIDTH_8 | SAMPLE_TIME_FALLING); if (retval) { - rtsx_trace(chip); return retval; } ms_card->ms_type |= MS_8BIT; retval = ms_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -874,7 +806,6 @@ static int ms_switch_8bit_bus(struct rtsx_chip *chip) retval = ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT, 1, NO_WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -890,19 +821,16 @@ static int ms_pro_reset_flow(struct rtsx_chip *chip, int switch_8bit_bus) for (i = 0; i < 3; i++) { retval = ms_prepare_reset(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_identify_media_type(chip, switch_8bit_bus); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_confirm_cpu_startup(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -910,7 +838,6 @@ static int ms_pro_reset_flow(struct rtsx_chip *chip, int switch_8bit_bus) if (retval != STATUS_SUCCESS) { if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { ms_set_err_code(chip, MS_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } continue; @@ -920,26 +847,22 @@ static int ms_pro_reset_flow(struct rtsx_chip *chip, int switch_8bit_bus) } if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } /* Switch MS-PRO into Parallel mode */ retval = rtsx_write_register(chip, MS_CFG, 0x18, MS_BUS_WIDTH_4); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, MS_CFG, PUSH_TIME_ODD, PUSH_TIME_ODD); if (retval) { - rtsx_trace(chip); return retval; } retval = ms_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -948,7 +871,6 @@ static int ms_pro_reset_flow(struct rtsx_chip *chip, int switch_8bit_bus) retval = ms_switch_8bit_bus(chip); if (retval != STATUS_SUCCESS) { ms_card->switch_8bit_fail = 1; - rtsx_trace(chip); return STATUS_FAIL; } } @@ -966,7 +888,6 @@ static int msxc_change_power(struct rtsx_chip *chip, u8 mode) retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -979,23 +900,19 @@ static int msxc_change_power(struct rtsx_chip *chip, u8 mode) retval = ms_write_bytes(chip, PRO_WRITE_REG, 6, NO_WAIT_INT, buf, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, XC_CHG_POWER, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, MS_TRANS_CFG, buf); if (retval) { - rtsx_trace(chip); return retval; } if (buf[0] & (MS_INT_CMDNK | MS_INT_ERR)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1020,7 +937,6 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) retval = ms_set_rw_reg_addr(chip, Pro_IntReg, 2, Pro_SystemParm, 7); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1045,13 +961,11 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) break; } if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } buf = kmalloc(64 * 512, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -1063,12 +977,10 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) retval = rtsx_read_register(chip, MS_TRANS_CFG, &val); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } if (!(val & MS_INT_BREQ)) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_transfer_data(chip, MS_TM_AUTO_READ, @@ -1081,7 +993,6 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) } if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1090,7 +1001,6 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) retval = rtsx_read_register(chip, MS_TRANS_CFG, &val); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1101,7 +1011,6 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) PRO_READ_LONG_DATA, 0, WAIT_INT); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1111,13 +1020,11 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) if ((buf[0] != 0xa5) && (buf[1] != 0xc3)) { /* Signature code is wrong */ kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } if ((buf[4] < 1) || (buf[4] > 12)) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1142,17 +1049,14 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) sys_info_addr, sys_info_size); if (sys_info_size != 96) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } if (sys_info_addr < 0x1A0) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } if ((sys_info_size + sys_info_addr) > 0x8000) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1180,17 +1084,14 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) model_name_addr, model_name_size); if (model_name_size != 48) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } if (model_name_addr < 0x1A0) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } if ((model_name_size + model_name_addr) > 0x8000) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1204,7 +1105,6 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) if (i == buf[4]) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1251,18 +1151,15 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) #ifdef SUPPORT_MSXC if (CHK_MSXC(ms_card)) { if (class_code != 0x03) { - rtsx_trace(chip); return STATUS_FAIL; } } else { if (class_code != 0x02) { - rtsx_trace(chip); return STATUS_FAIL; } } #else if (class_code != 0x02) { - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -1272,13 +1169,11 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) (device_type == 0x03)) { chip->card_wp |= MS_CARD; } else { - rtsx_trace(chip); return STATUS_FAIL; } } if (sub_class & 0xC0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1329,18 +1224,15 @@ retry: if (ms_card->switch_8bit_fail) { retval = ms_pro_reset_flow(chip, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { - rtsx_trace(chip); return STATUS_FAIL; } } retval = ms_read_attribute_info(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1383,7 +1275,6 @@ retry: #ifdef SUPPORT_MAGIC_GATE retval = mg_set_tpc_para_sub(chip, 0, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -1403,19 +1294,16 @@ static int ms_read_status_reg(struct rtsx_chip *chip) retval = ms_set_rw_reg_addr(chip, StatusReg0, 2, 0, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_bytes(chip, READ_REG, 2, NO_WAIT_INT, val, 2); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val[1] & (STS_UCDT | STS_UCEX | STS_UCFG)) { ms_set_err_code(chip, MS_FLASH_READ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1432,7 +1320,6 @@ static int ms_read_extra_data(struct rtsx_chip *chip, retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1456,7 +1343,6 @@ static int ms_read_extra_data(struct rtsx_chip *chip, break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1468,27 +1354,23 @@ static int ms_read_extra_data(struct rtsx_chip *chip, break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } ms_set_err_code(chip, MS_NO_ERROR); retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CED) { if (val & INT_REG_ERR) { retval = ms_read_status_reg(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1496,7 +1378,6 @@ static int ms_read_extra_data(struct rtsx_chip *chip, MS_EXTRA_SIZE, SystemParm, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1505,7 +1386,6 @@ static int ms_read_extra_data(struct rtsx_chip *chip, retval = ms_read_bytes(chip, READ_REG, MS_EXTRA_SIZE, NO_WAIT_INT, data, MS_EXTRA_SIZE); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1526,14 +1406,12 @@ static int ms_write_extra_data(struct rtsx_chip *chip, u16 block_addr, u8 val, data[16]; if (!buf || (buf_len < MS_EXTRA_SIZE)) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6 + MS_EXTRA_SIZE); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1554,32 +1432,27 @@ static int ms_write_extra_data(struct rtsx_chip *chip, u16 block_addr, retval = ms_write_bytes(chip, WRITE_REG, (6 + MS_EXTRA_SIZE), NO_WAIT_INT, data, 16); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ms_set_err_code(chip, MS_NO_ERROR); retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CED) { if (val & INT_REG_ERR) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1596,7 +1469,6 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1613,26 +1485,22 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) retval = ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ms_set_err_code(chip, MS_NO_ERROR); retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1640,7 +1508,6 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) if (val & INT_REG_ERR) { if (!(val & INT_REG_BREQ)) { ms_set_err_code(chip, MS_FLASH_READ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_status_reg(chip); @@ -1650,7 +1517,6 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) } else { if (!(val & INT_REG_BREQ)) { ms_set_err_code(chip, MS_BREQ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1659,12 +1525,10 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) retval = ms_transfer_tpc(chip, MS_TM_NORMAL_READ, READ_PAGE_DATA, 0, NO_WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (ms_check_err_code(chip, MS_FLASH_WRITE_ERROR)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1679,14 +1543,12 @@ static int ms_set_bad_block(struct rtsx_chip *chip, u16 phy_blk) retval = ms_read_extra_data(chip, phy_blk, 0, extra, MS_EXTRA_SIZE); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 7); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1707,33 +1569,28 @@ static int ms_set_bad_block(struct rtsx_chip *chip, u16 phy_blk) retval = ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, data, 7); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ms_set_err_code(chip, MS_NO_ERROR); retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CED) { if (val & INT_REG_ERR) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1750,7 +1607,6 @@ static int ms_erase_block(struct rtsx_chip *chip, u16 phy_blk) retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1769,21 +1625,18 @@ static int ms_erase_block(struct rtsx_chip *chip, u16 phy_blk) retval = ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ERASE_RTY: retval = ms_send_cmd(chip, BLOCK_ERASE, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ms_set_err_code(chip, MS_NO_ERROR); retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1795,14 +1648,12 @@ ERASE_RTY: ms_set_err_code(chip, MS_CMD_NK); ms_set_bad_block(chip, phy_blk); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CED) { if (val & INT_REG_ERR) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1845,14 +1696,12 @@ static int ms_init_page(struct rtsx_chip *chip, u16 phy_blk, u16 log_blk, for (i = start_page; i < end_page; i++) { if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { ms_set_err_code(chip, MS_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_write_extra_data(chip, phy_blk, i, extra, MS_EXTRA_SIZE); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1875,38 +1724,32 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_read_extra_data(chip, new_blk, 0, extra, MS_EXTRA_SIZE); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_status_reg(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, PPBUF_BASE2, &val); if (retval) { - rtsx_trace(chip); return retval; } if (val & BUF_FULL) { retval = ms_send_cmd(chip, CLEAR_BUF, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (!(val & INT_REG_CED)) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1914,7 +1757,6 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, for (i = start_page; i < end_page; i++) { if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { ms_set_err_code(chip, MS_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1923,7 +1765,6 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1943,26 +1784,22 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ms_set_err_code(chip, MS_NO_ERROR); retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1981,7 +1818,6 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, READ_PAGE_DATA, 0, NO_WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2019,14 +1855,12 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, break; } if (rty_cnt == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } } if (!(val & INT_REG_BREQ)) { ms_set_err_code(chip, MS_BREQ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2062,33 +1896,28 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_write_bytes(chip, WRITE_REG, (6 + MS_EXTRA_SIZE), NO_WAIT_INT, data, 16); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ms_set_err_code(chip, MS_NO_ERROR); retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CED) { if (val & INT_REG_ERR) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2098,7 +1927,6 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, MS_EXTRA_SIZE, SystemParm, 7); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2120,13 +1948,11 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, data, 8); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2134,13 +1960,11 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2148,7 +1972,6 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, if (val & INT_REG_ERR) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2170,7 +1993,6 @@ static int reset_ms(struct rtsx_chip *chip) retval = ms_prepare_reset(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2178,19 +2000,16 @@ static int reset_ms(struct rtsx_chip *chip) retval = ms_send_cmd(chip, MS_RESET, NO_WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_status_reg(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, PPBUF_BASE2, &val); if (retval) { - rtsx_trace(chip); return retval; } if (val & WRT_PRTCT) @@ -2205,7 +2024,6 @@ RE_SEARCH: while (i < (MAX_DEFECTIVE_BLOCK + 2)) { if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { ms_set_err_code(chip, MS_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2226,7 +2044,6 @@ RE_SEARCH: if (i == (MAX_DEFECTIVE_BLOCK + 2)) { dev_dbg(rtsx_dev(chip), "No boot block found!"); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2243,7 +2060,6 @@ RE_SEARCH: retval = ms_read_page(chip, ms_card->boot_block, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2255,7 +2071,6 @@ RE_SEARCH: retval = rtsx_send_cmd(chip, MS_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2280,7 +2095,6 @@ RE_SEARCH: retval = rtsx_send_cmd(chip, MS_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2356,25 +2170,21 @@ RE_SEARCH: if (ptr[15]) { retval = ms_set_rw_reg_addr(chip, 0, 0, SystemParm, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, PPBUF_BASE2, 0xFF, 0x88); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, PPBUF_BASE2 + 1, 0xFF, 0); if (retval) { - rtsx_trace(chip); return retval; } retval = ms_transfer_tpc(chip, MS_TM_WRITE_BYTES, WRITE_REG, 1, NO_WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2384,7 +2194,6 @@ RE_SEARCH: PUSH_TIME_ODD | MS_NO_CHECK_INT); if (retval) { - rtsx_trace(chip); return retval; } @@ -2413,13 +2222,11 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip) size = ms_card->segment_cnt * sizeof(struct zone_entry); ms_card->segment = vzalloc(size); if (!ms_card->segment) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_page(chip, ms_card->boot_block, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto INIT_FAIL; } @@ -2429,13 +2236,11 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip) retval = rtsx_read_register(chip, reg_addr++, &val1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto INIT_FAIL; } retval = rtsx_read_register(chip, reg_addr++, &val2); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto INIT_FAIL; } @@ -2599,7 +2404,6 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) if (!ms_card->segment) { retval = ms_init_l2p_tbl(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return retval; } } @@ -2620,7 +2424,6 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) if (!segment->l2p_table) { segment->l2p_table = vmalloc(array_size(table_size, 2)); if (!segment->l2p_table) { - rtsx_trace(chip); goto BUILD_FAIL; } } @@ -2629,7 +2432,6 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) if (!segment->free_table) { segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2); if (!segment->free_table) { - rtsx_trace(chip); goto BUILD_FAIL; } } @@ -2757,7 +2559,6 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) } retval = ms_init_page(chip, phy_blk, log_blk, 0, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto BUILD_FAIL; } @@ -2791,7 +2592,6 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) log_blk, 0, ms_card->page_off + 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2799,7 +2599,6 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) retval = ms_set_bad_block(chip, tmp_blk); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2828,13 +2627,11 @@ int reset_ms_card(struct rtsx_chip *chip) retval = enable_card_clock(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = select_card(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2845,18 +2642,15 @@ int reset_ms_card(struct rtsx_chip *chip) if (ms_card->check_ms_flow) { retval = reset_ms(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { - rtsx_trace(chip); return STATUS_FAIL; } } retval = ms_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2866,7 +2660,6 @@ int reset_ms_card(struct rtsx_chip *chip) */ retval = ms_build_l2p_tbl(chip, seg_no); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2898,7 +2691,6 @@ static int mspro_set_rw_cmd(struct rtsx_chip *chip, break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2940,7 +2732,6 @@ static inline int ms_auto_tune_clock(struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2992,7 +2783,6 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3003,7 +2793,6 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, retval = rtsx_read_register(chip, MS_TRANS_CFG, &val); if (retval) { - rtsx_trace(chip); return retval; } @@ -3020,7 +2809,6 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, if (val & MS_INT_BREQ) { retval = ms_send_cmd(chip, PRO_STOP, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3050,7 +2838,6 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, retval = mspro_set_rw_cmd(chip, start_sector, count, rw_cmd); if (retval != STATUS_SUCCESS) { ms_card->seq_mode = 0; - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3067,7 +2854,6 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, chip->rw_need_retry = 0; dev_dbg(rtsx_dev(chip), "No card exist, exit %s\n", __func__); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3080,7 +2866,6 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, ms_auto_tune_clock(chip); } - rtsx_trace(chip); return retval; } @@ -3109,14 +2894,12 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, MS_TRANS_CFG, &tmp); if (retval != STATUS_SUCCESS) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } @@ -3127,7 +2910,6 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, return STATUS_SUCCESS; } ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } @@ -3140,7 +2922,6 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, MS_NO_CHECK_INT); if (retval != STATUS_SUCCESS) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } @@ -3148,7 +2929,6 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, data, 8); if (retval != STATUS_SUCCESS) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } @@ -3174,7 +2954,6 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, retval = rtsx_read_register(chip, MS_TRANS_CFG, &tmp); if (retval != STATUS_SUCCESS) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } if (tmp & (MS_INT_CED | MS_INT_CMDNK | @@ -3187,19 +2966,16 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, retval = rtsx_write_register(chip, MS_CFG, MS_NO_CHECK_INT, 0); if (retval != STATUS_SUCCESS) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } if (i == 5000) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) { ms_card->format_status = FORMAT_FAIL; - rtsx_trace(chip); return STATUS_FAIL; } @@ -3211,7 +2987,6 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, } else { ms_card->format_status = FORMAT_FAIL; ms_card->pro_under_formatting = 0; - rtsx_trace(chip); return STATUS_FAIL; } @@ -3245,13 +3020,11 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip, retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_set_rw_reg_addr(chip, 0x00, 0x00, Pro_TPCParm, 0x01); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3279,7 +3052,6 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip, break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3290,18 +3062,15 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip, retval = mspro_set_rw_cmd(chip, 0, para, PRO_FORMAT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, MS_TRANS_CFG, &tmp); if (retval) { - rtsx_trace(chip); return retval; } if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3320,7 +3089,6 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip, return STATUS_SUCCESS; } - rtsx_trace(chip); return STATUS_FAIL; } @@ -3339,7 +3107,6 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, if (retval == STATUS_SUCCESS) { if ((extra[1] & 0x30) != 0x30) { ms_set_err_code(chip, MS_FLASH_READ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3347,7 +3114,6 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3369,7 +3135,6 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3377,7 +3142,6 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3388,19 +3152,16 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { ms_set_err_code(chip, MS_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_ERR) { @@ -3420,18 +3181,15 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, } ms_set_err_code(chip, MS_FLASH_READ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } else { ms_set_err_code(chip, MS_FLASH_READ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } else { if (!(val & INT_REG_BREQ)) { ms_set_err_code(chip, MS_BREQ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3440,7 +3198,6 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, if (!(val & INT_REG_CED)) { retval = ms_send_cmd(chip, BLOCK_END, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3448,13 +3205,11 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (!(val & INT_REG_CED)) { ms_set_err_code(chip, MS_FLASH_READ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3489,7 +3244,6 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, if (retval == -ETIMEDOUT) { ms_set_err_code(chip, MS_TO_ERROR); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_TIMEDOUT; } @@ -3497,13 +3251,11 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, if (retval != STATUS_SUCCESS) { ms_set_err_code(chip, MS_TO_ERROR); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_TIMEDOUT; } if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) { ms_set_err_code(chip, MS_CRC16_ERROR); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3529,7 +3281,6 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 7); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3549,13 +3300,11 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, retval = ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, data, 8); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3563,7 +3312,6 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, retval = ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT, 1, NO_WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3571,7 +3319,6 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, (6 + MS_EXTRA_SIZE)); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3606,7 +3353,6 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3616,13 +3362,11 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3632,23 +3376,19 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { ms_set_err_code(chip, MS_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_CMDNK) { ms_set_err_code(chip, MS_CMD_NK); - rtsx_trace(chip); return STATUS_FAIL; } if (val & INT_REG_ERR) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } if (!(val & INT_REG_BREQ)) { ms_set_err_code(chip, MS_BREQ_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3682,23 +3422,19 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, rtsx_clear_ms_error(chip); if (retval == -ETIMEDOUT) { - rtsx_trace(chip); return STATUS_TIMEDOUT; } - rtsx_trace(chip); return STATUS_FAIL; } retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if ((end_page - start_page) == 1) { if (!(val & INT_REG_CED)) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -3707,7 +3443,6 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, retval = ms_send_cmd(chip, BLOCK_END, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3715,7 +3450,6 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3725,7 +3459,6 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, if (!(val & INT_REG_CED)) { ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3747,7 +3480,6 @@ static int ms_finish_write(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_copy_page(chip, old_blk, new_blk, log_blk, page_off, ms_card->page_off + 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3776,7 +3508,6 @@ static int ms_prepare_write(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, retval = ms_copy_page(chip, old_blk, new_blk, log_blk, 0, start_page); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3794,7 +3525,6 @@ int ms_delay_write(struct rtsx_chip *chip) if (delay_write->delay_write_flag) { retval = ms_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3805,7 +3535,6 @@ int ms_delay_write(struct rtsx_chip *chip) delay_write->logblock, delay_write->pageoff); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3846,7 +3575,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { ms_rw_fail(srb, chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3863,7 +3591,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { chip->card_fail |= MS_CARD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3882,7 +3609,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } old_blk = delay_write->old_phyblock; @@ -3898,7 +3624,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -3909,7 +3634,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, if ((old_blk == 0xFFFF) || (new_blk == 0xFFFF)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3921,12 +3645,10 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, set_sense_type (chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } #ifdef MS_DELAY_WRITE @@ -3939,12 +3661,10 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -3953,7 +3673,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (old_blk == 0xFFFF) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3989,11 +3708,9 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } ms_rw_fail(srb, chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4030,7 +3747,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, chip->card_fail |= MS_CARD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -4039,7 +3755,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, log_blk - ms_start_idx[seg_no]); if (old_blk == 0xFFFF) { ms_rw_fail(srb, chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4047,7 +3762,6 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, new_blk = ms_get_unused_block(chip, seg_no); if (new_blk == 0xFFFF) { ms_rw_fail(srb, chip); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -4075,12 +3789,10 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, set_sense_type (chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } ms_rw_fail(srb, chip); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -4139,13 +3851,11 @@ static int ms_poll_int(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, MS_CARD, 5000); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } val = *rtsx_get_cmd_data(chip); if (val & MS_INT_ERR) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -4211,13 +3921,11 @@ static int mg_send_ex_cmd(struct rtsx_chip *chip, u8 cmd, u8 entry_num) break; } if (i == MS_MAX_RETRY_COUNT) { - rtsx_trace(chip); return STATUS_FAIL; } if (check_ms_err(chip)) { rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4236,7 +3944,6 @@ static int mg_set_tpc_para_sub(struct rtsx_chip *chip, int type, retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -4251,7 +3958,6 @@ static int mg_set_tpc_para_sub(struct rtsx_chip *chip, int type, retval = ms_write_bytes(chip, PRO_WRITE_REG, (type == 0) ? 1 : 6, NO_WAIT_INT, buf, 6); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -4267,7 +3973,6 @@ int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (scsi_bufflen(srb) < 12) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4275,14 +3980,12 @@ int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = mg_send_ex_cmd(chip, MG_SET_LID, 0); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4295,13 +3998,11 @@ int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf1, 32); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - rtsx_trace(chip); return STATUS_FAIL; } if (check_ms_err(chip)) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4319,13 +4020,11 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } buf = kmalloc(1540, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -4337,7 +4036,6 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = mg_send_ex_cmd(chip, MG_GET_LEKB, 0); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - rtsx_trace(chip); goto free_buffer; } @@ -4346,13 +4044,11 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); rtsx_clear_ms_error(chip); - rtsx_trace(chip); goto free_buffer; } if (check_ms_err(chip)) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); rtsx_clear_ms_error(chip); - rtsx_trace(chip); retval = STATUS_FAIL; goto free_buffer; } @@ -4378,14 +4074,12 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = mg_send_ex_cmd(chip, MG_GET_ID, 0); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4393,13 +4087,11 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf, 32); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - rtsx_trace(chip); return STATUS_FAIL; } if (check_ms_err(chip)) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4409,7 +4101,6 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_poll_int(chip); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -4417,7 +4108,6 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = mg_send_ex_cmd(chip, MG_SET_RD, 0); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4434,13 +4124,11 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) 32, WAIT_INT, buf, 32); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - rtsx_trace(chip); return STATUS_FAIL; } if (check_ms_err(chip)) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4461,14 +4149,12 @@ int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = mg_send_ex_cmd(chip, MG_MAKE_RMS, 0); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4476,13 +4162,11 @@ int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf1, 32); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - rtsx_trace(chip); return STATUS_FAIL; } if (check_ms_err(chip)) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4501,7 +4185,6 @@ int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_poll_int(chip); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -4522,14 +4205,12 @@ int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = mg_send_ex_cmd(chip, MG_MAKE_KSE, 0); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4546,13 +4227,11 @@ int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf, 32); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - rtsx_trace(chip); return STATUS_FAIL; } if (check_ms_err(chip)) { set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); rtsx_clear_ms_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4573,13 +4252,11 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } buf = kmalloc(1028, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -4591,7 +4268,6 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = mg_send_ex_cmd(chip, MG_GET_IBD, ms_card->mg_entry_num); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); goto free_buffer; } @@ -4600,13 +4276,11 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); rtsx_clear_ms_error(chip); - rtsx_trace(chip); goto free_buffer; } if (check_ms_err(chip)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); rtsx_clear_ms_error(chip); - rtsx_trace(chip); retval = STATUS_FAIL; goto free_buffer; } @@ -4634,13 +4308,11 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ms_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } buf = kmalloc(1028, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -4660,7 +4332,6 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) } else { set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); } - rtsx_trace(chip); goto SetICVFinish; } @@ -4702,7 +4373,6 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) SENSE_TYPE_MG_WRITE_ERR); } retval = STATUS_FAIL; - rtsx_trace(chip); goto SetICVFinish; } } @@ -4722,7 +4392,6 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) } else { set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); } - rtsx_trace(chip); goto SetICVFinish; } #endif @@ -4765,14 +4434,12 @@ int ms_power_off_card3v3(struct rtsx_chip *chip) retval = disable_card_clock(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (chip->asic_code) { retval = ms_pull_ctl_disable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -4780,19 +4447,16 @@ int ms_power_off_card3v3(struct rtsx_chip *chip) FPGA_MS_PULL_CTL_BIT | 0x20, FPGA_MS_PULL_CTL_BIT); if (retval) { - rtsx_trace(chip); return retval; } } retval = rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, 0); if (retval) { - rtsx_trace(chip); return retval; } if (!chip->ft2_fast_mode) { retval = card_power_off(chip, MS_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -4823,7 +4487,6 @@ int release_ms_card(struct rtsx_chip *chip) retval = ms_power_off_card3v3(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } diff --git a/drivers/staging/rts5208/rtsx.h b/drivers/staging/rts5208/rtsx.h index 62e467c5a6d7..514536a6f92b 100644 --- a/drivers/staging/rts5208/rtsx.h +++ b/drivers/staging/rts5208/rtsx.h @@ -139,28 +139,6 @@ static inline struct rtsx_dev *host_to_rtsx(struct Scsi_Host *host) return (struct rtsx_dev *)host->hostdata; } -static inline void get_current_time(u8 *timeval_buf, int buf_len) -{ - struct timespec64 ts64; - u32 tv_usec; - - if (!timeval_buf || (buf_len < 8)) - return; - - getnstimeofday64(&ts64); - - tv_usec = ts64.tv_nsec / NSEC_PER_USEC; - - timeval_buf[0] = (u8)(ts64.tv_sec >> 24); - timeval_buf[1] = (u8)(ts64.tv_sec >> 16); - timeval_buf[2] = (u8)(ts64.tv_sec >> 8); - timeval_buf[3] = (u8)(ts64.tv_sec); - timeval_buf[4] = (u8)(tv_usec >> 24); - timeval_buf[5] = (u8)(tv_usec >> 16); - timeval_buf[6] = (u8)(tv_usec >> 8); - timeval_buf[7] = (u8)(tv_usec); -} - /* * The scsi_lock() and scsi_unlock() macros protect the sm_state and the * single queue element srb for write access @@ -174,9 +152,6 @@ static inline void get_current_time(u8 *timeval_buf, int buf_len) /* struct scsi_cmnd transfer buffer access utilities */ enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF}; -#define _MSG_TRACE - -#include "trace.h" #include "rtsx_chip.h" #include "rtsx_transport.h" #include "rtsx_scsi.h" diff --git a/drivers/staging/rts5208/rtsx_card.c b/drivers/staging/rts5208/rtsx_card.c index a6b7bffc6714..d26a8e372fce 100644 --- a/drivers/staging/rts5208/rtsx_card.c +++ b/drivers/staging/rts5208/rtsx_card.c @@ -648,7 +648,6 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk) clk, chip->cur_clk); if ((clk <= 2) || (n > max_n)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -690,14 +689,12 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk) retval = rtsx_send_cmd(chip, 0, WAIT_TIME); if (retval < 0) { - rtsx_trace(chip); return STATUS_ERROR; } udelay(10); retval = rtsx_write_register(chip, CLK_CTL, CLK_LOW_FREQ, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -789,38 +786,32 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk) default: dev_dbg(rtsx_dev(chip), "Try to switch to an illegal clock (%d)\n", clk); - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ); if (retval) { - rtsx_trace(chip); return retval; } if (sd_vpclk_phase_reset) { retval = rtsx_write_register(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SD_VPCLK1_CTL, PHASE_NOT_RESET, 0); if (retval) { - rtsx_trace(chip); return retval; } } retval = rtsx_write_register(chip, CLK_DIV, 0xFF, (div << 4) | mcu_cnt); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CLK_SEL, 0xFF, sel); if (retval) { - rtsx_trace(chip); return retval; } @@ -829,20 +820,17 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk) retval = rtsx_write_register(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, PHASE_NOT_RESET); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SD_VPCLK1_CTL, PHASE_NOT_RESET, PHASE_NOT_RESET); if (retval) { - rtsx_trace(chip); return retval; } udelay(200); } retval = rtsx_write_register(chip, CLK_CTL, 0xFF, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -891,7 +879,6 @@ int enable_card_clock(struct rtsx_chip *chip, u8 card) retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, clk_en); if (retval) { - rtsx_trace(chip); return retval; } @@ -912,7 +899,6 @@ int disable_card_clock(struct rtsx_chip *chip, u8 card) retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -939,7 +925,6 @@ int card_power_on(struct rtsx_chip *chip, u8 card) retval = rtsx_send_cmd(chip, 0, 100); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -950,7 +935,6 @@ int card_power_on(struct rtsx_chip *chip, u8 card) retval = rtsx_send_cmd(chip, 0, 100); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -972,7 +956,6 @@ int card_power_off(struct rtsx_chip *chip, u8 card) retval = rtsx_write_register(chip, CARD_PWR_CTL, mask, val); if (retval) { - rtsx_trace(chip); return retval; } @@ -987,7 +970,6 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, int i; if (!chip->rw_card[lun]) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -998,12 +980,10 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { if (rtsx_check_chip_exist(chip) != STATUS_SUCCESS) { rtsx_release_chip(chip); - rtsx_trace(chip); return STATUS_FAIL; } if (detect_card_cd(chip, chip->cur_card) != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1036,7 +1016,6 @@ int card_share_mode(struct rtsx_chip *chip, int card) } else if (card == XD_CARD) { value = CARD_SHARE_48_XD; } else { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1049,18 +1028,15 @@ int card_share_mode(struct rtsx_chip *chip, int card) } else if (card == XD_CARD) { value = CARD_SHARE_BAROSSA_XD; } else { - rtsx_trace(chip); return STATUS_FAIL; } } else { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_SHARE_MODE, mask, value); if (retval) { - rtsx_trace(chip); return retval; } @@ -1083,20 +1059,17 @@ int select_card(struct rtsx_chip *chip, int card) } else if (card == SPI_CARD) { mod = SPI_MOD_SEL; } else { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_SELECT, 0x07, mod); if (retval) { - rtsx_trace(chip); return retval; } chip->cur_card = card; retval = card_share_mode(chip, card); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1143,13 +1116,11 @@ int detect_card_cd(struct rtsx_chip *chip, int card) card_cd = XD_EXIST; } else { dev_dbg(rtsx_dev(chip), "Wrong card type: 0x%x\n", card); - rtsx_trace(chip); return STATUS_FAIL; } status = rtsx_readl(chip, RTSX_BIPR); if (!(status & card_cd)) { - rtsx_trace(chip); return STATUS_FAIL; } diff --git a/drivers/staging/rts5208/rtsx_card.h b/drivers/staging/rts5208/rtsx_card.h index aa37705bae39..ac165d8a081c 100644 --- a/drivers/staging/rts5208/rtsx_card.h +++ b/drivers/staging/rts5208/rtsx_card.h @@ -1063,7 +1063,6 @@ static inline int card_power_off_all(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_PWR_CTL, 0x0F, 0x0F); if (retval) { - rtsx_trace(chip); return retval; } diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 8a823466ca2b..6b1234bff09c 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -117,7 +117,6 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip) MS_INS_PU | SD_WP_PU | SD_CD_PU | SD_CMD_PU); if (retval) { - rtsx_trace(chip); return retval; } } else { @@ -125,28 +124,24 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip) 0xFF, FPGA_SD_PULL_CTL_EN); if (retval) { - rtsx_trace(chip); return retval; } } retval = rtsx_write_register(chip, CARD_SHARE_MODE, 0xFF, CARD_SHARE_48_SD); if (retval) { - rtsx_trace(chip); return retval; } /* Enable SDIO internal clock */ retval = rtsx_write_register(chip, 0xFF2C, 0x01, 0x01); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SDIO_CTRL, 0xFF, SDIO_BUS_CTRL | SDIO_CD_CTRL); if (retval) { - rtsx_trace(chip); return retval; } @@ -170,7 +165,6 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) if (CHECK_PID(chip, 0x5288)) { retval = rtsx_read_register(chip, 0xFE5A, &tmp); if (retval) { - rtsx_trace(chip); return retval; } if (tmp & 0x08) @@ -178,7 +172,6 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) } else if (CHECK_PID(chip, 0x5208)) { retval = rtsx_read_register(chip, 0xFE70, &tmp); if (retval) { - rtsx_trace(chip); return retval; } if (tmp & 0x80) @@ -200,7 +193,6 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) retval = rtsx_read_register(chip, TLPTISTAT, &tmp); if (retval) { - rtsx_trace(chip); return retval; } cd_toggle_mask = 0x08; @@ -211,14 +203,12 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) retval = rtsx_write_register(chip, 0xFE5A, 0x08, 0x00); if (retval) { - rtsx_trace(chip); return retval; } } else if (CHECK_PID(chip, 0x5208)) { retval = rtsx_write_register(chip, 0xFE70, 0x80, 0x00); if (retval) { - rtsx_trace(chip); return retval; } } @@ -226,7 +216,6 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) retval = rtsx_write_register(chip, TLPTISTAT, 0xFF, tmp); if (retval) { - rtsx_trace(chip); return retval; } @@ -237,7 +226,6 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) if (chip->asic_code) { retval = sd_pull_ctl_enable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -246,13 +234,11 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) FPGA_SD_PULL_CTL_BIT | 0x20, 0); if (retval) { - rtsx_trace(chip); return retval; } } retval = card_share_mode(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -261,14 +247,12 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) retval = rtsx_write_register(chip, 0xFE5A, 0x08, 0x08); if (retval) { - rtsx_trace(chip); return retval; } } else if (CHECK_PID(chip, 0x5208)) { retval = rtsx_write_register(chip, 0xFE70, 0x80, 0x80); if (retval) { - rtsx_trace(chip); return retval; } } @@ -279,7 +263,6 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) } else { retval = rtsx_write_register(chip, TLPTISTAT, 0x08, 0x08); if (retval) { - rtsx_trace(chip); return retval; } @@ -301,7 +284,6 @@ static int rtsx_reset_aspm(struct rtsx_chip *chip) ret = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en); if (ret != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -311,13 +293,11 @@ static int rtsx_reset_aspm(struct rtsx_chip *chip) if (CHECK_PID(chip, 0x5208)) { ret = rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFF, 0x3F); if (ret) { - rtsx_trace(chip); return ret; } } ret = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en); if (ret != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -327,7 +307,6 @@ static int rtsx_reset_aspm(struct rtsx_chip *chip) ret = rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1, 0xC0, 0xFF, chip->aspm_l0s_l1_en); if (ret != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -349,7 +328,6 @@ static int rtsx_enable_pcie_intr(struct rtsx_chip *chip) if (chip->phy_debug_mode) { ret = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0); if (ret) { - rtsx_trace(chip); return ret; } rtsx_disable_bus_int(chip); @@ -362,7 +340,6 @@ static int rtsx_enable_pcie_intr(struct rtsx_chip *chip) ret = rtsx_read_phy_register(chip, 0x00, ®); if (ret != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -370,20 +347,17 @@ static int rtsx_enable_pcie_intr(struct rtsx_chip *chip) reg |= 0x80; ret = rtsx_write_phy_register(chip, 0x00, reg); if (ret != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } ret = rtsx_read_phy_register(chip, 0x1C, ®); if (ret != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } reg &= 0xFFF7; ret = rtsx_write_phy_register(chip, 0x1C, reg); if (ret != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -404,14 +378,12 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 0x00); if (retval) { - rtsx_trace(chip); return retval; } /* Disable card clock */ retval = rtsx_write_register(chip, CARD_CLK_EN, 0x1E, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -420,14 +392,12 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) { retval = rtsx_write_register(chip, FPDCTL, OC_POWER_DOWN, 0); if (retval) { - rtsx_trace(chip); return retval; } } else { retval = rtsx_write_register(chip, FPDCTL, OC_POWER_DOWN, MS_OC_POWER_DOWN); if (retval) { - rtsx_trace(chip); return retval; } } @@ -435,19 +405,16 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, OCPPARA1, OCP_TIME_MASK, OCP_TIME_800); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, OCPPARA2, OCP_THD_MASK, OCP_THD_244_946); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, OCPCTL, 0xFF, CARD_OC_INT_EN | CARD_DETECT_EN); if (retval) { - rtsx_trace(chip); return retval; } #else @@ -455,7 +422,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, FPDCTL, OC_POWER_DOWN, OC_POWER_DOWN); if (retval) { - rtsx_trace(chip); return retval; } #endif @@ -463,7 +429,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (!CHECK_PID(chip, 0x5288)) { retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0xFF, 0x03); if (retval) { - rtsx_trace(chip); return retval; } } @@ -471,14 +436,12 @@ int rtsx_reset_chip(struct rtsx_chip *chip) /* Turn off LED */ retval = rtsx_write_register(chip, CARD_GPIO, 0xFF, 0x03); if (retval) { - rtsx_trace(chip); return retval; } /* Reset delink mode */ retval = rtsx_write_register(chip, CHANGE_LINK_STATE, 0x0A, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -486,7 +449,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_DRIVE_SEL, 0xFF, chip->card_drive_sel); if (retval) { - rtsx_trace(chip); return retval; } @@ -494,7 +456,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_AUTO_BLINK, 0xFF, LED_BLINK_SPEED | BLINK_EN | LED_GPIO0); if (retval) { - rtsx_trace(chip); return retval; } #endif @@ -504,12 +465,10 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SSC_CTL1, 0xFF, SSC_8X_EN | SSC_SEL_4M); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SSC_CTL2, 0xFF, 0x12); if (retval) { - rtsx_trace(chip); return retval; } } @@ -524,7 +483,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) */ retval = rtsx_write_register(chip, CHANGE_LINK_STATE, 0x16, 0x10); if (retval) { - rtsx_trace(chip); return retval; } @@ -532,28 +490,24 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (chip->aspm_l0s_l1_en) { retval = rtsx_reset_aspm(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { if (chip->asic_code && CHECK_PID(chip, 0x5208)) { retval = rtsx_write_phy_register(chip, 0x07, 0x0129); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } retval = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } retval = rtsx_write_config_byte(chip, 0x81, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -563,7 +517,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) 0xC0, 0xFF00, 0x0100); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -571,13 +524,11 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (CHECK_PID(chip, 0x5288) && !CHK_SDIO_EXIST(chip)) { retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFFFF, 0x0103); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_cfg_dw(chip, 2, 0x84, 0xFF, 0x03); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -585,19 +536,16 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, IRQSTAT0, LINK_RDY_INT, LINK_RDY_INT); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, PERST_GLITCH_WIDTH, 0xFF, 0x80); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_enable_pcie_intr(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -622,7 +570,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_pre_handle_sdio_old(chip); #endif /* HW_AUTO_SWITCH_SD_BUS */ if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -631,7 +578,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SDIO_CTRL, SDIO_BUS_CTRL | SDIO_CD_CTRL, 0); if (retval) { - rtsx_trace(chip); return retval; } } @@ -645,7 +591,6 @@ nextcard: retval = rtsx_write_register(chip, SSC_CTL1, SSC_RSTB, SSC_RSTB); if (retval) { - rtsx_trace(chip); return retval; } } @@ -655,7 +600,6 @@ nextcard: retval = rtsx_write_register(chip, RCCTL, 0x01, 0x00); if (retval) { - rtsx_trace(chip); return retval; } @@ -664,7 +608,6 @@ nextcard: retval = rtsx_write_register(chip, MAIN_PWR_OFF_CTL, 0x03, 0x03); if (retval) { - rtsx_trace(chip); return retval; } } @@ -672,26 +615,22 @@ nextcard: if (chip->remote_wakeup_en && !chip->auto_delink_en) { retval = rtsx_write_register(chip, WAKE_SEL_CTL, 0x07, 0x07); if (retval) { - rtsx_trace(chip); return retval; } if (chip->aux_pwr_exist) { retval = rtsx_write_register(chip, PME_FORCE_CTL, 0xFF, 0x33); if (retval) { - rtsx_trace(chip); return retval; } } } else { retval = rtsx_write_register(chip, WAKE_SEL_CTL, 0x07, 0x04); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, PME_FORCE_CTL, 0xFF, 0x30); if (retval) { - rtsx_trace(chip); return retval; } } @@ -699,7 +638,6 @@ nextcard: if (CHECK_PID(chip, 0x5208) && (chip->ic_version >= IC_VER_D)) { retval = rtsx_write_register(chip, PETXCFG, 0x1C, 0x14); if (retval) { - rtsx_trace(chip); return retval; } } @@ -707,7 +645,6 @@ nextcard: if (chip->asic_code && CHECK_PID(chip, 0x5208)) { retval = rtsx_clr_phy_reg_bit(chip, 0x1C, 2); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -717,14 +654,12 @@ nextcard: MS_PARTIAL_POWER_ON | SD_PARTIAL_POWER_ON); if (retval) { - rtsx_trace(chip); return retval; } udelay(chip->pmos_pwr_on_interval); retval = rtsx_write_register(chip, CARD_PWR_CTL, 0xFF, MS_POWER_ON | SD_POWER_ON); if (retval) { - rtsx_trace(chip); return retval; } @@ -781,12 +716,10 @@ static int rts5208_init(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CLK_SEL, 0x03, 0x03); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_read_register(chip, CLK_SEL, &val); if (retval) { - rtsx_trace(chip); return retval; } chip->asic_code = val == 0 ? 1 : 0; @@ -794,7 +727,6 @@ static int rts5208_init(struct rtsx_chip *chip) if (chip->asic_code) { retval = rtsx_read_phy_register(chip, 0x1C, ®); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -806,7 +738,6 @@ static int rts5208_init(struct rtsx_chip *chip) } else { retval = rtsx_read_register(chip, 0xFE80, &val); if (retval) { - rtsx_trace(chip); return retval; } chip->ic_version = val; @@ -815,7 +746,6 @@ static int rts5208_init(struct rtsx_chip *chip) retval = rtsx_read_register(chip, PDINFO, &val); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val); @@ -823,7 +753,6 @@ static int rts5208_init(struct rtsx_chip *chip) retval = rtsx_read_register(chip, 0xFE50, &val); if (retval) { - rtsx_trace(chip); return retval; } chip->hw_bypass_sd = val & 0x01 ? 1 : 0; @@ -837,7 +766,6 @@ static int rts5208_init(struct rtsx_chip *chip) if (chip->use_hw_setting) { retval = rtsx_read_register(chip, CHANGE_LINK_STATE, &val); if (retval) { - rtsx_trace(chip); return retval; } chip->auto_delink_en = val & 0x80 ? 1 : 0; @@ -854,12 +782,10 @@ static int rts5288_init(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CLK_SEL, 0x03, 0x03); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_read_register(chip, CLK_SEL, &val); if (retval) { - rtsx_trace(chip); return retval; } chip->asic_code = val == 0 ? 1 : 0; @@ -869,7 +795,6 @@ static int rts5288_init(struct rtsx_chip *chip) retval = rtsx_read_register(chip, PDINFO, &val); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val); @@ -877,7 +802,6 @@ static int rts5288_init(struct rtsx_chip *chip) retval = rtsx_read_register(chip, CARD_SHARE_MODE, &val); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "CARD_SHARE_MODE: 0x%x\n", val); @@ -885,14 +809,12 @@ static int rts5288_init(struct rtsx_chip *chip) retval = rtsx_read_register(chip, 0xFE5A, &val); if (retval) { - rtsx_trace(chip); return retval; } chip->hw_bypass_sd = val & 0x10 ? 1 : 0; retval = rtsx_read_cfg_dw(chip, 0, 0x718, &lval); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -906,7 +828,6 @@ static int rts5288_init(struct rtsx_chip *chip) if (chip->use_hw_setting) { retval = rtsx_read_register(chip, CHANGE_LINK_STATE, &val); if (retval) { - rtsx_trace(chip); return retval; } chip->auto_delink_en = val & 0x80 ? 1 : 0; @@ -933,10 +854,6 @@ int rtsx_init_chip(struct rtsx_chip *chip) chip->ic_version = 0; -#ifdef _MSG_TRACE - chip->msg_idx = 0; -#endif - memset(xd_card, 0, sizeof(struct xd_info)); memset(sd_card, 0, sizeof(struct sd_info)); memset(ms_card, 0, sizeof(struct ms_info)); @@ -989,13 +906,11 @@ int rtsx_init_chip(struct rtsx_chip *chip) retval = rtsx_write_register(chip, FPDCTL, SSC_POWER_DOWN, 0); if (retval) { - rtsx_trace(chip); return retval; } wait_timeout(200); retval = rtsx_write_register(chip, CLK_DIV, 0x07, 0x07); if (retval) { - rtsx_trace(chip); return retval; } dev_dbg(rtsx_dev(chip), "chip->use_hw_setting = %d\n", @@ -1004,14 +919,12 @@ int rtsx_init_chip(struct rtsx_chip *chip) if (CHECK_PID(chip, 0x5208)) { retval = rts5208_init(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else if (CHECK_PID(chip, 0x5288)) { retval = rts5288_init(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1061,7 +974,6 @@ int rtsx_init_chip(struct rtsx_chip *chip) retval = rtsx_reset_chip(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1492,7 +1404,6 @@ int rtsx_write_register(struct rtsx_chip *chip, u16 addr, u8 mask, u8 data) val = rtsx_readl(chip, RTSX_HAIMR); if ((val & BIT(31)) == 0) { if (data != (u8)val) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1500,7 +1411,6 @@ int rtsx_write_register(struct rtsx_chip *chip, u16 addr, u8 mask, u8 data) } } - rtsx_trace(chip); return STATUS_TIMEDOUT; } @@ -1523,7 +1433,6 @@ int rtsx_read_register(struct rtsx_chip *chip, u16 addr, u8 *data) } if (i >= MAX_RW_REG_CNT) { - rtsx_trace(chip); return STATUS_TIMEDOUT; } @@ -1546,7 +1455,6 @@ int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask, 0xFF, (u8)(val & mask & 0xFF)); if (retval) { - rtsx_trace(chip); return retval; } mode |= (1 << i); @@ -1558,13 +1466,11 @@ int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask, if (mode) { retval = rtsx_write_register(chip, CFGADDR0, 0xFF, (u8)addr); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CFGADDR1, 0xFF, (u8)(addr >> 8)); if (retval) { - rtsx_trace(chip); return retval; } @@ -1572,14 +1478,12 @@ int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask, 0x80 | mode | ((func_no & 0x03) << 4)); if (retval) { - rtsx_trace(chip); return retval; } for (i = 0; i < MAX_RW_REG_CNT; i++) { retval = rtsx_read_register(chip, CFGRWCTL, &tmp); if (retval) { - rtsx_trace(chip); return retval; } if ((tmp & 0x80) == 0) @@ -1599,25 +1503,21 @@ int rtsx_read_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 *val) retval = rtsx_write_register(chip, CFGADDR0, 0xFF, (u8)addr); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CFGADDR1, 0xFF, (u8)(addr >> 8)); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CFGRWCTL, 0xFF, 0x80 | ((func_no & 0x03) << 4)); if (retval) { - rtsx_trace(chip); return retval; } for (i = 0; i < MAX_RW_REG_CNT; i++) { retval = rtsx_read_register(chip, CFGRWCTL, &tmp); if (retval) { - rtsx_trace(chip); return retval; } if ((tmp & 0x80) == 0) @@ -1627,7 +1527,6 @@ int rtsx_read_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 *val) for (i = 0; i < 4; i++) { retval = rtsx_read_register(chip, CFGDATA0 + i, &tmp); if (retval) { - rtsx_trace(chip); return retval; } data |= (u32)tmp << (i * 8); @@ -1649,7 +1548,6 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, int retval; if (!buf) { - rtsx_trace(chip); return STATUS_NOMEM; } @@ -1662,14 +1560,12 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, data = vzalloc(array_size(dw_len, 4)); if (!data) { - rtsx_trace(chip); return STATUS_NOMEM; } mask = vzalloc(array_size(dw_len, 4)); if (!mask) { vfree(data); - rtsx_trace(chip); return STATUS_NOMEM; } @@ -1694,7 +1590,6 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, if (retval != STATUS_SUCCESS) { vfree(data); vfree(mask); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1723,7 +1618,6 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, data = vmalloc(array_size(dw_len, 4)); if (!data) { - rtsx_trace(chip); return STATUS_NOMEM; } @@ -1732,7 +1626,6 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, data + i); if (retval != STATUS_SUCCESS) { vfree(data); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1763,29 +1656,24 @@ int rtsx_write_phy_register(struct rtsx_chip *chip, u8 addr, u16 val) retval = rtsx_write_register(chip, PHYDATA0, 0xFF, (u8)val); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, PHYDATA1, 0xFF, (u8)(val >> 8)); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, PHYADDR, 0xFF, addr); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, PHYRWCTL, 0xFF, 0x81); if (retval) { - rtsx_trace(chip); return retval; } for (i = 0; i < 100000; i++) { retval = rtsx_read_register(chip, PHYRWCTL, &tmp); if (retval) { - rtsx_trace(chip); return retval; } if (!(tmp & 0x80)) { @@ -1795,7 +1683,6 @@ int rtsx_write_phy_register(struct rtsx_chip *chip, u8 addr, u16 val) } if (!finished) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1812,19 +1699,16 @@ int rtsx_read_phy_register(struct rtsx_chip *chip, u8 addr, u16 *val) retval = rtsx_write_register(chip, PHYADDR, 0xFF, addr); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, PHYRWCTL, 0xFF, 0x80); if (retval) { - rtsx_trace(chip); return retval; } for (i = 0; i < 100000; i++) { retval = rtsx_read_register(chip, PHYRWCTL, &tmp); if (retval) { - rtsx_trace(chip); return retval; } if (!(tmp & 0x80)) { @@ -1834,19 +1718,16 @@ int rtsx_read_phy_register(struct rtsx_chip *chip, u8 addr, u16 *val) } if (!finished) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, PHYDATA0, &tmp); if (retval) { - rtsx_trace(chip); return retval; } data = tmp; retval = rtsx_read_register(chip, PHYDATA1, &tmp); if (retval) { - rtsx_trace(chip); return retval; } data |= (u16)tmp << 8; @@ -1865,14 +1746,12 @@ int rtsx_read_efuse(struct rtsx_chip *chip, u8 addr, u8 *val) retval = rtsx_write_register(chip, EFUSE_CTRL, 0xFF, 0x80 | addr); if (retval) { - rtsx_trace(chip); return retval; } for (i = 0; i < 100; i++) { retval = rtsx_read_register(chip, EFUSE_CTRL, &data); if (retval) { - rtsx_trace(chip); return retval; } if (!(data & 0x80)) @@ -1881,13 +1760,11 @@ int rtsx_read_efuse(struct rtsx_chip *chip, u8 addr, u8 *val) } if (data & 0x80) { - rtsx_trace(chip); return STATUS_TIMEDOUT; } retval = rtsx_read_register(chip, EFUSE_DATA, &data); if (retval) { - rtsx_trace(chip); return retval; } if (val) @@ -1911,20 +1788,17 @@ int rtsx_write_efuse(struct rtsx_chip *chip, u8 addr, u8 val) retval = rtsx_write_register(chip, EFUSE_DATA, 0xFF, tmp); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, EFUSE_CTRL, 0xFF, 0xA0 | addr); if (retval) { - rtsx_trace(chip); return retval; } for (j = 0; j < 100; j++) { retval = rtsx_read_register(chip, EFUSE_CTRL, &data); if (retval) { - rtsx_trace(chip); return retval; } if (!(data & 0x80)) @@ -1933,7 +1807,6 @@ int rtsx_write_efuse(struct rtsx_chip *chip, u8 addr, u8 val) } if (data & 0x80) { - rtsx_trace(chip); return STATUS_TIMEDOUT; } @@ -1950,7 +1823,6 @@ int rtsx_clr_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit) retval = rtsx_read_phy_register(chip, reg, &value); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1958,7 +1830,6 @@ int rtsx_clr_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit) value &= ~(1 << bit); retval = rtsx_write_phy_register(chip, reg, value); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1973,7 +1844,6 @@ int rtsx_set_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit) retval = rtsx_read_phy_register(chip, reg, &value); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1981,7 +1851,6 @@ int rtsx_set_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit) value |= (1 << bit); retval = rtsx_write_phy_register(chip, reg, value); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2285,7 +2154,6 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) u8 *ptr; if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -2299,7 +2167,6 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) retval = rtsx_send_cmd(chip, 0, 250); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2315,7 +2182,6 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) retval = rtsx_send_cmd(chip, 0, 250); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2333,7 +2199,6 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) u8 *ptr; if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -2350,7 +2215,6 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) retval = rtsx_send_cmd(chip, 0, 250); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2366,7 +2230,6 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) retval = rtsx_send_cmd(chip, 0, 250); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2377,7 +2240,6 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) int rtsx_check_chip_exist(struct rtsx_chip *chip) { if (rtsx_readl(chip, 0) == 0xFFFFFFFF) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2403,7 +2265,6 @@ int rtsx_force_power_on(struct rtsx_chip *chip, u8 ctl) if (mask) { retval = rtsx_write_register(chip, FPDCTL, mask, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2434,7 +2295,6 @@ int rtsx_force_power_down(struct rtsx_chip *chip, u8 ctl) val = mask; retval = rtsx_write_register(chip, FPDCTL, mask, val); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } diff --git a/drivers/staging/rts5208/rtsx_chip.h b/drivers/staging/rts5208/rtsx_chip.h index 8a8cd5d3cf7e..ec1c3d96d31a 100644 --- a/drivers/staging/rts5208/rtsx_chip.h +++ b/drivers/staging/rts5208/rtsx_chip.h @@ -644,19 +644,6 @@ struct spi_info { int spi_clock; }; -#ifdef _MSG_TRACE -struct trace_msg_t { - u16 line; -#define MSG_FUNC_LEN 64 - char func[MSG_FUNC_LEN]; -#define MSG_FILE_LEN 32 - char file[MSG_FILE_LEN]; -#define TIME_VAL_LEN 16 - u8 timeval_buf[TIME_VAL_LEN]; - u8 valid; -}; -#endif - /************/ /* LUN mode */ /************/ @@ -798,11 +785,6 @@ struct rtsx_chip { struct spi_info spi; -#ifdef _MSG_TRACE - struct trace_msg_t trace_msg[TRACE_ITEM_CNT]; - int msg_idx; -#endif - int auto_delink_cnt; int auto_delink_allowed; diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c index a401b13f5f5e..c9a6d97938f6 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -508,7 +508,6 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = vmalloc(scsi_bufflen(srb)); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -583,13 +582,11 @@ static int start_stop_unit(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (check_card_ready(chip, lun)) return TRANSPORT_GOOD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; break; } - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -604,7 +601,6 @@ static int allow_medium_removal(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (prevent) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -642,7 +638,6 @@ static int request_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = vmalloc(scsi_bufflen(srb)); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -764,7 +759,6 @@ static int mode_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); scsi_set_resid(srb, scsi_bufflen(srb)); - rtsx_trace(chip); return TRANSPORT_FAILED; } #endif @@ -790,7 +784,6 @@ static int mode_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = kmalloc(data_size, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -871,7 +864,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun) || (get_card_size(chip, lun) == 0)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -888,7 +880,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) */ dev_dbg(rtsx_dev(chip), "SD card being erased!\n"); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -897,7 +888,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) dev_dbg(rtsx_dev(chip), "SD card locked!\n"); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -923,7 +913,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) sec_cnt = ((u16)(srb->cmnd[9]) << 8) | srb->cmnd[10]; } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -934,7 +923,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) if ((start_sec > get_card_size(chip, lun)) || ((start_sec + sec_cnt) > get_card_size(chip, lun))) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LBA_OVER_RANGE); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -951,7 +939,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) else set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -960,7 +947,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) dev_dbg(rtsx_dev(chip), "Write protected card!\n"); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -981,7 +967,6 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip) SENSE_TYPE_MEDIA_WRITE_ERR); } retval = TRANSPORT_FAILED; - rtsx_trace(chip); goto exit; } else { chip->rw_fail_cnt[lun] = 0; @@ -1007,7 +992,6 @@ static int read_format_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { if (!chip->mspro_formatter_enable) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -1016,7 +1000,6 @@ static int read_format_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = kmalloc(buf_len, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1083,7 +1066,6 @@ static int read_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1095,7 +1077,6 @@ static int read_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = kmalloc(8, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1136,7 +1117,6 @@ static int read_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1145,7 +1125,6 @@ static int read_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1155,7 +1134,6 @@ static int read_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -1188,7 +1166,6 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_force_power_on(chip, SSC_PDCTL); if (retval != STATUS_SUCCESS) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1197,7 +1174,6 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { @@ -1205,7 +1181,6 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) len); buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1218,7 +1193,6 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -1249,13 +1223,11 @@ static int read_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (addr < 0xFC00) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1263,7 +1235,6 @@ static int read_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1273,7 +1244,6 @@ static int read_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -1307,14 +1277,12 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (addr < 0xFC00) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1325,7 +1293,6 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1335,7 +1302,6 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -1352,13 +1318,11 @@ static int get_sd_csd(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (get_lun_card(chip, lun) != SD_CARD) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1387,77 +1351,6 @@ static int toggle_gpio_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip) return TRANSPORT_GOOD; } -#ifdef _MSG_TRACE -static int trace_msg_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip) -{ - unsigned char *ptr, *buf = NULL; - int i, msg_cnt; - u8 clear; - unsigned int buf_len; - - buf_len = 4 + ((2 + MSG_FUNC_LEN + MSG_FILE_LEN + TIME_VAL_LEN) * - TRACE_ITEM_CNT); - - if ((scsi_bufflen(srb) < buf_len) || !scsi_sglist(srb)) { - set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); - return TRANSPORT_FAILED; - } - - clear = srb->cmnd[2]; - - buf = vmalloc(scsi_bufflen(srb)); - if (!buf) { - rtsx_trace(chip); - return TRANSPORT_ERROR; - } - ptr = buf; - - if (chip->trace_msg[chip->msg_idx].valid) - msg_cnt = TRACE_ITEM_CNT; - else - msg_cnt = chip->msg_idx; - - *(ptr++) = (u8)(msg_cnt >> 24); - *(ptr++) = (u8)(msg_cnt >> 16); - *(ptr++) = (u8)(msg_cnt >> 8); - *(ptr++) = (u8)msg_cnt; - dev_dbg(rtsx_dev(chip), "Trace message count is %d\n", msg_cnt); - - for (i = 1; i <= msg_cnt; i++) { - int j, idx; - - idx = chip->msg_idx - i; - if (idx < 0) - idx += TRACE_ITEM_CNT; - - *(ptr++) = (u8)(chip->trace_msg[idx].line >> 8); - *(ptr++) = (u8)(chip->trace_msg[idx].line); - for (j = 0; j < MSG_FUNC_LEN; j++) - *(ptr++) = chip->trace_msg[idx].func[j]; - - for (j = 0; j < MSG_FILE_LEN; j++) - *(ptr++) = chip->trace_msg[idx].file[j]; - - for (j = 0; j < TIME_VAL_LEN; j++) - *(ptr++) = chip->trace_msg[idx].timeval_buf[j]; - } - - rtsx_stor_set_xfer_buf(buf, scsi_bufflen(srb), srb); - vfree(buf); - - if (clear) { - chip->msg_idx = 0; - for (i = 0; i < TRACE_ITEM_CNT; i++) - chip->trace_msg[i].valid = 0; - } - - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; -} -#endif - static int read_host_reg(struct scsi_cmnd *srb, struct rtsx_chip *chip) { u8 addr, buf[4]; @@ -1543,7 +1436,6 @@ static int set_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip) default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } } else if (srb->cmnd[3] == 2) { @@ -1567,7 +1459,6 @@ static int set_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1575,7 +1466,6 @@ static int set_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip) } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1608,7 +1498,6 @@ static int get_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip) default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1619,7 +1508,6 @@ static int get_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip) rtsx_stor_set_xfer_buf(&tmp, 1, srb); } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1659,7 +1547,6 @@ static int dma_access_ring_buffer(struct scsi_cmnd *srb, struct rtsx_chip *chip) set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } scsi_set_resid(srb, 0); @@ -1807,7 +1694,6 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!CHECK_PID(chip, 0x5208)) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1817,7 +1703,6 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) chip->phy_debug_mode = 1; retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1825,21 +1710,18 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_read_phy_register(chip, 0x1C, ®); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } reg |= 0x0001; retval = rtsx_write_phy_register(chip, 0x1C, reg); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { chip->phy_debug_mode = 0; retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0x77); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1847,14 +1729,12 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_read_phy_register(chip, 0x1C, ®); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } reg &= 0xFFFE; retval = rtsx_write_phy_register(chip, 0x1C, reg); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -1887,7 +1767,6 @@ static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (cmd_type > 2) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } addr = (srb->cmnd[5] << 8) | srb->cmnd[6]; @@ -1906,7 +1785,6 @@ static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (scsi_bufflen(srb) < 1) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } rtsx_stor_set_xfer_buf(&value, 1, srb); @@ -1915,13 +1793,11 @@ static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rtsx_chip *chip) default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1965,7 +1841,6 @@ static int read_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (len) { buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1974,7 +1849,6 @@ static int read_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -1985,7 +1859,6 @@ static int read_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) set_sense_type (chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2031,7 +1904,6 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2043,7 +1915,6 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2054,7 +1925,6 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -2082,7 +1952,6 @@ static int erase_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_force_power_on(chip, SSC_PDCTL); if (retval != STATUS_SUCCESS) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2094,7 +1963,6 @@ static int erase_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } else if (mode == 1) { @@ -2102,13 +1970,11 @@ static int erase_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2134,7 +2000,6 @@ static int read_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2143,7 +2008,6 @@ static int read_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2153,7 +2017,6 @@ static int read_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -2187,7 +2050,6 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2198,7 +2060,6 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2208,7 +2069,6 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -2237,7 +2097,6 @@ static int read_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2246,7 +2105,6 @@ static int read_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2256,7 +2114,6 @@ static int read_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) vfree(buf); set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -2291,7 +2148,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) len = (u8)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2301,7 +2157,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_force_power_on(chip, SSC_PDCTL); if (retval != STATUS_SUCCESS) { vfree(buf); - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2309,7 +2164,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_read_phy_register(chip, 0x08, &val); if (retval != STATUS_SUCCESS) { vfree(buf); - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2317,7 +2171,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) LDO3318_PWR_MASK, LDO_OFF); if (retval != STATUS_SUCCESS) { vfree(buf); - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2327,7 +2180,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) 0x4C00 | chip->phy_voltage); if (retval != STATUS_SUCCESS) { vfree(buf); - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2335,7 +2187,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) LDO3318_PWR_MASK, LDO_ON); if (retval != STATUS_SUCCESS) { vfree(buf); - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2345,7 +2196,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = card_power_on(chip, SPI_CARD); if (retval != STATUS_SUCCESS) { vfree(buf); - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2357,7 +2207,6 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); result = TRANSPORT_FAILED; - rtsx_trace(chip); goto exit; } } @@ -2367,7 +2216,6 @@ exit: retval = card_power_off(chip, SPI_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2375,7 +2223,6 @@ exit: retval = rtsx_write_register(chip, PWR_GATE_CTRL, LDO3318_PWR_MASK, LDO_OFF); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2383,14 +2230,12 @@ exit: retval = rtsx_write_phy_register(chip, 0x08, val); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_ERROR; } retval = rtsx_write_register(chip, PWR_GATE_CTRL, LDO3318_PWR_MASK, LDO_ON); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_ERROR; } } @@ -2429,13 +2274,11 @@ static int read_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (func > func_max) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2444,7 +2287,6 @@ static int read_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip) set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); vfree(buf); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2488,14 +2330,12 @@ static int write_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (func > func_max) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2506,7 +2346,6 @@ static int write_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); vfree(buf); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2597,7 +2436,6 @@ static int app_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip) default: set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2740,7 +2578,6 @@ static int get_card_bus_width(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2749,7 +2586,6 @@ static int get_card_bus_width(struct scsi_cmnd *srb, struct rtsx_chip *chip) bus_width = chip->card_bus_width[lun]; } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2767,7 +2603,6 @@ static int spi_vendor_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (CHECK_PID(chip, 0x5208) || CHECK_PID(chip, 0x5288)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2817,14 +2652,12 @@ static int spi_vendor_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip) rtsx_write_register(chip, CARD_GPIO_DIR, 0x07, gpio_dir); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } rtsx_write_register(chip, CARD_GPIO_DIR, 0x07, gpio_dir); if (result != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2868,12 +2701,6 @@ static int vendor_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) result = get_card_bus_width(srb, chip); break; -#ifdef _MSG_TRACE - case TRACE_MSG: - result = trace_msg_cmd(srb, chip); - break; -#endif - case SCSI_APP_CMD: result = app_cmd(srb, chip); break; @@ -2885,7 +2712,6 @@ static int vendor_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) default: set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2926,7 +2752,6 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (get_lun_card(chip, lun) != MS_CARD) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2934,7 +2759,6 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[5] != 0x66) || (srb->cmnd[6] != 0x6D) || (srb->cmnd[7] != 0x74)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2947,7 +2771,6 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun) || (get_card_size(chip, lun) == 0)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -2960,26 +2783,22 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!(chip->card_ready & MS_CARD)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (chip->card_wp & MS_CARD) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (!CHK_MSPRO(ms_card)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - rtsx_trace(chip); return TRANSPORT_FAILED; } retval = mspro_format(srb, chip, MS_SHORT_DATA_LEN, quick_format); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -2999,12 +2818,10 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (get_lun_card(chip, lun) != MS_CARD) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3012,7 +2829,6 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[5] != 0x53) || (srb->cmnd[6] != 0x49) || (srb->cmnd[7] != 0x44)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3021,7 +2837,6 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) (!CHK_MSXC(ms_card) && (dev_info_id == 0x13)) || !CHK_MSPRO(ms_card)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3035,7 +2850,6 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = kmalloc(buf_len, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -3124,12 +2938,10 @@ static int sd_extension_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (get_lun_card(chip, lun) != SD_CARD) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3160,7 +2972,6 @@ static int sd_extension_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip) default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3188,24 +2999,20 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (get_lun_card(chip, lun) != MS_CARD) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (srb->cmnd[7] != KC_MG_R_PRO) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (!CHK_MSPRO(ms_card)) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3219,14 +3026,12 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[9] == 0x1C)) { retval = mg_get_local_EKB(srb, chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } break; @@ -3237,14 +3042,12 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[9] == 0x24)) { retval = mg_get_rsp_chg(srb, chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } break; @@ -3260,21 +3063,18 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[5] < 32)) { retval = mg_get_ICV(srb, chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } break; default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3301,29 +3101,24 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!check_card_ready(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (check_card_wp(chip, lun)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (get_lun_card(chip, lun) != MS_CARD) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (srb->cmnd[7] != KC_MG_R_PRO) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (!CHK_MSPRO(ms_card)) { set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3337,14 +3132,12 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[9] == 0x0C)) { retval = mg_set_leaf_id(srb, chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } break; @@ -3355,14 +3148,12 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[9] == 0x0C)) { retval = mg_chg(srb, chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } break; @@ -3373,14 +3164,12 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[9] == 0x0C)) { retval = mg_rsp(srb, chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } break; @@ -3396,21 +3185,18 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[5] < 32)) { retval = mg_set_ICV(srb, chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } else { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } break; default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -3440,7 +3226,6 @@ int rtsx_scsi_handler(struct scsi_cmnd *srb, struct rtsx_chip *chip) /* Logical Unit Not Ready Format in Progress */ set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, 0, 0); - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -3453,7 +3238,6 @@ int rtsx_scsi_handler(struct scsi_cmnd *srb, struct rtsx_chip *chip) /* Logical Unit Not Ready Format in Progress */ set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, 0, (u16)(ms_card->progress)); - rtsx_trace(chip); return TRANSPORT_FAILED; } } diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index 716cce2bd7f0..b4a796c570c2 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -275,7 +275,6 @@ int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout) dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n", chip->int_reg); err = -ETIMEDOUT; - rtsx_trace(chip); goto finish_send_cmd; } diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c index d548bc695f9e..f2778abf10c0 100644 --- a/drivers/staging/rts5208/sd.c +++ b/drivers/staging/rts5208/sd.c @@ -110,13 +110,11 @@ static int sd_check_data0_status(struct rtsx_chip *chip) retval = rtsx_read_register(chip, REG_SD_STAT1, &stat); if (retval) { - rtsx_trace(chip); return retval; } if (!(stat & SD_DAT0_STATUS)) { sd_set_err_code(chip, SD_BUSY); - rtsx_trace(chip); return STATUS_FAIL; } @@ -191,7 +189,6 @@ RTY_SEND_CMD: retval = sd_check_data0_status(chip); if (retval != STATUS_SUCCESS) { rtsx_clear_sd_error(chip); - rtsx_trace(chip); return retval; } } else { @@ -203,7 +200,6 @@ RTY_SEND_CMD: } rtsx_clear_sd_error(chip); - rtsx_trace(chip); return retval; } @@ -214,7 +210,6 @@ RTY_SEND_CMD: if ((ptr[0] & 0xC0) != 0) { sd_set_err_code(chip, SD_STS_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -222,7 +217,6 @@ RTY_SEND_CMD: if (ptr[stat_idx] & SD_CRC7_ERR) { if (cmd_idx == WRITE_MULTIPLE_BLOCK) { sd_set_err_code(chip, SD_CRC_ERR); - rtsx_trace(chip); return STATUS_FAIL; } if (rty_cnt < SD_MAX_RETRY_COUNT) { @@ -231,7 +225,6 @@ RTY_SEND_CMD: goto RTY_SEND_CMD; } else { sd_set_err_code(chip, SD_CRC_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -242,7 +235,6 @@ RTY_SEND_CMD: (cmd_idx != SEND_IF_COND)) { if (cmd_idx != STOP_TRANSMISSION) { if (ptr[1] & 0x80) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -253,19 +245,16 @@ RTY_SEND_CMD: #endif dev_dbg(rtsx_dev(chip), "ptr[1]: 0x%02x\n", ptr[1]); - rtsx_trace(chip); return STATUS_FAIL; } if (ptr[2] & 0xFF) { dev_dbg(rtsx_dev(chip), "ptr[2]: 0x%02x\n", ptr[2]); - rtsx_trace(chip); return STATUS_FAIL; } if (ptr[3] & 0x80) { dev_dbg(rtsx_dev(chip), "ptr[3]: 0x%02x\n", ptr[3]); - rtsx_trace(chip); return STATUS_FAIL; } if (ptr[3] & 0x01) @@ -296,7 +285,6 @@ static int sd_read_data(struct rtsx_chip *chip, buf_len = 0; if (buf_len > 512) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -338,14 +326,12 @@ static int sd_read_data(struct rtsx_chip *chip, SD_RSP_TYPE_R1, NULL, 0); } - rtsx_trace(chip); return STATUS_FAIL; } if (buf && buf_len) { retval = rtsx_read_ppbuf(chip, buf, buf_len); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -368,14 +354,12 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode, if (buf_len > 512) { /* This function can't write data more than one page */ - rtsx_trace(chip); return STATUS_FAIL; } if (buf && buf_len) { retval = rtsx_write_ppbuf(chip, buf, buf_len); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -416,7 +400,6 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode, SD_RSP_TYPE_R1, NULL, 0); } - rtsx_trace(chip); return STATUS_FAIL; } @@ -434,7 +417,6 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) for (i = 0; i < 6; i++) { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) { sd_set_err_code(chip, SD_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -445,7 +427,6 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) } if (i == 6) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -489,11 +470,9 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp) else sd_card->sd_clock = CLK_20; } else { - rtsx_trace(chip); return STATUS_FAIL; } } else { - rtsx_trace(chip); return STATUS_FAIL; } @@ -565,7 +544,6 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip) retval = rtsx_write_register(chip, REG_SD_CFG1, 0x1C, val); if (retval) { - rtsx_trace(chip); return retval; } @@ -629,7 +607,6 @@ static int sd_set_clock_divider(struct rtsx_chip *chip, u8 clk_div) retval = rtsx_write_register(chip, REG_SD_CFG1, mask, val); if (retval) { - rtsx_trace(chip); return retval; } @@ -643,7 +620,6 @@ static int sd_set_init_para(struct rtsx_chip *chip) retval = sd_set_sample_push_timing(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -651,7 +627,6 @@ static int sd_set_init_para(struct rtsx_chip *chip) retval = switch_clock(chip, sd_card->sd_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -677,7 +652,6 @@ int sd_select_card(struct rtsx_chip *chip, int select) retval = sd_send_cmd_get_rsp(chip, cmd_idx, addr, cmd_type, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -694,7 +668,6 @@ static int sd_update_lock_status(struct rtsx_chip *chip) retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, rsp, 5); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -707,7 +680,6 @@ static int sd_update_lock_status(struct rtsx_chip *chip) sd_card->sd_lock_status); if (rsp[1] & 0x01) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -727,7 +699,6 @@ static int sd_wait_state_data_ready(struct rtsx_chip *chip, u8 state, sd_card->sd_addr, SD_RSP_TYPE_R1, rsp, 5); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -736,7 +707,6 @@ static int sd_wait_state_data_ready(struct rtsx_chip *chip, u8 state, return STATUS_SUCCESS; } - rtsx_trace(chip); return STATUS_FAIL; } @@ -750,14 +720,12 @@ static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage) 0x4FC0 | chip->phy_voltage); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { retval = rtsx_write_register(chip, SD_PAD_CTL, SD_IO_USING_1V8, 0); if (retval) { - rtsx_trace(chip); return retval; } } @@ -767,7 +735,6 @@ static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage) 0x4C40 | chip->phy_voltage); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -775,12 +742,10 @@ static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage) SD_IO_USING_1V8, SD_IO_USING_1V8); if (retval) { - rtsx_trace(chip); return retval; } } } else { - rtsx_trace(chip); return STATUS_FAIL; } @@ -796,14 +761,12 @@ static int sd_voltage_switch(struct rtsx_chip *chip) SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, SD_CLK_TOGGLE_EN); if (retval) { - rtsx_trace(chip); return retval; } retval = sd_send_cmd_get_rsp(chip, VOLTAGE_SWITCH, 0, SD_RSP_TYPE_R1, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -811,24 +774,20 @@ static int sd_voltage_switch(struct rtsx_chip *chip) retval = rtsx_read_register(chip, SD_BUS_STAT, &stat); if (retval) { - rtsx_trace(chip); return retval; } if (stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | SD_DAT1_STATUS | SD_DAT0_STATUS)) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, SD_BUS_STAT, 0xFF, SD_CLK_FORCE_STOP); if (retval) { - rtsx_trace(chip); return retval; } retval = sd_change_bank_voltage(chip, SD_IO_1V8); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -837,14 +796,12 @@ static int sd_voltage_switch(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SD_BUS_STAT, 0xFF, SD_CLK_TOGGLE_EN); if (retval) { - rtsx_trace(chip); return retval; } wait_timeout(10); retval = rtsx_read_register(chip, SD_BUS_STAT, &stat); if (retval) { - rtsx_trace(chip); return retval; } if ((stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | @@ -855,14 +812,12 @@ static int sd_voltage_switch(struct rtsx_chip *chip) rtsx_write_register(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); rtsx_write_register(chip, CARD_CLK_EN, 0xFF, 0); - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -877,24 +832,20 @@ static int sd_reset_dcm(struct rtsx_chip *chip, u8 tune_dir) retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF, DCM_RESET | DCM_RX); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF, DCM_RX); if (retval) { - rtsx_trace(chip); return retval; } } else { retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF, DCM_RESET | DCM_TX); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF, DCM_TX); if (retval) { - rtsx_trace(chip); return retval; } } @@ -927,30 +878,25 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) retval = rtsx_write_register(chip, CLK_CTL, CHANGE_CLK, CHANGE_CLK); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SD_VP_CTL, 0x1F, sample_point); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, PHASE_NOT_RESET); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CLK_CTL, CHANGE_CLK, 0); if (retval) { - rtsx_trace(chip); return retval; } } else { @@ -964,7 +910,6 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) PHASE_CHANGE, PHASE_CHANGE); if (retval) { - rtsx_trace(chip); return retval; } udelay(50); @@ -973,14 +918,12 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) PHASE_NOT_RESET | sample_point); if (retval) { - rtsx_trace(chip); return retval; } } else { retval = rtsx_write_register(chip, CLK_CTL, CHANGE_CLK, CHANGE_CLK); if (retval) { - rtsx_trace(chip); return retval; } udelay(50); @@ -988,7 +931,6 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) PHASE_NOT_RESET | sample_point); if (retval) { - rtsx_trace(chip); return retval; } } @@ -1001,39 +943,33 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) DCMPS_CHANGE_DONE, DCMPS_CHANGE_DONE); retval = rtsx_send_cmd(chip, SD_CARD, 100); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto fail; } val = *rtsx_get_cmd_data(chip); if (val & DCMPS_ERROR) { - rtsx_trace(chip); goto fail; } if ((val & DCMPS_CURRENT_PHASE) != sample_point) { - rtsx_trace(chip); goto fail; } retval = rtsx_write_register(chip, SD_DCMPS_CTL, DCMPS_CHANGE, 0); if (retval) { - rtsx_trace(chip); return retval; } if (ddr_rx) { retval = rtsx_write_register(chip, SD_VP_CTL, PHASE_CHANGE, 0); if (retval) { - rtsx_trace(chip); return retval; } } else { retval = rtsx_write_register(chip, CLK_CTL, CHANGE_CLK, 0); if (retval) { - rtsx_trace(chip); return retval; } } @@ -1043,7 +979,6 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir) retval = rtsx_write_register(chip, SD_CFG1, SD_ASYNC_FIFO_NOT_RST, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -1071,7 +1006,6 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width) retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1085,14 +1019,12 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width) buf, 8, 250); if (retval != STATUS_SUCCESS) { rtsx_clear_sd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } memcpy(sd_card->raw_scr, buf, 8); if ((buf[0] & 0x0F) == 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1136,7 +1068,6 @@ static int sd_query_switch_result(struct rtsx_chip *chip, u8 func_group, break; default: - rtsx_trace(chip); return STATUS_FAIL; } } else if (func_group == SD_FUNC_GROUP_3) { @@ -1164,7 +1095,6 @@ static int sd_query_switch_result(struct rtsx_chip *chip, u8 func_group, break; default: - rtsx_trace(chip); return STATUS_FAIL; } } else if (func_group == SD_FUNC_GROUP_4) { @@ -1192,18 +1122,15 @@ static int sd_query_switch_result(struct rtsx_chip *chip, u8 func_group, break; default: - rtsx_trace(chip); return STATUS_FAIL; } } else { - rtsx_trace(chip); return STATUS_FAIL; } if (func_group == SD_FUNC_GROUP_1) { if (!(buf[support_offset] & support_mask) || ((buf[query_switch_offset] & 0x0F) != query_switch)) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1211,7 +1138,6 @@ static int sd_query_switch_result(struct rtsx_chip *chip, u8 func_group, /* Check 'Busy Status' */ if ((buf[DATA_STRUCTURE_VER_OFFSET] == 0x01) && ((buf[check_busy_offset] & switch_busy) == switch_busy)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1254,7 +1180,6 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode, u8 func_group, buf, 64, 250); if (retval != STATUS_SUCCESS) { rtsx_clear_sd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1283,14 +1208,12 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode, u8 func_group, dev_dbg(rtsx_dev(chip), "Maximum current consumption: %dmA\n", cc); if ((cc == 0) || (cc > 800)) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_query_switch_result(chip, func_group, func_to_switch, buf, 64); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1299,14 +1222,12 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode, u8 func_group, SD_OCP_THD_MASK, chip->sd_800mA_ocp_thd); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PWR_CTL, PMOS_STRG_MASK, PMOS_STRG_800mA); if (retval) { - rtsx_trace(chip); return retval; } } @@ -1339,7 +1260,6 @@ static int sd_check_switch(struct rtsx_chip *chip, for (i = 0; i < 3; i++) { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) { sd_set_err_code(chip, SD_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1359,12 +1279,10 @@ static int sd_check_switch(struct rtsx_chip *chip, retval = rtsx_read_register(chip, SD_STAT1, &stat); if (retval) { - rtsx_trace(chip); return retval; } if (stat & SD_CRC16_ERR) { dev_dbg(rtsx_dev(chip), "SD CRC16 error when switching mode\n"); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1376,7 +1294,6 @@ static int sd_check_switch(struct rtsx_chip *chip, } if (!switch_good) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1394,7 +1311,6 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) retval = sd_check_switch_mode(chip, SD_CHECK_MODE, NO_ARGUMENT, NO_ARGUMENT, bus_width); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1462,7 +1378,6 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) sd_card->sd_switch_fail = SDR104_SUPPORT_MASK | DDR50_SUPPORT_MASK | SDR50_SUPPORT_MASK; } - rtsx_trace(chip); return STATUS_FAIL; } @@ -1480,12 +1395,10 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) retval = rtsx_write_register(chip, SD_PUSH_POINT_CTL, 0x06, 0x04); if (retval) { - rtsx_trace(chip); return retval; } retval = sd_set_sample_push_timing(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1542,7 +1455,6 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) bus_width); if (retval != STATUS_SUCCESS) { if (sd_check_err_code(chip, SD_NO_CARD)) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1553,7 +1465,6 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) if (CHK_SD_DDR50(sd_card)) { retval = rtsx_write_register(chip, SD_PUSH_POINT_CTL, 0x06, 0); if (retval) { - rtsx_trace(chip); return retval; } } @@ -1570,7 +1481,6 @@ static int sd_wait_data_idle(struct rtsx_chip *chip) for (i = 0; i < 100; i++) { retval = rtsx_read_register(chip, SD_DATA_STATE, &val); if (retval) { - rtsx_trace(chip); return retval; } if (val & SD_DATA_IDLE) { @@ -1591,7 +1501,6 @@ static int sd_sdr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = sd_change_phase(chip, sample_point, TUNE_RX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1607,7 +1516,6 @@ static int sd_sdr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point) (void)sd_wait_data_idle(chip); rtsx_clear_sd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1622,7 +1530,6 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = sd_change_phase(chip, sample_point, TUNE_RX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1631,7 +1538,6 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1647,7 +1553,6 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point) (void)sd_wait_data_idle(chip); rtsx_clear_sd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1669,7 +1574,6 @@ static int mmc_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = sd_change_phase(chip, sample_point, TUNE_RX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1687,7 +1591,6 @@ static int mmc_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point) (void)sd_wait_data_idle(chip); rtsx_clear_sd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1701,14 +1604,12 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = sd_change_phase(chip, sample_point, TUNE_TX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, SD_RSP_80CLK_TIMEOUT_EN); if (retval) { - rtsx_trace(chip); return retval; } @@ -1718,7 +1619,6 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point) if (sd_check_err_code(chip, SD_RSP_TIMEOUT)) { rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1726,7 +1626,6 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -1741,7 +1640,6 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = sd_change_phase(chip, sample_point, TUNE_TX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1758,14 +1656,12 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point) retval = sd_wait_state_data_ready(chip, 0x08, 1, 1000); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, SD_RSP_80CLK_TIMEOUT_EN); if (retval) { - rtsx_trace(chip); return retval; } @@ -1780,14 +1676,12 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point) if (retval != STATUS_SUCCESS) { rtsx_clear_sd_error(chip); rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -1935,7 +1829,6 @@ static int sd_tuning_rx(struct rtsx_chip *chip) if (CHK_MMC_DDR52(sd_card)) { tuning_cmd = mmc_ddr_tuning_rx_cmd; } else { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1945,7 +1838,6 @@ static int sd_tuning_rx(struct rtsx_chip *chip) for (j = MAX_PHASE; j >= 0; j--) { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) { sd_set_err_code(chip, SD_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1964,13 +1856,11 @@ static int sd_tuning_rx(struct rtsx_chip *chip) final_phase = sd_search_final_phase(chip, phase_map, TUNE_RX); if (final_phase == 0xFF) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_change_phase(chip, final_phase, TUNE_RX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1988,7 +1878,6 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, SD_RSP_80CLK_TIMEOUT_EN); if (retval) { - rtsx_trace(chip); return retval; } @@ -1998,7 +1887,6 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip) sd_set_err_code(chip, SD_NO_CARD); rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2017,7 +1905,6 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -2026,13 +1913,11 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip) final_phase = sd_search_final_phase(chip, phase_map, TUNE_TX); if (final_phase == 0xFF) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_change_phase(chip, final_phase, TUNE_TX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2061,7 +1946,6 @@ static int sd_tuning_tx(struct rtsx_chip *chip) if (CHK_MMC_DDR52(sd_card)) { tuning_cmd = sd_ddr_tuning_tx_cmd; } else { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2073,7 +1957,6 @@ static int sd_tuning_tx(struct rtsx_chip *chip) sd_set_err_code(chip, SD_NO_CARD); rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2092,13 +1975,11 @@ static int sd_tuning_tx(struct rtsx_chip *chip) final_phase = sd_search_final_phase(chip, phase_map, TUNE_TX); if (final_phase == 0xFF) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_change_phase(chip, final_phase, TUNE_TX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2111,13 +1992,11 @@ static int sd_sdr_tuning(struct rtsx_chip *chip) retval = sd_tuning_tx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_tuning_rx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2131,28 +2010,24 @@ static int sd_ddr_tuning(struct rtsx_chip *chip) if (!(chip->sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) { retval = sd_ddr_pre_tuning_tx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { retval = sd_change_phase(chip, (u8)chip->sd_ddr_tx_phase, TUNE_TX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } retval = sd_tuning_rx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (!(chip->sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) { retval = sd_tuning_tx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2167,28 +2042,24 @@ static int mmc_ddr_tuning(struct rtsx_chip *chip) if (!(chip->sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) { retval = sd_ddr_pre_tuning_tx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { retval = sd_change_phase(chip, (u8)chip->mmc_ddr_tx_phase, TUNE_TX); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } retval = sd_tuning_rx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (!(chip->sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) { retval = sd_tuning_tx(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2204,13 +2075,11 @@ int sd_switch_clock(struct rtsx_chip *chip) retval = select_card(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = switch_clock(chip, sd_card->sd_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2226,7 +2095,6 @@ int sd_switch_clock(struct rtsx_chip *chip) } if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2259,26 +2127,22 @@ static int sd_prepare_reset(struct rtsx_chip *chip) retval = sd_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, REG_SD_CFG1, 0xFF, 0x40); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_STOP, SD_STOP | SD_CLR_ERR, SD_STOP | SD_CLR_ERR); if (retval) { - rtsx_trace(chip); return retval; } retval = select_card(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2294,41 +2158,35 @@ static int sd_pull_ctl_disable(struct rtsx_chip *chip) XD_D3_PD | SD_D7_PD | SD_CLK_PD | SD_D5_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, SD_D6_PD | SD_D0_PD | SD_D1_PD | XD_D5_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF, SD_D4_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF, XD_RDY_PD | SD_D3_PD | SD_D2_PD | XD_ALE_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF, MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF, MS_D5_PD | MS_D4_PD); if (retval) { - rtsx_trace(chip); return retval; } } else if (CHECK_PID(chip, 0x5288)) { @@ -2336,25 +2194,21 @@ static int sd_pull_ctl_disable(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_PULL_CTL1, 0xFF, 0x55); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, 0x55); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF, 0x4B); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF, 0x69); if (retval) { - rtsx_trace(chip); return retval; } } @@ -2397,7 +2251,6 @@ int sd_pull_ctl_enable(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, SD_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2410,7 +2263,6 @@ static int sd_init_power(struct rtsx_chip *chip) retval = sd_power_off_card3v3(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2419,21 +2271,18 @@ static int sd_init_power(struct rtsx_chip *chip) retval = enable_card_clock(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (chip->asic_code) { retval = sd_pull_ctl_enable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { retval = rtsx_write_register(chip, FPGA_PULL_CTL, FPGA_SD_PULL_CTL_BIT | 0x20, 0); if (retval) { - rtsx_trace(chip); return retval; } } @@ -2441,7 +2290,6 @@ static int sd_init_power(struct rtsx_chip *chip) if (!chip->ft2_fast_mode) { retval = card_power_on(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2451,7 +2299,6 @@ static int sd_init_power(struct rtsx_chip *chip) if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n", chip->ocp_stat); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -2460,7 +2307,6 @@ static int sd_init_power(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN); if (retval) { - rtsx_trace(chip); return retval; } @@ -2473,13 +2319,11 @@ static int sd_dummy_clock(struct rtsx_chip *chip) retval = rtsx_write_register(chip, REG_SD_CFG3, 0x01, 0x01); if (retval) { - rtsx_trace(chip); return retval; } wait_timeout(5); retval = rtsx_write_register(chip, REG_SD_CFG3, 0x01, 0); if (retval) { - rtsx_trace(chip); return retval; } @@ -2513,7 +2357,6 @@ static int sd_read_lba0(struct rtsx_chip *chip) bus_width, NULL, 0, 100); if (retval != STATUS_SUCCESS) { rtsx_clear_sd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2531,7 +2374,6 @@ static int sd_check_wp_state(struct rtsx_chip *chip) retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2548,7 +2390,6 @@ static int sd_check_wp_state(struct rtsx_chip *chip) sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2849,7 +2690,6 @@ SD_UNLOCK_ENTRY: retval = rtsx_write_register(chip, SD30_DRIVE_SEL, 0x07, chip->sd30_drive_sel_1v8); if (retval) { - rtsx_trace(chip); return retval; } @@ -2914,13 +2754,11 @@ SD_UNLOCK_ENTRY: retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_H, 0xFF, 0x02); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_L, 0xFF, 0x00); if (retval) { - rtsx_trace(chip); return retval; } } @@ -2929,7 +2767,6 @@ SD_UNLOCK_ENTRY: return STATUS_SUCCESS; status_fail: - rtsx_trace(chip); return STATUS_FAIL; } @@ -2944,7 +2781,6 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width) retval = sd_send_cmd_get_rsp(chip, BUSTEST_W, 0, SD_RSP_TYPE_R1, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return SWITCH_FAIL; } @@ -2963,7 +2799,6 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width) retval = rtsx_write_register(chip, REG_SD_CFG3, 0x02, 0x02); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return SWITCH_ERR; } @@ -2972,13 +2807,11 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width) if (retval != STATUS_SUCCESS) { rtsx_clear_sd_error(chip); rtsx_write_register(chip, REG_SD_CFG3, 0x02, 0); - rtsx_trace(chip); return SWITCH_ERR; } retval = rtsx_write_register(chip, REG_SD_CFG3, 0x02, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return SWITCH_ERR; } @@ -3015,7 +2848,6 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width) retval = rtsx_send_cmd(chip, SD_CARD, 100); if (retval < 0) { rtsx_clear_sd_error(chip); - rtsx_trace(chip); return SWITCH_ERR; } @@ -3058,7 +2890,6 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width) } } - rtsx_trace(chip); return SWITCH_FAIL; } @@ -3109,7 +2940,6 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, bool switch_ddr) sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0); } - rtsx_trace(chip); return STATUS_FAIL; } @@ -3117,7 +2947,6 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, bool switch_ddr) if (ptr[0] & SD_TRANSFER_ERR) { sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3151,7 +2980,6 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, bool switch_ddr) sd_choose_proper_clock(chip); retval = switch_clock(chip, sd_card->sd_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3175,11 +3003,9 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, bool switch_ddr) CLR_MMC_8BIT(sd_card); CLR_MMC_4BIT(sd_card); } else { - rtsx_trace(chip); return STATUS_FAIL; } } else { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3203,7 +3029,6 @@ static int reset_mmc(struct rtsx_chip *chip) switch_fail: retval = sd_prepare_reset(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return retval; } @@ -3213,14 +3038,12 @@ RTY_MMC_RST: retval = sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } do { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) { sd_set_err_code(chip, SD_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3235,7 +3058,6 @@ RTY_MMC_RST: sd_clr_err_code(chip); goto RTY_MMC_RST; } else { - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -3244,7 +3066,6 @@ RTY_MMC_RST: sd_clr_err_code(chip); goto RTY_MMC_RST; } else { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3255,7 +3076,6 @@ RTY_MMC_RST: } while (!(rsp[1] & 0x80) && (i < 255)); if (i == 255) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3267,7 +3087,6 @@ RTY_MMC_RST: retval = sd_send_cmd_get_rsp(chip, ALL_SEND_CID, 0, SD_RSP_TYPE_R2, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3275,13 +3094,11 @@ RTY_MMC_RST: retval = sd_send_cmd_get_rsp(chip, SET_RELATIVE_ADDR, sd_card->sd_addr, SD_RSP_TYPE_R6, rsp, 5); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_check_csd(chip, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3289,14 +3106,12 @@ RTY_MMC_RST: retval = sd_select_card(chip, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, SD_RSP_TYPE_R1, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3304,14 +3119,12 @@ RTY_MMC_RST: MMC_UNLOCK_ENTRY: retval = sd_update_lock_status(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } #endif retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3324,24 +3137,20 @@ MMC_UNLOCK_ENTRY: if (retval != STATUS_SUCCESS) { retval = sd_init_power(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } sd_card->mmc_dont_switch_bus = 1; - rtsx_trace(chip); goto switch_fail; } } if (CHK_MMC_SECTOR_MODE(sd_card) && (sd_card->capacity == 0)) { - rtsx_trace(chip); return STATUS_FAIL; } if (switch_ddr && CHK_MMC_DDR52(sd_card)) { retval = sd_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3349,12 +3158,10 @@ MMC_UNLOCK_ENTRY: if (retval != STATUS_SUCCESS) { retval = sd_init_power(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } switch_ddr = false; - rtsx_trace(chip); goto switch_fail; } @@ -3364,12 +3171,10 @@ MMC_UNLOCK_ENTRY: if (retval != STATUS_SUCCESS) { retval = sd_init_power(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } switch_ddr = false; - rtsx_trace(chip); goto switch_fail; } } @@ -3381,13 +3186,11 @@ MMC_UNLOCK_ENTRY: retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_H, 0xFF, 0x02); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_L, 0xFF, 0x00); if (retval) { - rtsx_trace(chip); return retval; } } @@ -3412,7 +3215,6 @@ int reset_sd_card(struct rtsx_chip *chip) retval = enable_card_clock(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3421,7 +3223,6 @@ int reset_sd_card(struct rtsx_chip *chip) if (chip->asic_code) { retval = sd_pull_ctl_enable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -3429,24 +3230,20 @@ int reset_sd_card(struct rtsx_chip *chip) FPGA_SD_PULL_CTL_BIT | 0x20, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } retval = card_share_mode(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } chip->sd_io = 1; - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_init_power(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3454,13 +3251,11 @@ int reset_sd_card(struct rtsx_chip *chip) retval = reset_mmc(chip); if (retval != STATUS_SUCCESS) { if (sd_check_err_code(chip, SD_NO_CARD)) { - rtsx_trace(chip); return STATUS_FAIL; } retval = reset_sd(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3468,17 +3263,14 @@ int reset_sd_card(struct rtsx_chip *chip) retval = reset_sd(chip); if (retval != STATUS_SUCCESS) { if (sd_check_err_code(chip, SD_NO_CARD)) { - rtsx_trace(chip); return STATUS_FAIL; } if (chip->sd_io) { - rtsx_trace(chip); return STATUS_FAIL; } retval = reset_mmc(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3486,18 +3278,15 @@ int reset_sd_card(struct rtsx_chip *chip) retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_L, 0xFF, 0); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_H, 0xFF, 2); if (retval) { - rtsx_trace(chip); return retval; } @@ -3505,7 +3294,6 @@ int reset_sd_card(struct rtsx_chip *chip) retval = sd_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3534,36 +3322,30 @@ static int reset_mmc_only(struct rtsx_chip *chip) retval = enable_card_clock(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_init_power(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = reset_mmc(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_L, 0xFF, 0); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_H, 0xFF, 2); if (retval) { - rtsx_trace(chip); return retval; } @@ -3571,7 +3353,6 @@ static int reset_mmc_only(struct rtsx_chip *chip) retval = sd_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3591,7 +3372,6 @@ static int wait_data_buf_ready(struct rtsx_chip *chip) for (i = 0; i < WAIT_DATA_READY_RTY_CNT; i++) { if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) { sd_set_err_code(chip, SD_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3601,7 +3381,6 @@ static int wait_data_buf_ready(struct rtsx_chip *chip) sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3613,7 +3392,6 @@ static int wait_data_buf_ready(struct rtsx_chip *chip) sd_set_err_code(chip, SD_TO_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3683,7 +3461,6 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip) retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -3722,7 +3499,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, chip->card_fail |= SD_CARD; chip->capacity[chip->card2lun[SD_CARD]] = 0; chip->rw_need_retry = 1; - rtsx_trace(chip); return STATUS_FAIL; } } @@ -3737,7 +3513,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { sd_set_err_code(chip, SD_IO_ERR); - rtsx_trace(chip); goto RW_FAIL; } @@ -3759,7 +3534,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, if (retval != STATUS_SUCCESS) { chip->rw_need_retry = 1; sd_set_err_code(chip, SD_STS_ERR); - rtsx_trace(chip); goto RW_FAIL; } @@ -3768,7 +3542,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, retval = rtsx_write_register(chip, RBCTL, RB_FLUSH, RB_FLUSH); if (retval != STATUS_SUCCESS) { sd_set_err_code(chip, SD_IO_ERR); - rtsx_trace(chip); goto RW_FAIL; } @@ -3860,7 +3633,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, chip->rw_need_retry = 1; sd_set_err_code(chip, SD_TO_ERR); - rtsx_trace(chip); goto RW_FAIL; } @@ -3868,7 +3640,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, if (retval != STATUS_SUCCESS) { chip->rw_need_retry = 1; sd_set_err_code(chip, SD_TO_ERR); - rtsx_trace(chip); goto RW_FAIL; } @@ -3877,7 +3648,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, NULL, 0); if (retval != STATUS_SUCCESS) { chip->rw_need_retry = 1; - rtsx_trace(chip); goto RW_FAIL; } @@ -3923,7 +3693,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, chip->rw_need_retry = 0; dev_dbg(rtsx_dev(chip), "No card exist, exit %s\n", __func__); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3933,24 +3702,20 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, SD_RSP_TYPE_R1b, NULL, 0); if (retval != STATUS_SUCCESS) { sd_set_err_code(chip, SD_STS_ERR); - rtsx_trace(chip); goto RW_FAIL; } if (stat & (SD_CRC7_ERR | SD_CRC16_ERR | SD_CRC_WRITE_ERR)) { dev_dbg(rtsx_dev(chip), "SD CRC error, tune clock!\n"); sd_set_err_code(chip, SD_CRC_ERR); - rtsx_trace(chip); goto RW_FAIL; } if (err == STATUS_TIMEDOUT) { sd_set_err_code(chip, SD_TO_ERR); - rtsx_trace(chip); goto RW_FAIL; } - rtsx_trace(chip); return err; } @@ -3966,7 +3731,6 @@ RW_FAIL: if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) { chip->rw_need_retry = 0; dev_dbg(rtsx_dev(chip), "No card exist, exit %s\n", __func__); - rtsx_trace(chip); return STATUS_FAIL; } @@ -3988,7 +3752,6 @@ RW_FAIL: } } - rtsx_trace(chip); return STATUS_FAIL; } @@ -4057,14 +3820,12 @@ RTY_SEND_CMD: if (rsp_type & SD_WAIT_BUSY_END) { retval = sd_check_data0_status(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return retval; } } else { sd_set_err_code(chip, SD_TO_ERR); } } - rtsx_trace(chip); return STATUS_FAIL; } @@ -4075,7 +3836,6 @@ RTY_SEND_CMD: if ((ptr[0] & 0xC0) != 0) { sd_set_err_code(chip, SD_STS_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -4083,7 +3843,6 @@ RTY_SEND_CMD: if (ptr[stat_idx] & SD_CRC7_ERR) { if (cmd_idx == WRITE_MULTIPLE_BLOCK) { sd_set_err_code(chip, SD_CRC_ERR); - rtsx_trace(chip); return STATUS_FAIL; } if (rty_cnt < SD_MAX_RETRY_COUNT) { @@ -4092,7 +3851,6 @@ RTY_SEND_CMD: goto RTY_SEND_CMD; } else { sd_set_err_code(chip, SD_CRC_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -4102,7 +3860,6 @@ RTY_SEND_CMD: (cmd_idx == SEND_STATUS) || (cmd_idx == STOP_TRANSMISSION)) { if ((cmd_idx != STOP_TRANSMISSION) && !special_check) { if (ptr[1] & 0x80) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -4111,18 +3868,15 @@ RTY_SEND_CMD: #else if (ptr[1] & 0x7F) { #endif - rtsx_trace(chip); return STATUS_FAIL; } if (ptr[2] & 0xF8) { - rtsx_trace(chip); return STATUS_FAIL; } if (cmd_idx == SELECT_CARD) { if (rsp_type == SD_RSP_TYPE_R2) { if ((ptr[3] & 0x1E) != 0x04) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -4162,7 +3916,6 @@ int ext_sd_get_rsp(struct rtsx_chip *chip, int len, u8 *rsp, u8 rsp_type) retval = rtsx_send_cmd(chip, SD_CARD, 100); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -4210,7 +3963,6 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!(CHK_BIT(chip->lun_mc, lun))) { SET_BIT(chip->lun_mc, lun); set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4219,7 +3971,6 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[6] != 0x61) || (srb->cmnd[7] != 0x72) || (srb->cmnd[8] != 0x64)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4234,7 +3985,6 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4303,20 +4053,17 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!sd_card->sd_pass_thru_en) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err = 0; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4333,14 +4080,12 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = get_rsp_type(srb, &rsp_type, &rsp_len); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } sd_card->last_rsp_type = rsp_type; retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4350,7 +4095,6 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_8); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4358,7 +4102,6 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_4); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -4366,7 +4109,6 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) #else retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_4); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } #endif @@ -4374,7 +4116,6 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (standby) { retval = sd_select_card(chip, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_cmd_failed; } } @@ -4385,7 +4126,6 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_cmd_failed; } } @@ -4393,14 +4133,12 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_cmd_failed; } if (standby) { retval = sd_select_card(chip, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_cmd_failed; } } @@ -4408,7 +4146,6 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) #ifdef SUPPORT_SD_LOCK retval = sd_update_lock_status(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_cmd_failed; } #endif @@ -4424,7 +4161,6 @@ sd_execute_cmd_failed: if (!(chip->card_ready & SD_CARD)) set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4440,20 +4176,17 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!sd_card->sd_pass_thru_en) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err = 0; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - rtsx_trace(chip); return TRANSPORT_FAILED; } retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4473,14 +4206,12 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = get_rsp_type(srb, &rsp_type, &rsp_len); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } sd_card->last_rsp_type = rsp_type; retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4505,7 +4236,6 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } } @@ -4513,7 +4243,6 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (standby) { retval = sd_select_card(chip, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } } @@ -4524,7 +4253,6 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } } @@ -4546,7 +4274,6 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = kmalloc(data_len, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -4556,7 +4283,6 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) read_err = true; kfree(buf); rtsx_clear_sd_error(chip); - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } @@ -4606,25 +4332,21 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval < 0) { read_err = true; rtsx_clear_sd_error(chip); - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } } else { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } retval = ext_sd_get_rsp(chip, rsp_len, sd_card->rsp, rsp_type); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } if (standby) { retval = sd_select_card(chip, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } } @@ -4634,7 +4356,6 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1b, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } } @@ -4644,19 +4365,16 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } retval = rtsx_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } retval = rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } } @@ -4673,7 +4391,6 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) break; } if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_read_cmd_failed; } @@ -4691,7 +4408,6 @@ sd_execute_read_cmd_failed: if (!(chip->card_ready & SD_CARD)) set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4712,20 +4428,17 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!sd_card->sd_pass_thru_en) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err = 0; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - rtsx_trace(chip); return TRANSPORT_FAILED; } retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4754,14 +4467,12 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = get_rsp_type(srb, &rsp_type, &rsp_len); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } sd_card->last_rsp_type = rsp_type; retval = sd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4771,7 +4482,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_8); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -4779,7 +4489,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_4); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } } @@ -4787,7 +4496,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) #else retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_4); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return TRANSPORT_FAILED; } #endif @@ -4797,7 +4505,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -4805,7 +4512,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (standby) { retval = sd_select_card(chip, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -4816,7 +4522,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -4824,7 +4529,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type, sd_card->rsp, rsp_len, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } @@ -4834,7 +4538,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf = kmalloc(data_len, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -4854,7 +4557,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, 0, 250); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } @@ -4866,7 +4568,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, 0, 250); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } else { @@ -4878,7 +4579,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, 0, 250); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -4931,14 +4631,12 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) DMA_TO_DEVICE, 10000); } else { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } if (retval < 0) { write_err = true; rtsx_clear_sd_error(chip); - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } @@ -4966,7 +4664,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (standby) { retval = sd_select_card(chip, 1); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -4976,7 +4673,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1b, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -4986,19 +4682,16 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) SD_RSP_TYPE_R1, NULL, 0, false); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } retval = rtsx_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -5015,7 +4708,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) break; } if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } @@ -5043,7 +4735,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = reset_sd(chip); if (retval != STATUS_SUCCESS) { sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON | SD_SDR_RST); - rtsx_trace(chip); goto sd_execute_write_cmd_failed; } } @@ -5057,7 +4748,6 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (lock_cmd_fail) { scsi_set_resid(srb, 0); set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); - rtsx_trace(chip); return TRANSPORT_FAILED; } #endif /* SUPPORT_SD_LOCK */ @@ -5076,7 +4766,6 @@ sd_execute_write_cmd_failed: if (!(chip->card_ready & SD_CARD)) set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -5089,14 +4778,12 @@ int sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!sd_card->sd_pass_thru_en) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err = 0; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -5104,7 +4791,6 @@ int sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (sd_card->last_rsp_type == SD_RSP_TYPE_R0) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } else if (sd_card->last_rsp_type == SD_RSP_TYPE_R2) { count = (data_len < 17) ? data_len : 17; @@ -5130,14 +4816,12 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (!sd_card->sd_pass_thru_en) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } if (sd_card->pre_cmd_err) { sd_card->pre_cmd_err = 0; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -5146,7 +4830,6 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip) (srb->cmnd[6] != 0x61) || (srb->cmnd[7] != 0x72) || (srb->cmnd[8] != 0x64)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -5163,7 +4846,6 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip) #endif set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); sd_card->pre_cmd_err = 1; - rtsx_trace(chip); return TRANSPORT_FAILED; } #ifdef SUPPORT_SD_LOCK @@ -5176,14 +4858,12 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); sd_card->pre_cmd_err = 1; - rtsx_trace(chip); return TRANSPORT_FAILED; } break; default: set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - rtsx_trace(chip); return TRANSPORT_FAILED; } @@ -5209,20 +4889,17 @@ int sd_power_off_card3v3(struct rtsx_chip *chip) retval = disable_card_clock(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, 0); if (retval) { - rtsx_trace(chip); return retval; } if (!chip->ft2_fast_mode) { retval = card_power_off(chip, SD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -5232,7 +4909,6 @@ int sd_power_off_card3v3(struct rtsx_chip *chip) if (chip->asic_code) { retval = sd_pull_ctl_disable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -5240,7 +4916,6 @@ int sd_power_off_card3v3(struct rtsx_chip *chip) FPGA_SD_PULL_CTL_BIT | 0x20, FPGA_SD_PULL_CTL_BIT); if (retval) { - rtsx_trace(chip); return retval; } } @@ -5270,7 +4945,6 @@ int release_sd_card(struct rtsx_chip *chip) retval = sd_power_off_card3v3(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } diff --git a/drivers/staging/rts5208/spi.c b/drivers/staging/rts5208/spi.c index b5646b62ec9e..4675668ad977 100644 --- a/drivers/staging/rts5208/spi.c +++ b/drivers/staging/rts5208/spi.c @@ -42,13 +42,11 @@ static int spi_init(struct rtsx_chip *chip) CS_POLARITY_LOW | DTO_MSB_FIRST | SPI_MASTER | SPI_MODE0 | SPI_AUTO); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK, SAMPLE_DELAY_HALF); if (retval) { - rtsx_trace(chip); return retval; } @@ -63,38 +61,32 @@ static int spi_set_init_para(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF, (u8)(spi->clk_div >> 8)); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF, (u8)(spi->clk_div)); if (retval) { - rtsx_trace(chip); return retval; } retval = switch_clock(chip, spi->spi_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = select_card(chip, SPI_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN, SPI_CLK_EN); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN, SPI_OUTPUT_EN); if (retval) { - rtsx_trace(chip); return retval; } @@ -102,7 +94,6 @@ static int spi_set_init_para(struct rtsx_chip *chip) retval = spi_init(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -125,7 +116,6 @@ static int sf_polling_status(struct rtsx_chip *chip, int msec) if (retval < 0) { rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_BUSY_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -154,7 +144,6 @@ static int sf_enable_write(struct rtsx_chip *chip, u8 ins) if (retval < 0) { rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -183,7 +172,6 @@ static int sf_disable_write(struct rtsx_chip *chip, u8 ins) if (retval < 0) { rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -242,7 +230,6 @@ static int sf_erase(struct rtsx_chip *chip, u8 ins, u8 addr_mode, u32 addr) if (retval < 0) { rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -261,37 +248,31 @@ static int spi_init_eeprom(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF, 0x00); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF, 0x27); if (retval) { - rtsx_trace(chip); return retval; } retval = switch_clock(chip, clk); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = select_card(chip, SPI_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN, SPI_CLK_EN); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN, SPI_OUTPUT_EN); if (retval) { - rtsx_trace(chip); return retval; } @@ -300,13 +281,11 @@ static int spi_init_eeprom(struct rtsx_chip *chip) retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF, CS_POLARITY_HIGH | SPI_EEPROM_AUTO); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK, SAMPLE_DELAY_HALF); if (retval) { - rtsx_trace(chip); return retval; } @@ -328,7 +307,6 @@ static int spi_eeprom_program_enable(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, 0, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -341,13 +319,11 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip) retval = spi_init_eeprom(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = spi_eeprom_program_enable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -364,13 +340,11 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, 0, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01); if (retval) { - rtsx_trace(chip); return retval; } @@ -383,13 +357,11 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr) retval = spi_init_eeprom(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = spi_eeprom_program_enable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -408,13 +380,11 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr) retval = rtsx_send_cmd(chip, 0, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01); if (retval) { - rtsx_trace(chip); return retval; } @@ -428,7 +398,6 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val) retval = spi_init_eeprom(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -448,14 +417,12 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val) retval = rtsx_send_cmd(chip, 0, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } wait_timeout(5); retval = rtsx_read_register(chip, SPI_DATA, &data); if (retval) { - rtsx_trace(chip); return retval; } @@ -464,7 +431,6 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val) retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01); if (retval) { - rtsx_trace(chip); return retval; } @@ -477,13 +443,11 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val) retval = spi_init_eeprom(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = spi_eeprom_program_enable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -503,13 +467,11 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val) retval = rtsx_send_cmd(chip, 0, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01); if (retval) { - rtsx_trace(chip); return retval; } @@ -562,14 +524,12 @@ int spi_read_flash_id(struct scsi_cmnd *srb, struct rtsx_chip *chip) len = ((u16)(srb->cmnd[7]) << 8) | srb->cmnd[8]; if (len > 512) { spi_set_err_code(chip, SPI_INVALID_COMMAND); - rtsx_trace(chip); return STATUS_FAIL; } retval = spi_set_init_para(chip); if (retval != STATUS_SUCCESS) { spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -612,14 +572,12 @@ int spi_read_flash_id(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval < 0) { rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } if (len) { buf = kmalloc(len, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -627,7 +585,6 @@ int spi_read_flash_id(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { spi_set_err_code(chip, SPI_READ_ERR); kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -660,13 +617,11 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = spi_set_init_para(chip); if (retval != STATUS_SUCCESS) { spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -720,7 +675,6 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -757,14 +711,12 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = spi_set_init_para(chip); if (retval != STATUS_SUCCESS) { spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } if (program_mode == BYTE_PROGRAM) { buf = kmalloc(4, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -772,7 +724,6 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_enable_write(chip, SPI_WREN); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -792,14 +743,12 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } retval = sf_polling_status(chip, 100); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -814,13 +763,11 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_enable_write(chip, SPI_WREN); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } buf = kmalloc(4, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -846,14 +793,12 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } retval = sf_polling_status(chip, 100); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -864,19 +809,16 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_disable_write(chip, SPI_WRDI); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sf_polling_status(chip, 100); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else if (program_mode == PAGE_PROGRAM) { buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL); if (!buf) { - rtsx_trace(chip); return STATUS_NOMEM; } @@ -889,7 +831,6 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_enable_write(chip, SPI_WREN); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -909,14 +850,12 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } retval = sf_polling_status(chip, 100); if (retval != STATUS_SUCCESS) { kfree(buf); - rtsx_trace(chip); return STATUS_FAIL; } @@ -927,7 +866,6 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) kfree(buf); } else { spi_set_err_code(chip, SPI_INVALID_COMMAND); - rtsx_trace(chip); return STATUS_FAIL; } @@ -950,37 +888,31 @@ int spi_erase_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = spi_set_init_para(chip); if (retval != STATUS_SUCCESS) { spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } if (erase_mode == PAGE_ERASE) { retval = sf_enable_write(chip, SPI_WREN); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sf_erase(chip, ins, 1, addr); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else if (erase_mode == CHIP_ERASE) { retval = sf_enable_write(chip, SPI_WREN); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = sf_erase(chip, ins, 0, 0); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { spi_set_err_code(chip, SPI_INVALID_COMMAND); - rtsx_trace(chip); return STATUS_FAIL; } @@ -999,13 +931,11 @@ int spi_write_flash_status(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = spi_set_init_para(chip); if (retval != STATUS_SUCCESS) { spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } retval = sf_enable_write(chip, ewsr); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1029,7 +959,6 @@ int spi_write_flash_status(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) { rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); - rtsx_trace(chip); return STATUS_FAIL; } diff --git a/drivers/staging/rts5208/trace.c b/drivers/staging/rts5208/trace.c deleted file mode 100644 index c878e75293f7..000000000000 --- a/drivers/staging/rts5208/trace.c +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -#include "rtsx.h" - -#ifdef _MSG_TRACE - -void _rtsx_trace(struct rtsx_chip *chip, const char *file, const char *func, - int line) -{ - struct trace_msg_t *msg = &chip->trace_msg[chip->msg_idx]; - - file = kbasename(file); - dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", file, func, line); - - strncpy(msg->file, file, MSG_FILE_LEN - 1); - strncpy(msg->func, func, MSG_FUNC_LEN - 1); - msg->line = (u16)line; - get_current_time(msg->timeval_buf, TIME_VAL_LEN); - msg->valid = 1; - - chip->msg_idx++; - if (chip->msg_idx >= TRACE_ITEM_CNT) - chip->msg_idx = 0; -} -#endif diff --git a/drivers/staging/rts5208/trace.h b/drivers/staging/rts5208/trace.h deleted file mode 100644 index 5b807874c1d7..000000000000 --- a/drivers/staging/rts5208/trace.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Driver for Realtek PCI-Express card reader - * Header file - * - * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * - * Author: - * Wei WANG (wei_wang@realsil.com.cn) - * Micky Ching (micky_ching@realsil.com.cn) - */ - -#ifndef __REALTEK_RTSX_TRACE_H -#define __REALTEK_RTSX_TRACE_H - -struct rtsx_chip; - -#ifdef _MSG_TRACE -void _rtsx_trace(struct rtsx_chip *chip, const char *file, const char *func, - int line); -#define rtsx_trace(chip) \ - _rtsx_trace(chip, __FILE__, __func__, __LINE__) -#else -static inline void rtsx_trace(struct rtsx_chip *chip) -{ -} -#endif - -#endif /* __REALTEK_RTSX_TRACE_H */ diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index 11ea0c658e28..667dfe1d76bc 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -61,7 +61,6 @@ static int xd_set_init_para(struct rtsx_chip *chip) retval = switch_clock(chip, xd_card->xd_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -75,13 +74,11 @@ static int xd_switch_clock(struct rtsx_chip *chip) retval = select_card(chip, XD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = switch_clock(chip, xd_card->xd_clock); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -106,7 +103,6 @@ static int xd_read_id(struct rtsx_chip *chip, u8 id_cmd, u8 *id_buf, u8 buf_len) retval = rtsx_send_cmd(chip, XD_CARD, 20); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -178,7 +174,6 @@ static int xd_read_redundant(struct rtsx_chip *chip, u32 page_addr, retval = rtsx_send_cmd(chip, XD_CARD, 500); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -199,7 +194,6 @@ static int xd_read_data_from_ppb(struct rtsx_chip *chip, int offset, int retval, i; if (!buf || (buf_len < 0)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -212,7 +206,6 @@ static int xd_read_data_from_ppb(struct rtsx_chip *chip, int offset, retval = rtsx_send_cmd(chip, 0, 250); if (retval < 0) { rtsx_clear_xd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -228,7 +221,6 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, u8 reg; if (!buf || (buf_len < 10)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -250,30 +242,25 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, retval = rtsx_send_cmd(chip, XD_CARD, 250); if (retval == -ETIMEDOUT) { rtsx_clear_xd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, XD_PAGE_STATUS, ®); if (retval) { - rtsx_trace(chip); return retval; } if (reg != XD_GPG) { rtsx_clear_xd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_read_register(chip, XD_CTL, ®); if (retval) { - rtsx_trace(chip); return retval; } if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) { retval = xd_read_data_from_ppb(chip, 0, buf, buf_len); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (reg & XD_ECC1_ERROR) { @@ -282,13 +269,11 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, retval = rtsx_read_register(chip, XD_ECC_BIT1, &ecc_bit); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_read_register(chip, XD_ECC_BYTE1, &ecc_byte); if (retval) { - rtsx_trace(chip); return retval; } @@ -307,7 +292,6 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, retval = xd_read_data_from_ppb(chip, 256, buf, buf_len); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (reg & XD_ECC2_ERROR) { @@ -316,13 +300,11 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, retval = rtsx_read_register(chip, XD_ECC_BIT2, &ecc_bit); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_read_register(chip, XD_ECC_BYTE2, &ecc_byte); if (retval) { - rtsx_trace(chip); return retval; } @@ -338,7 +320,6 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf, } } else { rtsx_clear_xd_error(chip); - rtsx_trace(chip); return STATUS_FAIL; } @@ -424,7 +405,6 @@ static int xd_pull_ctl_disable(struct rtsx_chip *chip) XD_D1_PD | XD_D0_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, @@ -433,7 +413,6 @@ static int xd_pull_ctl_disable(struct rtsx_chip *chip) XD_D5_PD | XD_D4_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF, @@ -442,7 +421,6 @@ static int xd_pull_ctl_disable(struct rtsx_chip *chip) XD_CLE_PD | XD_CD_PU); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF, @@ -451,7 +429,6 @@ static int xd_pull_ctl_disable(struct rtsx_chip *chip) XD_RE_PD | XD_ALE_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF, @@ -460,13 +437,11 @@ static int xd_pull_ctl_disable(struct rtsx_chip *chip) SD_CD_PU | SD_CMD_PD); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF, MS_D5_PD | MS_D4_PD); if (retval) { - rtsx_trace(chip); return retval; } } else if (CHECK_PID(chip, 0x5288)) { @@ -474,25 +449,21 @@ static int xd_pull_ctl_disable(struct rtsx_chip *chip) retval = rtsx_write_register(chip, CARD_PULL_CTL1, 0xFF, 0x55); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, 0x55); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF, 0x4B); if (retval) { - rtsx_trace(chip); return retval; } retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF, 0x69); if (retval) { - rtsx_trace(chip); return retval; } } @@ -509,7 +480,6 @@ static int reset_xd(struct rtsx_chip *chip) retval = select_card(chip, XD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -536,14 +506,12 @@ static int reset_xd(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, XD_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } if (!chip->ft2_fast_mode) { retval = card_power_off(chip, XD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -562,13 +530,11 @@ static int reset_xd(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, XD_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } retval = card_power_on(chip, XD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -577,7 +543,6 @@ static int reset_xd(struct rtsx_chip *chip) if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n", chip->ocp_stat); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -601,7 +566,6 @@ static int reset_xd(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, XD_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -610,7 +574,6 @@ static int reset_xd(struct rtsx_chip *chip) retval = xd_set_init_para(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -636,7 +599,6 @@ static int reset_xd(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, XD_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -651,7 +613,6 @@ static int reset_xd(struct rtsx_chip *chip) retval = xd_read_id(chip, READ_ID, id_buf, 4); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -734,7 +695,6 @@ static int reset_xd(struct rtsx_chip *chip) for (j = 0; j < 10; j++) { retval = xd_read_id(chip, READ_ID, id_buf, 4); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -752,19 +712,16 @@ static int reset_xd(struct rtsx_chip *chip) xd_card->addr_cycle = 0; xd_card->capacity = 0; - rtsx_trace(chip); return STATUS_FAIL; } retval = xd_read_id(chip, READ_xD_ID, id_buf, 4); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } dev_dbg(rtsx_dev(chip), "READ_xD_ID: 0x%x 0x%x 0x%x 0x%x\n", id_buf[0], id_buf[1], id_buf[2], id_buf[3]); if (id_buf[2] != XD_ID_CODE) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -773,7 +730,6 @@ static int reset_xd(struct rtsx_chip *chip) u32 page_addr; if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -814,7 +770,6 @@ static int reset_xd(struct rtsx_chip *chip) retval = xd_read_cis(chip, page_addr, buf, 10); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -833,7 +788,6 @@ static int reset_xd(struct rtsx_chip *chip) dev_dbg(rtsx_dev(chip), "CIS block: 0x%x\n", xd_card->cis_block); if (xd_card->cis_block == 0xFFFF) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -889,7 +843,6 @@ static int xd_init_l2p_tbl(struct rtsx_chip *chip) xd_card->zone_cnt); if (xd_card->zone_cnt < 1) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -898,7 +851,6 @@ static int xd_init_l2p_tbl(struct rtsx_chip *chip) xd_card->zone = vmalloc(size); if (!xd_card->zone) { - rtsx_trace(chip); return STATUS_ERROR; } @@ -1078,19 +1030,16 @@ int reset_xd_card(struct rtsx_chip *chip) retval = enable_card_clock(chip, XD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = reset_xd(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = xd_init_l2p_tbl(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1107,7 +1056,6 @@ static int xd_mark_bad_block(struct rtsx_chip *chip, u32 phy_blk) dev_dbg(rtsx_dev(chip), "mark block 0x%x as bad block\n", phy_blk); if (phy_blk == BLK_NOT_FOUND) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1144,7 +1092,6 @@ static int xd_mark_bad_block(struct rtsx_chip *chip, u32 phy_blk) xd_set_err_code(chip, XD_PRG_ERROR); else xd_set_err_code(chip, XD_TO_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1162,11 +1109,9 @@ static int xd_init_page(struct rtsx_chip *chip, u32 phy_blk, dev_dbg(rtsx_dev(chip), "Init block 0x%x\n", phy_blk); if (start_page > end_page) { - rtsx_trace(chip); return STATUS_FAIL; } if (phy_blk == BLK_NOT_FOUND) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1203,7 +1148,6 @@ static int xd_init_page(struct rtsx_chip *chip, u32 phy_blk, } else { xd_set_err_code(chip, XD_TO_ERROR); } - rtsx_trace(chip); return STATUS_FAIL; } @@ -1222,12 +1166,10 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, old_blk, new_blk); if (start_page > end_page) { - rtsx_trace(chip); return STATUS_FAIL; } if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND)) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1239,7 +1181,6 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, retval = rtsx_write_register(chip, CARD_DATA_SOURCE, 0x01, PINGPONG_BUFFER); if (retval) { - rtsx_trace(chip); return retval; } @@ -1247,7 +1188,6 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { rtsx_clear_xd_error(chip); xd_set_err_code(chip, XD_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1274,7 +1214,6 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { xd_set_err_code(chip, XD_NO_CARD); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1296,7 +1235,6 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, } } else { xd_set_err_code(chip, XD_TO_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1325,7 +1263,6 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, } else { xd_set_err_code(chip, XD_TO_ERROR); } - rtsx_trace(chip); return STATUS_FAIL; } @@ -1352,7 +1289,6 @@ static int xd_reset_cmd(struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, XD_CARD, 100); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1360,7 +1296,6 @@ static int xd_reset_cmd(struct rtsx_chip *chip) if (((ptr[0] & READY_FLAG) == READY_STATE) && (ptr[1] & XD_RDY)) return STATUS_SUCCESS; - rtsx_trace(chip); return STATUS_FAIL; } @@ -1372,7 +1307,6 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk) int i, retval; if (phy_blk == BLK_NOT_FOUND) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1396,13 +1330,11 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk) if (reg & PROGRAM_ERROR) { xd_mark_bad_block(chip, phy_blk); xd_set_err_code(chip, XD_PRG_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } xd_set_err_code(chip, XD_ERASE_FAIL); retval = xd_reset_cmd(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } continue; @@ -1412,7 +1344,6 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk) if (*ptr & PROGRAM_ERROR) { xd_mark_bad_block(chip, phy_blk); xd_set_err_code(chip, XD_PRG_ERROR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1421,7 +1352,6 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk) xd_mark_bad_block(chip, phy_blk); xd_set_err_code(chip, XD_ERASE_FAIL); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1454,7 +1384,6 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no) if (!zone->l2p_table) { zone->l2p_table = vmalloc(2000); if (!zone->l2p_table) { - rtsx_trace(chip); goto build_fail; } } @@ -1463,7 +1392,6 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no) if (!zone->free_table) { zone->free_table = vmalloc(XD_FREE_TABLE_CNT * 2); if (!zone->free_table) { - rtsx_trace(chip); goto build_fail; } } @@ -1629,7 +1557,6 @@ static int xd_send_cmd(struct rtsx_chip *chip, u8 cmd) retval = rtsx_send_cmd(chip, XD_CARD, 200); if (retval < 0) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1702,7 +1629,6 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk, xd_set_err_code(chip, XD_TO_ERROR); goto status_fail; } else { - rtsx_trace(chip); goto fail; } } @@ -1712,7 +1638,6 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk, fail: retval = rtsx_read_register(chip, XD_PAGE_STATUS, ®_val); if (retval) { - rtsx_trace(chip); return retval; } @@ -1721,7 +1646,6 @@ fail: retval = rtsx_read_register(chip, XD_CTL, ®_val); if (retval) { - rtsx_trace(chip); return retval; } @@ -1764,7 +1688,6 @@ fail: } status_fail: - rtsx_trace(chip); return STATUS_FAIL; } @@ -1781,7 +1704,6 @@ static int xd_finish_write(struct rtsx_chip *chip, dev_dbg(rtsx_dev(chip), "log_blk = 0x%x\n", log_blk); if (page_off > xd_card->page_off) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1795,7 +1717,6 @@ static int xd_finish_write(struct rtsx_chip *chip, retval = xd_erase_block(chip, new_blk); if (retval == STATUS_SUCCESS) xd_set_unused_block(chip, new_blk); - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -1808,7 +1729,6 @@ static int xd_finish_write(struct rtsx_chip *chip, xd_set_unused_block(chip, new_blk); } XD_CLR_BAD_NEWBLK(xd_card); - rtsx_trace(chip); return STATUS_FAIL; } @@ -1842,7 +1762,6 @@ static int xd_prepare_write(struct rtsx_chip *chip, if (page_off) { retval = xd_copy_page(chip, old_blk, new_blk, 0, page_off); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -1912,7 +1831,6 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk, xd_set_err_code(chip, XD_TO_ERROR); goto status_fail; } else { - rtsx_trace(chip); goto fail; } } @@ -1942,7 +1860,6 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk, fail: retval = rtsx_read_register(chip, XD_DAT, ®_val); if (retval) { - rtsx_trace(chip); return retval; } if (reg_val & PROGRAM_ERROR) { @@ -1951,7 +1868,6 @@ fail: } status_fail: - rtsx_trace(chip); return STATUS_FAIL; } @@ -1966,7 +1882,6 @@ int xd_delay_write(struct rtsx_chip *chip) dev_dbg(rtsx_dev(chip), "%s\n", __func__); retval = xd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -1977,7 +1892,6 @@ int xd_delay_write(struct rtsx_chip *chip) delay_write->logblock, delay_write->pageoff); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2012,14 +1926,12 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, retval = xd_switch_clock(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { chip->card_fail |= XD_CARD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2033,7 +1945,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { chip->card_fail |= XD_CARD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2053,7 +1964,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2070,7 +1980,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -2080,7 +1989,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, (new_blk == BLK_NOT_FOUND)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2091,12 +1999,10 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } #ifdef XD_DELAY_WRITE @@ -2109,12 +2015,10 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -2123,7 +2027,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (old_blk == BLK_NOT_FOUND) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2134,7 +2037,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { chip->card_fail |= XD_CARD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2151,7 +2053,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } else { @@ -2162,7 +2063,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2184,7 +2084,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, chip->card_fail |= XD_CARD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2198,7 +2097,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2207,7 +2105,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (new_blk == BLK_NOT_FOUND) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } } @@ -2227,7 +2124,6 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { chip->card_fail |= XD_CARD; set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } @@ -2237,11 +2133,9 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - rtsx_trace(chip); return STATUS_FAIL; } set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rtsx_trace(chip); return STATUS_FAIL; } #endif @@ -2288,20 +2182,17 @@ int xd_power_off_card3v3(struct rtsx_chip *chip) retval = disable_card_clock(chip, XD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } retval = rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN, 0); if (retval) { - rtsx_trace(chip); return retval; } if (!chip->ft2_fast_mode) { retval = card_power_off(chip, XD_CARD); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } @@ -2311,13 +2202,11 @@ int xd_power_off_card3v3(struct rtsx_chip *chip) if (chip->asic_code) { retval = xd_pull_ctl_disable(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } } else { retval = rtsx_write_register(chip, FPGA_PULL_CTL, 0xFF, 0xDF); if (retval) { - rtsx_trace(chip); return retval; } } @@ -2340,7 +2229,6 @@ int release_xd_card(struct rtsx_chip *chip) retval = xd_power_off_card3v3(chip); if (retval != STATUS_SUCCESS) { - rtsx_trace(chip); return STATUS_FAIL; } From 6b142341a605ceacc5bf82f69dedfc95fc607365 Mon Sep 17 00:00:00 2001 From: Chris Opperman Date: Fri, 22 Jun 2018 17:29:02 +0200 Subject: [PATCH 190/903] staging: wlan-ng: improved readability of function prism2_add_key Improve readability of prism2_add_key: a) Reduce nesting and removed goto statement by using more return statements. Signed-off-by: Chris Opperman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/cfg80211.c | 40 ++++++++++-------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 07c52e396387..d4cf09b11e33 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -148,40 +148,26 @@ static int prism2_add_key(struct wiphy *wiphy, struct net_device *dev, struct wlandevice *wlandev = dev->ml_priv; u32 did; - int err = 0; - int result = 0; - if (key_index >= NUM_WEPKEYS) return -EINVAL; - switch (params->cipher) { - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - result = prism2_domibset_uint32(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, - key_index); - if (result) - goto exit; - - /* send key to driver */ - did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1); - - result = prism2_domibset_pstr32(wlandev, did, - params->key_len, params->key); - if (result) - goto exit; - break; - - default: + if (params->cipher != WLAN_CIPHER_SUITE_WEP40 && + params->cipher != WLAN_CIPHER_SUITE_WEP104) { pr_debug("Unsupported cipher suite\n"); - result = 1; + return -EFAULT; } -exit: - if (result) - err = -EFAULT; + if (prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + key_index)) + return -EFAULT; - return err; + /* send key to driver */ + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1); + + if (prism2_domibset_pstr32(wlandev, did, params->key_len, params->key)) + return -EFAULT; + return 0; } static int prism2_get_key(struct wiphy *wiphy, struct net_device *dev, From ac5e4875e6d81f7f24a70247770c32585d773839 Mon Sep 17 00:00:00 2001 From: Jia-Ju Bai Date: Wed, 20 Jun 2018 10:58:01 +0800 Subject: [PATCH 191/903] staging: rtlwifi: Fix a possible sleep-in-atomic-context bug in _is_fw_read_cmd_down() The driver may sleep with holding a spinlock. The function call path (from bottom to top) in Linux-4.16.7 is: [FUNC] schedule drivers/staging/rtlwifi/halmac/rtl_halmac.c, 884: schedule in _is_fw_read_cmd_down drivers/staging/rtlwifi/halmac/rtl_halmac.c, 912: _is_fw_read_cmd_down in rtl_halmac_send_h2c drivers/staging/rtlwifi/halmac/rtl_halmac.c, 907: _raw_spin_lock_irqsave in rtl_halmac_send_h2c To fix this bug, schedule() is replaced with mdelay(1). This bug is found by my static analysis tool (DSAC-2) and checked by my code review. Signed-off-by: Jia-Ju Bai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/halmac/rtl_halmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/halmac/rtl_halmac.c b/drivers/staging/rtlwifi/halmac/rtl_halmac.c index ae433aa6ebbb..f0c6fc8c6aca 100644 --- a/drivers/staging/rtlwifi/halmac/rtl_halmac.c +++ b/drivers/staging/rtlwifi/halmac/rtl_halmac.c @@ -870,7 +870,7 @@ static bool _is_fw_read_cmd_down(struct rtl_priv *rtlpriv, u8 msgbox_num) if (valid == 0) read_down = true; else - schedule(); + mdelay(1); } while ((!read_down) && (retry_cnts--)); return read_down; From a37545e5e581d8b493d472f51a6011ef6f151de5 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 22 Jun 2018 20:39:31 +0100 Subject: [PATCH 192/903] staging: wlan-ng: fix coding style (indentation) in prism2mib.c Fix "CHECK: Alignment should match open parenthesis" reported by checkpatch.pl. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c index edad299ff5ad..e88baf715cec 100644 --- a/drivers/staging/wlan-ng/prism2mib.c +++ b/drivers/staging/wlan-ng/prism2mib.c @@ -87,10 +87,10 @@ struct mibrec { u16 parm2; u16 parm3; int (*func)(struct mibrec *mib, - int isget, - struct wlandevice *wlandev, - struct hfa384x *hw, - struct p80211msg_dot11req_mibset *msg, void *data); + int isget, + struct wlandevice *wlandev, + struct hfa384x *hw, + struct p80211msg_dot11req_mibset *msg, void *data); }; static int prism2mib_bytearea2pstr(struct mibrec *mib, From 9e5ffffb6853aafb6441193e27f60576a67a2e32 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 22 Jun 2018 20:39:32 +0100 Subject: [PATCH 193/903] staging: wlan-ng: replace WLAN_CTL_FRAMELEN with inline function in p80211hdr.h checkpatch reports a "CHECK" diagnostic for WLAN_CTL_FRAMELEN as the macro reuses its argument, leading to possible side-effects. Avoid this by replacing the macro with an equivalent function, named wlan_ctl_framelen (as recommended in the coding style). All references to the macro also updated accordingly. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211hdr.h | 30 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h index 26b178721414..6564810fd026 100644 --- a/drivers/staging/wlan-ng/p80211hdr.h +++ b/drivers/staging/wlan-ng/p80211hdr.h @@ -174,15 +174,25 @@ union p80211_hdr { /* Frame and header length macros */ -#define WLAN_CTL_FRAMELEN(fstype) (\ - (fstype) == WLAN_FSTYPE_BLOCKACKREQ ? 24 : \ - (fstype) == WLAN_FSTYPE_BLOCKACK ? 152 : \ - (fstype) == WLAN_FSTYPE_PSPOLL ? 20 : \ - (fstype) == WLAN_FSTYPE_RTS ? 20 : \ - (fstype) == WLAN_FSTYPE_CTS ? 14 : \ - (fstype) == WLAN_FSTYPE_ACK ? 14 : \ - (fstype) == WLAN_FSTYPE_CFEND ? 20 : \ - (fstype) == WLAN_FSTYPE_CFENDCFACK ? 20 : 4) +static inline u16 wlan_ctl_framelen(u16 fstype) +{ + switch (fstype) { + case WLAN_FSTYPE_BLOCKACKREQ: + return 24; + case WLAN_FSTYPE_BLOCKACK: + return 152; + case WLAN_FSTYPE_PSPOLL: + case WLAN_FSTYPE_RTS: + case WLAN_FSTYPE_CFEND: + case WLAN_FSTYPE_CFENDCFACK: + return 20; + case WLAN_FSTYPE_CTS: + case WLAN_FSTYPE_ACK: + return 14; + default: + return 4; + } +} #define WLAN_FCS_LEN 4 @@ -201,7 +211,7 @@ static inline u16 p80211_headerlen(u16 fctl) hdrlen += ETH_ALEN; break; case WLAN_FTYPE_CTL: - hdrlen = WLAN_CTL_FRAMELEN(WLAN_GET_FC_FSTYPE(fctl)) - + hdrlen = wlan_ctl_framelen(WLAN_GET_FC_FSTYPE(fctl)) - WLAN_FCS_LEN; break; default: From b2679009fa7def0772bff1af4b7579dc2d8ff442 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 22 Jun 2018 20:39:33 +0100 Subject: [PATCH 194/903] staging: wlan-ng: replace macro with inline function in prism2mgmt.c checkpatch gives the following message for the p80211rate_to_p2bit macro: CHECK: Macro argument reuse 'n' - possible side-effects? To fix the message, replace the macro with an equivalent inline function. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mgmt.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index d7de9e9c47a2..28e4029d46f6 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -85,10 +85,21 @@ #include "prism2mgmt.h" /* Converts 802.11 format rate specifications to prism2 */ -#define p80211rate_to_p2bit(n) ((((n) & ~BIT(7)) == 2) ? BIT(0) : \ - (((n) & ~BIT(7)) == 4) ? BIT(1) : \ - (((n) & ~BIT(7)) == 11) ? BIT(2) : \ - (((n) & ~BIT(7)) == 22) ? BIT(3) : 0) +static inline u16 p80211rate_to_p2bit(u32 rate) +{ + switch (rate & ~BIT(7)) { + case 2: + return BIT(0); + case 4: + return BIT(1); + case 11: + return BIT(2); + case 22: + return BIT(3); + default: + return 0; + } +} /*---------------------------------------------------------------- * prism2mgmt_scan From 39b2ef70d6d37db595bb28b372efcf4cd03417b8 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 22 Jun 2018 20:39:34 +0100 Subject: [PATCH 195/903] staging: wlan-ng: add parentheses to macro argument usage in prism2mgmt.c Fix two "CHECK: Macro argument 'N' may be better as '(N)' to avoid precedence issue" messages, reported by checkpatch, by adding parentheses around the offending macro argument references. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index 28e4029d46f6..ebfe69b138c7 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -439,7 +439,7 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) #define REQBASICRATE(N) \ do { \ - if ((count >= N) && DOT11_RATE5_ISBASIC_GET( \ + if ((count >= (N)) && DOT11_RATE5_ISBASIC_GET( \ item->supprates[(N) - 1])) { \ req->basicrate ## N .data = item->supprates[(N) - 1]; \ req->basicrate ## N .status = \ @@ -458,7 +458,7 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) #define REQSUPPRATE(N) \ do { \ - if (count >= N) { \ + if (count >= (N)) { \ req->supprate ## N .data = item->supprates[(N) - 1]; \ req->supprate ## N .status = \ P80211ENUM_msgitem_status_data_ok; \ From b244f917acb7e1f492c40f6f4cf7be860a5065a5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 26 Jun 2018 17:38:56 +0200 Subject: [PATCH 196/903] staging: rtl8188eu: remove blank lines Remove unrequired blank lines after open and before close braces. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 1 - drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 -- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 2 -- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 1 - drivers/staging/rtl8188eu/core/rtw_recv.c | 4 ---- drivers/staging/rtl8188eu/core/rtw_security.c | 2 -- drivers/staging/rtl8188eu/core/rtw_xmit.c | 3 --- 7 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 17cd28b893a4..be1e8bf41e00 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -306,7 +306,6 @@ void expire_timeout_chk(struct adapter *padapter) spin_lock_bh(&pstapriv->auth_list_lock); } } - } spin_unlock_bh(&pstapriv->auth_list_lock); diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 5b8414c568e5..3ac3dd796ec9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -301,7 +301,6 @@ static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf) { - if (rtw_IOL_applied(Adapter)) { rtw_hal_power_on(Adapter); iol_mode_enable(Adapter, 1); @@ -476,7 +475,6 @@ int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data) efuse_addr = efuse_addr + (word_cnts*2)+1; ReadState = PG_STATE_HEADER; } - } if ((data[0] == 0xff) && (data[1] == 0xff) && (data[2] == 0xff) && (data[3] == 0xff) && diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 785f78fe51c5..e47927b9c3b8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -178,7 +178,6 @@ u8 *rtw_get_ie(u8 *pbuf, int index, uint *len, int limit) void rtw_set_supported_rate(u8 *SupportedRates, uint mode) { - memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); switch (mode) { @@ -326,7 +325,6 @@ check_next_ie: unsigned char *rtw_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len, int limit) { - return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit); } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index c8c09ae9f5a4..f05658c9239e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -5448,7 +5448,6 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) if (peventbuf) { event_callback = wlanevents[evt_code].event_callback; event_callback(padapter, (u8 *)peventbuf); - } _abort_event_: diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 965fe9afda7c..79567cf470de 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -36,13 +36,11 @@ static void rtw_signal_stat_timer_hdl(struct timer_list *t); void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { - memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv)); spin_lock_init(&psta_recvpriv->lock); _rtw_init_queue(&psta_recvpriv->defrag_q); - } int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) @@ -98,7 +96,6 @@ void _rtw_free_recv_priv(struct recv_priv *precvpriv) vfree(precvpriv->pallocated_frame_buf); rtw_hal_free_recv_priv(padapter); - } struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) @@ -193,7 +190,6 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre } spin_unlock(&pframequeue->lock); - } u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 8e204dc4ab1b..5b8d7288a4e7 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -185,7 +185,6 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) } } } - } int rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) @@ -1030,7 +1029,6 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int mic_header2[14] = mpdu[30] & 0x0f; mic_header2[15] = mpdu[31] & 0x00; } - } /************************************************/ diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 2f85f58b7934..d16a7fa32a25 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -33,7 +33,6 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) _init_txservq(&psta_xmitpriv->vo_q); INIT_LIST_HEAD(&psta_xmitpriv->legacy_dz); INIT_LIST_HEAD(&psta_xmitpriv->apsd); - } s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) @@ -1146,7 +1145,6 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) } break; } - } void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz) @@ -1385,7 +1383,6 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram rtw_free_xmitframe(pxmitpriv, pxmitframe); } spin_unlock_bh(&pframequeue->lock); - } s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) From 6d2b0f7b9c1e8028f9a3efb99f539cb2f6d3d669 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sat, 23 Jun 2018 10:27:58 -0700 Subject: [PATCH 197/903] staging: Convert random_ether_addr to eth_random_addr random_ether_addr is a #define for eth_random_addr which is generally preferred in kernel code by ~3:1 Convert the uses of random_ether_addr to enable removing the #define Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 21874e78d8a1..9d9a9e102bb8 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2382,7 +2382,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) if (ieee->state == IEEE80211_NOLINK) { printk("creating new IBSS cell\n"); if(!ieee->wap_set) - random_ether_addr(ieee->current_network.bssid); + eth_random_addr(ieee->current_network.bssid); if(ieee->modulation & IEEE80211_CCK_MODULATION){ From 05ccc7061a3b2f11ac0a6c4d9528b4ca62acc139 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 27 Jun 2018 19:36:46 +0200 Subject: [PATCH 198/903] staging: rtl8723bs: fix comparsion to NULL - coding style Fix comparsion to NULL issues found by checkpatch. Use !x instead of x == NULL. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 0822e440204e..e55895632921 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -747,7 +747,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) u8 match = false; u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if (ie_ptr == NULL) + if (!ie_ptr) return match; eid = ie_ptr[0]; @@ -1163,7 +1163,7 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) const unsigned char *addr; int len; - if (mac_addr == NULL) + if (!mac_addr) return; if (rtw_initmac) { /* Users specify the mac address */ From 375a2bd2758395ecf8aed01ea264953afede6a4f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 27 Jun 2018 19:36:47 +0200 Subject: [PATCH 199/903] staging: rtl8723bs: refactor rtw_macaddr_cfg() Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of testing each byte of the mac[] array for 0xff and 0x00 shortens the code and improves readability. If np == NULL, of_get_property() returns NULL, hence the "np" check is not needed. Instead of a fixed default mac address use a random one to reduce the likelihood of mac address collision. Thanks to Joe Perches and Dan Carpenter. Suggested-by: Joe Perches Suggested-by: Dan Carpenter Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_ieee80211.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index e55895632921..7aa00d1391f7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1177,24 +1177,13 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) memcpy(mac, mac_addr, ETH_ALEN); } - if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) && - (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || - ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) && - (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) { - if (np && - (addr = of_get_property(np, "local-mac-address", &len)) && + if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) { + if ((addr = of_get_property(np, "local-mac-address", &len)) && len == ETH_ALEN) { memcpy(mac_addr, addr, ETH_ALEN); } else { - mac[0] = 0x00; - mac[1] = 0xe0; - mac[2] = 0x4c; - mac[3] = 0x87; - mac[4] = 0x00; - mac[5] = 0x00; - /* use default mac addresss */ - memcpy(mac_addr, mac, ETH_ALEN); - DBG_871X("MAC Address from efuse error, assign default one !!!\n"); + eth_random_addr(mac_addr); + DBG_871X("MAC Address from efuse error, assign random one !!!\n"); } } From 9579ba6e5d4f2e823a16f0f99ba755cb345c3605 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 27 Jun 2018 19:36:48 +0200 Subject: [PATCH 200/903] staging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg() Use ether_addr_copy() instead of memcpy() to copy the mac address. Suggested-by: Andy Shevchenko Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 7aa00d1391f7..8af4a89e632f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1172,15 +1172,15 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) { mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]); } - memcpy(mac_addr, mac, ETH_ALEN); + ether_addr_copy(mac_addr, mac); } else{ /* Use the mac address stored in the Efuse */ - memcpy(mac, mac_addr, ETH_ALEN); + ether_addr_copy(mac, mac_addr); } if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) { if ((addr = of_get_property(np, "local-mac-address", &len)) && len == ETH_ALEN) { - memcpy(mac_addr, addr, ETH_ALEN); + ether_addr_copy(mac_addr, addr); } else { eth_random_addr(mac_addr); DBG_871X("MAC Address from efuse error, assign random one !!!\n"); From a50d971c08ea72506d5f986fb7df9a5909c3997c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 27 Jun 2018 19:36:49 +0200 Subject: [PATCH 201/903] staging: rtl8723bs: use mac_pton() in rtw_macaddr_cfg() Use the mac_pton() helper to convert the mac address string. The functions key_char2num() and key_2char2num() are not used anywhere else and can be removed. This also has the benefit of validating the input since mac_pton() returns false if the string is not valid. Signed-off-by: Michael Straube Reviewed-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_ieee80211.c | 30 +++---------------- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 3 -- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 8af4a89e632f..8e0025e1ff14 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1137,25 +1137,6 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, } -static u8 key_char2num(u8 ch); -static u8 key_char2num(u8 ch) -{ - if ((ch >= '0') && (ch <= '9')) - return ch - '0'; - else if ((ch >= 'a') && (ch <= 'f')) - return ch - 'a' + 10; - else if ((ch >= 'A') && (ch <= 'F')) - return ch - 'A' + 10; - else - return 0xff; -} - -u8 key_2char2num(u8 hch, u8 lch); -u8 key_2char2num(u8 hch, u8 lch) -{ - return ((key_char2num(hch) << 4) | key_char2num(lch)); -} - void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) { u8 mac[ETH_ALEN]; @@ -1166,14 +1147,11 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) if (!mac_addr) return; - if (rtw_initmac) { /* Users specify the mac address */ - int jj, kk; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) { - mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]); - } + if (rtw_initmac && mac_pton(rtw_initmac, mac)) { + /* Users specify the mac address */ ether_addr_copy(mac_addr, mac); - } else{ /* Use the mac address stored in the Efuse */ + } else { + /* Use the mac address stored in the Efuse */ ether_addr_copy(mac, mac_addr); } diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 5f029198bcaf..7dd9521fedfb 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -32,9 +32,6 @@ #define WEXT_CSCAN_HOME_DWELL_SECTION 'H' #define WEXT_CSCAN_TYPE_SECTION 'T' - -extern u8 key_2char2num(u8 hch, u8 lch); - static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; From a98a5c27b54e01dd9c42e2b0addb543f0dc494cd Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 27 Jun 2018 20:47:32 +0200 Subject: [PATCH 202/903] staging: rtl8188eu: remove whitespace - coding style Remove unrequired whitespace in some declarations, fix an indentation and remove unrequired blank lines. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 9f9a595191b6..deadf26ea2aa 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -28,9 +28,9 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) { union iwreq_data wrqu; - struct iw_michaelmicfailure ev; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; + struct iw_michaelmicfailure ev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; u32 cur_time = 0; if (psecuritypriv->last_mic_err_time == 0) { @@ -69,7 +69,6 @@ int rtw_recv_indicatepkt(struct adapter *padapter, struct sk_buff *skb; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - precvpriv = &(padapter->recvpriv); pfree_recv_queue = &(precvpriv->free_recv_queue); @@ -129,7 +128,6 @@ _recv_indicatepkt_end: RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt :after netif_rx!!!!\n")); - return _SUCCESS; _recv_indicatepkt_drop: @@ -137,12 +135,11 @@ _recv_indicatepkt_drop: /* enqueue back to free_recv_queue */ rtw_free_recvframe(precv_frame, pfree_recv_queue); - return _FAIL; + return _FAIL; } void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) { - timer_setup(&preorder_ctrl->reordering_ctrl_timer, rtw_reordering_ctrl_timeout_handler, 0); } From c6988eb0e7d2ae1c892874d92ee9a7e8a380896d Mon Sep 17 00:00:00 2001 From: Karim Eshapa Date: Mon, 25 Jun 2018 21:11:23 +0200 Subject: [PATCH 203/903] staging:iio:impedance-analyzer:ad5933: Macro replacement Cleanups. Doing some macro replacement to start an array of structures so it can be reused by manipulating it with different values. Signed-off-by: Karim Eshapa Signed-off-by: Jonathan Cameron --- .../staging/iio/impedance-analyzer/ad5933.c | 57 +++++++------------ 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 3bcf49466361..14df89510396 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -116,45 +116,26 @@ static struct ad5933_platform_data ad5933_default_pdata = { .vref_mv = 3300, }; +#define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \ + _scan_index, _realbits) { \ + .type = (_type), \ + .extend_name = (_extend_name), \ + .info_mask_separate = (_info_mask_separate), \ + .address = (_address), \ + .scan_index = (_scan_index), \ + .scan_type = { \ + .sign = 's', \ + .realbits = (_realbits), \ + .storagebits = 16, \ + }, \ +} + static const struct iio_chan_spec ad5933_channels[] = { - { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SCALE), - .address = AD5933_REG_TEMP_DATA, - .scan_index = -1, - .scan_type = { - .sign = 's', - .realbits = 14, - .storagebits = 16, - }, - }, { /* Ring Channels */ - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .extend_name = "real", - .address = AD5933_REG_REAL_DATA, - .scan_index = 0, - .scan_type = { - .sign = 's', - .realbits = 16, - .storagebits = 16, - }, - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .extend_name = "imag", - .address = AD5933_REG_IMAG_DATA, - .scan_index = 1, - .scan_type = { - .sign = 's', - .realbits = 16, - .storagebits = 16, - }, - }, + AD5933_CHANNEL(IIO_TEMP, NULL, BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), AD5933_REG_TEMP_DATA, -1, 14), + /* Ring Channels */ + AD5933_CHANNEL(IIO_VOLTAGE, "real", 0, AD5933_REG_REAL_DATA, 0, 16), + AD5933_CHANNEL(IIO_VOLTAGE, "imag", 0, AD5933_REG_IMAG_DATA, 1, 16), }; static int ad5933_i2c_write(struct i2c_client *client, u8 reg, u8 len, u8 *data) From 4b5de1fa97b9932db0e989afe7dba3029fbd4545 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Tue, 26 Jun 2018 00:22:40 +0900 Subject: [PATCH 204/903] iio: accel: adxl345: add link to datasheet Add a link to the ADXL345 datasheet Cc: Eva Rachel Retuya Cc: Andy Shevchenko Cc: Jonathan Cameron Signed-off-by: Akinobu Mita Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl345_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 7251d0e63d74..8e0d56b89201 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -6,6 +6,8 @@ * This file is subject to the terms and conditions of version 2 of * the GNU General Public License. See the file COPYING in the main * directory of this archive for more details. + * + * Datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf */ #include From 9048f1f18a70a01eaa3c8e7166fdb2538929d780 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Tue, 26 Jun 2018 00:22:41 +0900 Subject: [PATCH 205/903] iio: accel: adxl345: convert address field usage in iio_chan_spec Currently the address field in iio_chan_spec is filled with an accel data register address for the corresponding axis. In preparation for adding calibration offset support, this sets the address field to the index of accel data registers instead of the actual register address. This change makes it easier to access both accel registers and calibration offset registers with fewer lines of code as these are located in X-axis, Y-axis, Z-axis order. Cc: Eva Rachel Retuya Cc: Andy Shevchenko Cc: Jonathan Cameron Signed-off-by: Akinobu Mita Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl345_core.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 8e0d56b89201..7a25840d806f 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -23,6 +23,8 @@ #define ADXL345_REG_DATAX0 0x32 #define ADXL345_REG_DATAY0 0x34 #define ADXL345_REG_DATAZ0 0x36 +#define ADXL345_REG_DATA_AXIS(index) \ + (ADXL345_REG_DATAX0 + (index) * sizeof(__le16)) #define ADXL345_POWER_CTL_MEASURE BIT(3) #define ADXL345_POWER_CTL_STANDBY 0x00 @@ -49,19 +51,19 @@ struct adxl345_data { u8 data_range; }; -#define ADXL345_CHANNEL(reg, axis) { \ +#define ADXL345_CHANNEL(index, axis) { \ .type = IIO_ACCEL, \ .modified = 1, \ .channel2 = IIO_MOD_##axis, \ - .address = reg, \ + .address = index, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ } static const struct iio_chan_spec adxl345_channels[] = { - ADXL345_CHANNEL(ADXL345_REG_DATAX0, X), - ADXL345_CHANNEL(ADXL345_REG_DATAY0, Y), - ADXL345_CHANNEL(ADXL345_REG_DATAZ0, Z), + ADXL345_CHANNEL(0, X), + ADXL345_CHANNEL(1, Y), + ADXL345_CHANNEL(2, Z), }; static int adxl345_read_raw(struct iio_dev *indio_dev, @@ -69,7 +71,7 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct adxl345_data *data = iio_priv(indio_dev); - __le16 regval; + __le16 accel; int ret; switch (mask) { @@ -79,12 +81,13 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, * ADXL345_REG_DATA(X0/Y0/Z0) contain the least significant byte * and ADXL345_REG_DATA(X0/Y0/Z0) + 1 the most significant byte */ - ret = regmap_bulk_read(data->regmap, chan->address, ®val, - sizeof(regval)); + ret = regmap_bulk_read(data->regmap, + ADXL345_REG_DATA_AXIS(chan->address), + &accel, sizeof(accel)); if (ret < 0) return ret; - *val = sign_extend32(le16_to_cpu(regval), 12); + *val = sign_extend32(le16_to_cpu(accel), 12); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; From 732238e22e4c5497bd76d02adcf5c4fcba6dcb67 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Tue, 26 Jun 2018 00:22:42 +0900 Subject: [PATCH 206/903] iio: accel: adxl345: add calibration offset support The ADXL345 provides the offset adjustment registers for each axis. This adds the iio channel information for the calibraion offsets with that feature. Cc: Eva Rachel Retuya Cc: Andy Shevchenko Cc: Jonathan Cameron Signed-off-by: Akinobu Mita Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl345_core.c | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 7a25840d806f..7b29ae8375e9 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -18,6 +18,10 @@ #include "adxl345.h" #define ADXL345_REG_DEVID 0x00 +#define ADXL345_REG_OFSX 0x1e +#define ADXL345_REG_OFSY 0x1f +#define ADXL345_REG_OFSZ 0x20 +#define ADXL345_REG_OFS_AXIS(index) (ADXL345_REG_OFSX + (index)) #define ADXL345_REG_POWER_CTL 0x2D #define ADXL345_REG_DATA_FORMAT 0x31 #define ADXL345_REG_DATAX0 0x32 @@ -56,7 +60,8 @@ struct adxl345_data { .modified = 1, \ .channel2 = IIO_MOD_##axis, \ .address = index, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_CALIBBIAS), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ } @@ -72,6 +77,7 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, { struct adxl345_data *data = iio_priv(indio_dev); __le16 accel; + unsigned int regval; int ret; switch (mask) { @@ -94,6 +100,38 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, *val2 = adxl345_uscale; return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_CALIBBIAS: + ret = regmap_read(data->regmap, + ADXL345_REG_OFS_AXIS(chan->address), ®val); + if (ret < 0) + return ret; + /* + * 8-bit resolution at +/- 2g, that is 4x accel data scale + * factor + */ + *val = sign_extend32(regval, 7) * 4; + + return IIO_VAL_INT; + } + + return -EINVAL; +} + +static int adxl345_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct adxl345_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_CALIBBIAS: + /* + * 8-bit resolution at +/- 2g, that is 4x accel data scale + * factor + */ + return regmap_write(data->regmap, + ADXL345_REG_OFS_AXIS(chan->address), + val / 4); } return -EINVAL; @@ -101,6 +139,7 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, static const struct iio_info adxl345_info = { .read_raw = adxl345_read_raw, + .write_raw = adxl345_write_raw, }; int adxl345_core_probe(struct device *dev, struct regmap *regmap, From d93de07a12e8b00e99ff9d7522c326ba6a5747c0 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Thu, 21 Jun 2018 11:14:04 +0800 Subject: [PATCH 207/903] dt-bindings: iio: Add Spreadtrum SC27XX PMICs ADC controller documentation This patch adds the binding documentation for Spreadtrum SC27XX series PMICs ADC controller device. Signed-off-by: Baolin Wang Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/sprd,sc27xx-adc.txt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/sprd,sc27xx-adc.txt diff --git a/Documentation/devicetree/bindings/iio/adc/sprd,sc27xx-adc.txt b/Documentation/devicetree/bindings/iio/adc/sprd,sc27xx-adc.txt new file mode 100644 index 000000000000..8aad960de50b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/sprd,sc27xx-adc.txt @@ -0,0 +1,36 @@ +Spreadtrum SC27XX series PMICs ADC binding + +Required properties: +- compatible: Should be one of the following. + "sprd,sc2720-adc" + "sprd,sc2721-adc" + "sprd,sc2723-adc" + "sprd,sc2730-adc" + "sprd,sc2731-adc" +- reg: The address offset of ADC controller. +- interrupt-parent: The interrupt controller. +- interrupts: The interrupt number for the ADC device. +- #io-channel-cells: Number of cells in an IIO specifier. +- hwlocks: Reference to a phandle of a hwlock provider node. + +Example: + + sc2731_pmic: pmic@0 { + compatible = "sprd,sc2731"; + reg = <0>; + spi-max-frequency = <26000000>; + interrupts = ; + interrupt-controller; + #interrupt-cells = <2>; + #address-cells = <1>; + #size-cells = <0>; + + pmic_adc: adc@480 { + compatible = "sprd,sc2731-adc"; + reg = <0x480>; + interrupt-parent = <&sc2731_pmic>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + #io-channel-cells = <1>; + hwlocks = <&hwlock 4>; + }; + }; From 5df362a6cf49ca8d2e69a2f68e605310e3c576cb Mon Sep 17 00:00:00 2001 From: Freeman Liu Date: Thu, 21 Jun 2018 11:14:05 +0800 Subject: [PATCH 208/903] iio: adc: Add Spreadtrum SC27XX PMICs ADC support The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, which is used to sample voltages with 12 bits conversion. [Baolin Wang did lots of improvements] Signed-off-by: Freeman Liu Signed-off-by: Baolin Wang Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/sc27xx_adc.c | 522 +++++++++++++++++++++++++++++++++++ 3 files changed, 533 insertions(+) create mode 100644 drivers/iio/adc/sc27xx_adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 084638e4ddf2..4a754921fb6f 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -620,6 +620,16 @@ config ROCKCHIP_SARADC To compile this driver as a module, choose M here: the module will be called rockchip_saradc. +config SC27XX_ADC + tristate "Spreadtrum SC27xx series PMICs ADC" + depends on MFD_SC27XX_PMIC || COMPILE_TEST + help + Say yes here to build support for the integrated ADC inside the + Spreadtrum SC27xx series PMICs. + + This driver can also be built as a module. If so, the module + will be called sc27xx_adc. + config SPEAR_ADC tristate "ST SPEAr ADC" depends on PLAT_SPEAR || COMPILE_TEST diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 28a9423997f3..03db7b578f9c 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o obj-$(CONFIG_SPEAR_ADC) += spear_adc.o obj-$(CONFIG_STX104) += stx104.o obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c new file mode 100644 index 000000000000..2b60efea0c39 --- /dev/null +++ b/drivers/iio/adc/sc27xx_adc.c @@ -0,0 +1,522 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Spreadtrum Communications Inc. + +#include +#include +#include +#include +#include +#include +#include +#include + +/* PMIC global registers definition */ +#define SC27XX_MODULE_EN 0xc08 +#define SC27XX_MODULE_ADC_EN BIT(5) +#define SC27XX_ARM_CLK_EN 0xc10 +#define SC27XX_CLK_ADC_EN BIT(5) +#define SC27XX_CLK_ADC_CLK_EN BIT(6) + +/* ADC controller registers definition */ +#define SC27XX_ADC_CTL 0x0 +#define SC27XX_ADC_CH_CFG 0x4 +#define SC27XX_ADC_DATA 0x4c +#define SC27XX_ADC_INT_EN 0x50 +#define SC27XX_ADC_INT_CLR 0x54 +#define SC27XX_ADC_INT_STS 0x58 +#define SC27XX_ADC_INT_RAW 0x5c + +/* Bits and mask definition for SC27XX_ADC_CTL register */ +#define SC27XX_ADC_EN BIT(0) +#define SC27XX_ADC_CHN_RUN BIT(1) +#define SC27XX_ADC_12BIT_MODE BIT(2) +#define SC27XX_ADC_RUN_NUM_MASK GENMASK(7, 4) +#define SC27XX_ADC_RUN_NUM_SHIFT 4 + +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) +#define SC27XX_ADC_SCALE_MASK GENMASK(10, 8) +#define SC27XX_ADC_SCALE_SHIFT 8 + +/* Bits definitions for SC27XX_ADC_INT_EN registers */ +#define SC27XX_ADC_IRQ_EN BIT(0) + +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ +#define SC27XX_ADC_IRQ_CLR BIT(0) + +/* Mask definition for SC27XX_ADC_DATA register */ +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) + +/* Timeout (ms) for the trylock of hardware spinlocks */ +#define SC27XX_ADC_HWLOCK_TIMEOUT 5000 + +/* Maximum ADC channel number */ +#define SC27XX_ADC_CHANNEL_MAX 32 + +/* ADC voltage ratio definition */ +#define SC27XX_VOLT_RATIO(n, d) \ + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) +#define SC27XX_RATIO_NUMERATOR_OFFSET 16 +#define SC27XX_RATIO_DENOMINATOR_MASK GENMASK(15, 0) + +struct sc27xx_adc_data { + struct device *dev; + struct regmap *regmap; + /* + * One hardware spinlock to synchronize between the multiple + * subsystems which will access the unique ADC controller. + */ + struct hwspinlock *hwlock; + struct completion completion; + int channel_scale[SC27XX_ADC_CHANNEL_MAX]; + u32 base; + int value; + int irq; +}; + +struct sc27xx_adc_linear_graph { + int volt0; + int adc0; + int volt1; + int adc1; +}; + +/* + * According to the datasheet, we can convert one ADC value to one voltage value + * through 2 points in the linear graph. If the voltage is less than 1.2v, we + * should use the small-scale graph, and if more than 1.2v, we should use the + * big-scale graph. + */ +static const struct sc27xx_adc_linear_graph big_scale_graph = { + 4200, 3310, + 3600, 2832, +}; + +static const struct sc27xx_adc_linear_graph small_scale_graph = { + 1000, 3413, + 100, 341, +}; + +static int sc27xx_adc_get_ratio(int channel, int scale) +{ + switch (channel) { + case 1: + case 2: + case 3: + case 4: + return scale ? SC27XX_VOLT_RATIO(400, 1025) : + SC27XX_VOLT_RATIO(1, 1); + case 5: + return SC27XX_VOLT_RATIO(7, 29); + case 6: + return SC27XX_VOLT_RATIO(375, 9000); + case 7: + case 8: + return scale ? SC27XX_VOLT_RATIO(100, 125) : + SC27XX_VOLT_RATIO(1, 1); + case 19: + return SC27XX_VOLT_RATIO(1, 3); + default: + return SC27XX_VOLT_RATIO(1, 1); + } + return SC27XX_VOLT_RATIO(1, 1); +} + +static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, + int scale, int *val) +{ + int ret; + u32 tmp; + + reinit_completion(&data->completion); + + ret = hwspin_lock_timeout_raw(data->hwlock, SC27XX_ADC_HWLOCK_TIMEOUT); + if (ret) { + dev_err(data->dev, "timeout to get the hwspinlock\n"); + return ret; + } + + ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, + SC27XX_ADC_EN, SC27XX_ADC_EN); + if (ret) + goto unlock_adc; + + /* Configure the channel id and scale */ + tmp = (scale << SC27XX_ADC_SCALE_SHIFT) & SC27XX_ADC_SCALE_MASK; + tmp |= channel & SC27XX_ADC_CHN_ID_MASK; + ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CH_CFG, + SC27XX_ADC_CHN_ID_MASK | SC27XX_ADC_SCALE_MASK, + tmp); + if (ret) + goto disable_adc; + + /* Select 12bit conversion mode, and only sample 1 time */ + tmp = SC27XX_ADC_12BIT_MODE; + tmp |= (0 << SC27XX_ADC_RUN_NUM_SHIFT) & SC27XX_ADC_RUN_NUM_MASK; + ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, + SC27XX_ADC_RUN_NUM_MASK | SC27XX_ADC_12BIT_MODE, + tmp); + if (ret) + goto disable_adc; + + ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, + SC27XX_ADC_CHN_RUN, SC27XX_ADC_CHN_RUN); + if (ret) + goto disable_adc; + + wait_for_completion(&data->completion); + +disable_adc: + regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, + SC27XX_ADC_EN, 0); +unlock_adc: + hwspin_unlock_raw(data->hwlock); + + if (!ret) + *val = data->value; + + return ret; +} + +static irqreturn_t sc27xx_adc_isr(int irq, void *dev_id) +{ + struct sc27xx_adc_data *data = dev_id; + int ret; + + ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_INT_CLR, + SC27XX_ADC_IRQ_CLR, SC27XX_ADC_IRQ_CLR); + if (ret) + return IRQ_RETVAL(ret); + + ret = regmap_read(data->regmap, data->base + SC27XX_ADC_DATA, + &data->value); + if (ret) + return IRQ_RETVAL(ret); + + data->value &= SC27XX_ADC_DATA_MASK; + complete(&data->completion); + + return IRQ_HANDLED; +} + +static void sc27xx_adc_volt_ratio(struct sc27xx_adc_data *data, + int channel, int scale, + u32 *div_numerator, u32 *div_denominator) +{ + u32 ratio = sc27xx_adc_get_ratio(channel, scale); + + *div_numerator = ratio >> SC27XX_RATIO_NUMERATOR_OFFSET; + *div_denominator = ratio & SC27XX_RATIO_DENOMINATOR_MASK; +} + +static int sc27xx_adc_to_volt(const struct sc27xx_adc_linear_graph *graph, + int raw_adc) +{ + int tmp; + + tmp = (graph->volt0 - graph->volt1) * (raw_adc - graph->adc1); + tmp /= (graph->adc0 - graph->adc1); + tmp += graph->volt1; + + return tmp < 0 ? 0 : tmp; +} + +static int sc27xx_adc_convert_volt(struct sc27xx_adc_data *data, int channel, + int scale, int raw_adc) +{ + u32 numerator, denominator; + u32 volt; + + /* + * Convert ADC values to voltage values according to the linear graph, + * and channel 5 and channel 1 has been calibrated, so we can just + * return the voltage values calculated by the linear graph. But other + * channels need be calculated to the real voltage values with the + * voltage ratio. + */ + switch (channel) { + case 5: + return sc27xx_adc_to_volt(&big_scale_graph, raw_adc); + + case 1: + return sc27xx_adc_to_volt(&small_scale_graph, raw_adc); + + default: + volt = sc27xx_adc_to_volt(&small_scale_graph, raw_adc); + break; + } + + sc27xx_adc_volt_ratio(data, channel, scale, &numerator, &denominator); + + return (volt * denominator + numerator / 2) / numerator; +} + +static int sc27xx_adc_read_processed(struct sc27xx_adc_data *data, + int channel, int scale, int *val) +{ + int ret, raw_adc; + + ret = sc27xx_adc_read(data, channel, scale, &raw_adc); + if (ret) + return ret; + + *val = sc27xx_adc_convert_volt(data, channel, scale, raw_adc); + return 0; +} + +static int sc27xx_adc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct sc27xx_adc_data *data = iio_priv(indio_dev); + int scale = data->channel_scale[chan->channel]; + int ret, tmp; + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + mutex_lock(&indio_dev->mlock); + ret = sc27xx_adc_read_processed(data, chan->channel, scale, + &tmp); + mutex_unlock(&indio_dev->mlock); + + if (ret) + return ret; + + *val = tmp; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + *val = scale; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + +static int sc27xx_adc_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct sc27xx_adc_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + data->channel_scale[chan->channel] = val; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + +static const struct iio_info sc27xx_info = { + .read_raw = &sc27xx_adc_read_raw, + .write_raw = &sc27xx_adc_write_raw, +}; + +#define SC27XX_ADC_CHANNEL(index) { \ + .type = IIO_VOLTAGE, \ + .channel = index, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .datasheet_name = "CH##index", \ + .indexed = 1, \ +} + +static const struct iio_chan_spec sc27xx_channels[] = { + SC27XX_ADC_CHANNEL(0), + SC27XX_ADC_CHANNEL(1), + SC27XX_ADC_CHANNEL(2), + SC27XX_ADC_CHANNEL(3), + SC27XX_ADC_CHANNEL(4), + SC27XX_ADC_CHANNEL(5), + SC27XX_ADC_CHANNEL(6), + SC27XX_ADC_CHANNEL(7), + SC27XX_ADC_CHANNEL(8), + SC27XX_ADC_CHANNEL(9), + SC27XX_ADC_CHANNEL(10), + SC27XX_ADC_CHANNEL(11), + SC27XX_ADC_CHANNEL(12), + SC27XX_ADC_CHANNEL(13), + SC27XX_ADC_CHANNEL(14), + SC27XX_ADC_CHANNEL(15), + SC27XX_ADC_CHANNEL(16), + SC27XX_ADC_CHANNEL(17), + SC27XX_ADC_CHANNEL(18), + SC27XX_ADC_CHANNEL(19), + SC27XX_ADC_CHANNEL(20), + SC27XX_ADC_CHANNEL(21), + SC27XX_ADC_CHANNEL(22), + SC27XX_ADC_CHANNEL(23), + SC27XX_ADC_CHANNEL(24), + SC27XX_ADC_CHANNEL(25), + SC27XX_ADC_CHANNEL(26), + SC27XX_ADC_CHANNEL(27), + SC27XX_ADC_CHANNEL(28), + SC27XX_ADC_CHANNEL(29), + SC27XX_ADC_CHANNEL(30), + SC27XX_ADC_CHANNEL(31), +}; + +static int sc27xx_adc_enable(struct sc27xx_adc_data *data) +{ + int ret; + + ret = regmap_update_bits(data->regmap, SC27XX_MODULE_EN, + SC27XX_MODULE_ADC_EN, SC27XX_MODULE_ADC_EN); + if (ret) + return ret; + + /* Enable ADC work clock and controller clock */ + ret = regmap_update_bits(data->regmap, SC27XX_ARM_CLK_EN, + SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN, + SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN); + if (ret) + goto disable_adc; + + ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_INT_EN, + SC27XX_ADC_IRQ_EN, SC27XX_ADC_IRQ_EN); + if (ret) + goto disable_clk; + + return 0; + +disable_clk: + regmap_update_bits(data->regmap, SC27XX_ARM_CLK_EN, + SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN, 0); +disable_adc: + regmap_update_bits(data->regmap, SC27XX_MODULE_EN, + SC27XX_MODULE_ADC_EN, 0); + + return ret; +} + +static void sc27xx_adc_disable(void *_data) +{ + struct sc27xx_adc_data *data = _data; + + regmap_update_bits(data->regmap, data->base + SC27XX_ADC_INT_EN, + SC27XX_ADC_IRQ_EN, 0); + + /* Disable ADC work clock and controller clock */ + regmap_update_bits(data->regmap, SC27XX_ARM_CLK_EN, + SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN, 0); + + regmap_update_bits(data->regmap, SC27XX_MODULE_EN, + SC27XX_MODULE_ADC_EN, 0); +} + +static void sc27xx_adc_free_hwlock(void *_data) +{ + struct hwspinlock *hwlock = _data; + + hwspin_lock_free(hwlock); +} + +static int sc27xx_adc_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct sc27xx_adc_data *sc27xx_data; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*sc27xx_data)); + if (!indio_dev) + return -ENOMEM; + + sc27xx_data = iio_priv(indio_dev); + + sc27xx_data->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!sc27xx_data->regmap) { + dev_err(&pdev->dev, "failed to get ADC regmap\n"); + return -ENODEV; + } + + ret = of_property_read_u32(np, "reg", &sc27xx_data->base); + if (ret) { + dev_err(&pdev->dev, "failed to get ADC base address\n"); + return ret; + } + + sc27xx_data->irq = platform_get_irq(pdev, 0); + if (sc27xx_data->irq < 0) { + dev_err(&pdev->dev, "failed to get ADC irq number\n"); + return sc27xx_data->irq; + } + + ret = of_hwspin_lock_get_id(np, 0); + if (ret < 0) { + dev_err(&pdev->dev, "failed to get hwspinlock id\n"); + return ret; + } + + sc27xx_data->hwlock = hwspin_lock_request_specific(ret); + if (!sc27xx_data->hwlock) { + dev_err(&pdev->dev, "failed to request hwspinlock\n"); + return -ENXIO; + } + + ret = devm_add_action(&pdev->dev, sc27xx_adc_free_hwlock, + sc27xx_data->hwlock); + if (ret) { + sc27xx_adc_free_hwlock(sc27xx_data->hwlock); + dev_err(&pdev->dev, "failed to add hwspinlock action\n"); + return ret; + } + + init_completion(&sc27xx_data->completion); + sc27xx_data->dev = &pdev->dev; + + ret = sc27xx_adc_enable(sc27xx_data); + if (ret) { + dev_err(&pdev->dev, "failed to enable ADC module\n"); + return ret; + } + + ret = devm_add_action(&pdev->dev, sc27xx_adc_disable, sc27xx_data); + if (ret) { + sc27xx_adc_disable(sc27xx_data); + dev_err(&pdev->dev, "failed to add ADC disable action\n"); + return ret; + } + + ret = devm_request_threaded_irq(&pdev->dev, sc27xx_data->irq, NULL, + sc27xx_adc_isr, IRQF_ONESHOT, + pdev->name, sc27xx_data); + if (ret) { + dev_err(&pdev->dev, "failed to request ADC irq\n"); + return ret; + } + + indio_dev->dev.parent = &pdev->dev; + indio_dev->name = dev_name(&pdev->dev); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &sc27xx_info; + indio_dev->channels = sc27xx_channels; + indio_dev->num_channels = ARRAY_SIZE(sc27xx_channels); + ret = devm_iio_device_register(&pdev->dev, indio_dev); + if (ret) + dev_err(&pdev->dev, "could not register iio (ADC)"); + + return ret; +} + +static const struct of_device_id sc27xx_adc_of_match[] = { + { .compatible = "sprd,sc2731-adc", }, + { } +}; + +static struct platform_driver sc27xx_adc_driver = { + .probe = sc27xx_adc_probe, + .driver = { + .name = "sc27xx-adc", + .of_match_table = sc27xx_adc_of_match, + }, +}; + +module_platform_driver(sc27xx_adc_driver); + +MODULE_AUTHOR("Freeman Liu "); +MODULE_DESCRIPTION("Spreadtrum SC27XX ADC Driver"); +MODULE_LICENSE("GPL v2"); From ee55fe552fcd8dcdafc52155ba515548c6538647 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Sun, 1 Jul 2018 14:48:14 -0400 Subject: [PATCH 209/903] staging/skein: Remove Skein and Threefish code It's been four years since this was added. In the interim, skein has not seen any mainstream adoption. Same with the threefish block cipher upon which it's based. In the discussion over which hash algorithm will replace SHA1 in git, it's not one of the contenders. There's absolutely no reason to think that there is anything wrong with Skein or Threefish. The only reason for this removal is a lack of adoption. If a real user comes forward, I'd be happy to assist with integrating this code into mainline. Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/skein/Kconfig | 16 - drivers/staging/skein/Makefile | 11 - drivers/staging/skein/TODO | 8 - drivers/staging/skein/skein_api.c | 231 - drivers/staging/skein/skein_api.h | 230 - drivers/staging/skein/skein_base.c | 870 --- drivers/staging/skein/skein_base.h | 336 - drivers/staging/skein/skein_block.c | 469 -- drivers/staging/skein/skein_block.h | 347 - drivers/staging/skein/skein_generic.c | 214 - drivers/staging/skein/skein_iv.h | 187 - drivers/staging/skein/threefish_api.c | 78 - drivers/staging/skein/threefish_api.h | 171 - drivers/staging/skein/threefish_block.c | 8244 ----------------------- 16 files changed, 11415 deletions(-) delete mode 100644 drivers/staging/skein/Kconfig delete mode 100644 drivers/staging/skein/Makefile delete mode 100644 drivers/staging/skein/TODO delete mode 100644 drivers/staging/skein/skein_api.c delete mode 100644 drivers/staging/skein/skein_api.h delete mode 100644 drivers/staging/skein/skein_base.c delete mode 100644 drivers/staging/skein/skein_base.h delete mode 100644 drivers/staging/skein/skein_block.c delete mode 100644 drivers/staging/skein/skein_block.h delete mode 100644 drivers/staging/skein/skein_generic.c delete mode 100644 drivers/staging/skein/skein_iv.h delete mode 100644 drivers/staging/skein/threefish_api.c delete mode 100644 drivers/staging/skein/threefish_api.h delete mode 100644 drivers/staging/skein/threefish_block.c diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 75a480497d22..5b96f972135a 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -84,8 +84,6 @@ source "drivers/staging/dgnc/Kconfig" source "drivers/staging/gs_fpgaboot/Kconfig" -source "drivers/staging/skein/Kconfig" - source "drivers/staging/unisys/Kconfig" source "drivers/staging/clocking-wizard/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index e84959a8a684..5d3740320577 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -33,7 +33,6 @@ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_DGNC) += dgnc/ obj-$(CONFIG_MTD_SPINAND_MT29F) += mt29f_spinand/ obj-$(CONFIG_GS_FPGABOOT) += gs_fpgaboot/ -obj-$(CONFIG_CRYPTO_SKEIN) += skein/ obj-$(CONFIG_UNISYSSPAR) += unisys/ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/ obj-$(CONFIG_FB_TFT) += fbtft/ diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig deleted file mode 100644 index 012a8233376e..000000000000 --- a/drivers/staging/skein/Kconfig +++ /dev/null @@ -1,16 +0,0 @@ -config CRYPTO_SKEIN - tristate "Skein digest algorithm" - depends on (X86 || UML_X86) && 64BIT && CRYPTO - select CRYPTO_HASH - select CRYPTO_ALGAPI - help - Skein secure hash algorithm is one of 5 finalists from the NIST SHA3 - competition. - - Skein is optimized for modern, 64bit processors and is highly - customizable. See: - - http://www.skein-hash.info/sites/default/files/skein1.3.pdf - - for more information. This module also contains the threefish block - cipher algorithm. diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile deleted file mode 100644 index 86b7966d694e..000000000000 --- a/drivers/staging/skein/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Makefile for the skein secure hash algorithm -# -obj-$(CONFIG_CRYPTO_SKEIN) += skein.o -skein-y := skein_base.o \ - skein_api.o \ - skein_block.o \ - threefish_block.o \ - threefish_api.o \ - skein_generic.o diff --git a/drivers/staging/skein/TODO b/drivers/staging/skein/TODO deleted file mode 100644 index cd3508dd9089..000000000000 --- a/drivers/staging/skein/TODO +++ /dev/null @@ -1,8 +0,0 @@ -skein/threefish TODO - - - move macros into appropriate header files - - add / pass test vectors - - module support - -Please send patches to Jason Cooper in addition to the -staging tree mailinglist. diff --git a/drivers/staging/skein/skein_api.c b/drivers/staging/skein/skein_api.c deleted file mode 100644 index c6526b6fbfb4..000000000000 --- a/drivers/staging/skein/skein_api.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2010 Werner Dittmann - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include "skein_api.h" - -int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) -{ - skein_assert_ret(ctx && size, SKEIN_FAIL); - - memset(ctx, 0, sizeof(struct skein_ctx)); - ctx->skein_size = size; - - return SKEIN_SUCCESS; -} - -int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) -{ - int ret = SKEIN_FAIL; - size_t x_len = 0; - u64 *x = NULL; - u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - - skein_assert_ret(ctx, SKEIN_FAIL); - /* - * The following two lines rely of the fact that the real Skein - * contexts are a union in out context and thus have tha maximum - * memory available. The beauty of C :-) . - */ - x = ctx->m.s256.x; - x_len = ctx->skein_size / 8; - /* - * If size is the same and hash bit length is zero then reuse - * the save chaining variables. - */ - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, - tree_info, NULL, 0); - break; - case SKEIN_512: - ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, - tree_info, NULL, 0); - break; - case SKEIN_1024: - ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, - tree_info, NULL, 0); - break; - } - - if (ret == SKEIN_SUCCESS) { - /* - * Save chaining variables for this combination of size and - * hash_bit_len - */ - memcpy(ctx->x_save, x, x_len); - } - return ret; -} - -int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, - size_t hash_bit_len) -{ - int ret = SKEIN_FAIL; - u64 *x = NULL; - size_t x_len = 0; - u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - - skein_assert_ret(ctx, SKEIN_FAIL); - - x = ctx->m.s256.x; - x_len = ctx->skein_size / 8; - - skein_assert_ret(hash_bit_len, SKEIN_BAD_HASHLEN); - - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, - tree_info, key, key_len); - - break; - case SKEIN_512: - ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, - tree_info, key, key_len); - break; - case SKEIN_1024: - ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, - tree_info, key, key_len); - - break; - } - if (ret == SKEIN_SUCCESS) { - /* - * Save chaining variables for this combination of key, - * key_len, hash_bit_len - */ - memcpy(ctx->x_save, x, x_len); - } - return ret; -} - -void skein_reset(struct skein_ctx *ctx) -{ - size_t x_len = 0; - u64 *x; - - /* - * The following two lines rely of the fact that the real Skein - * contexts are a union in out context and thus have tha maximum - * memory available. The beautiy of C :-) . - */ - x = ctx->m.s256.x; - x_len = ctx->skein_size / 8; - /* Restore the chaing variable, reset byte counter */ - memcpy(x, ctx->x_save, x_len); - - /* Setup context to process the message */ - skein_start_new_type(&ctx->m, MSG); -} - -int skein_update(struct skein_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - int ret = SKEIN_FAIL; - - skein_assert_ret(ctx, SKEIN_FAIL); - - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_update(&ctx->m.s256, msg, msg_byte_cnt); - break; - case SKEIN_512: - ret = skein_512_update(&ctx->m.s512, msg, msg_byte_cnt); - break; - case SKEIN_1024: - ret = skein_1024_update(&ctx->m.s1024, msg, msg_byte_cnt); - break; - } - return ret; -} - -int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, - size_t msg_bit_cnt) -{ - /* - * I've used the bit pad implementation from skein_test.c (see NIST CD) - * and modified it to use the convenience functions and added some - * pointer arithmetic. - */ - size_t length; - u8 mask; - u8 *up; - - /* - * only the final Update() call is allowed do partial bytes, else - * assert an error - */ - skein_assert_ret((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || - msg_bit_cnt == 0, SKEIN_FAIL); - - /* if number of bits is a multiple of bytes - that's easy */ - if ((msg_bit_cnt & 0x7) == 0) - return skein_update(ctx, msg, msg_bit_cnt >> 3); - - skein_update(ctx, msg, (msg_bit_cnt >> 3) + 1); - - /* - * The next line rely on the fact that the real Skein contexts - * are a union in our context. After the addition the pointer points to - * Skein's real partial block buffer. - * If this layout ever changes we have to adapt this as well. - */ - up = (u8 *)ctx->m.s256.x + ctx->skein_size / 8; - - /* set tweak flag for the skein_final call */ - skein_set_bit_pad_flag(ctx->m.h); - - /* now "pad" the final partial byte the way NIST likes */ - /* get the b_cnt value (same location for all block sizes) */ - length = ctx->m.h.b_cnt; - /* internal sanity check: there IS a partial byte in the buffer! */ - skein_assert(length != 0); - /* partial byte bit mask */ - mask = (u8)(1u << (7 - (msg_bit_cnt & 7))); - /* apply bit padding on final byte (in the buffer) */ - up[length - 1] = (up[length - 1] & (0 - mask)) | mask; - - return SKEIN_SUCCESS; -} - -int skein_final(struct skein_ctx *ctx, u8 *hash) -{ - int ret = SKEIN_FAIL; - - skein_assert_ret(ctx, SKEIN_FAIL); - - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_final(&ctx->m.s256, hash); - break; - case SKEIN_512: - ret = skein_512_final(&ctx->m.s512, hash); - break; - case SKEIN_1024: - ret = skein_1024_final(&ctx->m.s1024, hash); - break; - } - return ret; -} diff --git a/drivers/staging/skein/skein_api.h b/drivers/staging/skein/skein_api.h deleted file mode 100644 index 5df7905825da..000000000000 --- a/drivers/staging/skein/skein_api.h +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Copyright (c) 2010 Werner Dittmann - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - - */ - -#ifndef SKEINAPI_H -#define SKEINAPI_H - -/** - * @file skein_api.h - * @brief A Skein API and its functions. - * @{ - * - * This API and the functions that implement this API simplify the usage - * of Skein. The design and the way to use the functions follow the openSSL - * design but at the same time take care of some Skein specific behaviour - * and possibilities. - * - * The functions enable applications to create a normal Skein hashes and - * message authentication codes (MAC). - * - * Using these functions is simple and straight forward: - * - * @code - * - * #include "skein_api.h" - * - * ... - * struct skein_ctx ctx; // a Skein hash or MAC context - * - * // prepare context, here for a Skein with a state size of 512 bits. - * skein_ctx_prepare(&ctx, SKEIN_512); - * - * // Initialize the context to set the requested hash length in bits - * // here request a output hash size of 31 bits (Skein supports variable - * // output sizes even very strange sizes) - * skein_init(&ctx, 31); - * - * // Now update Skein with any number of message bits. A function that - * // takes a number of bytes is also available. - * skein_update_bits(&ctx, message, msg_length); - * - * // Now get the result of the Skein hash. The output buffer must be - * // large enough to hold the request number of output bits. The application - * // may now extract the bits. - * skein_final(&ctx, result); - * ... - * @endcode - * - * An application may use @c skein_reset to reset a Skein context and use - * it for creation of another hash with the same Skein state size and output - * bit length. In this case the API implementation restores some internal - * internal state data and saves a full Skein initialization round. - * - * To create a MAC the application just uses @c skein_mac_init instead of - * @c skein_init. All other functions calls remain the same. - * - */ - -#include -#include "skein_base.h" - -/** - * Which Skein size to use - */ -enum skein_size { - SKEIN_256 = 256, /*!< Skein with 256 bit state */ - SKEIN_512 = 512, /*!< Skein with 512 bit state */ - SKEIN_1024 = 1024 /*!< Skein with 1024 bit state */ -}; - -/** - * Context for Skein. - * - * This structure was setup with some know-how of the internal - * Skein structures, in particular ordering of header and size dependent - * variables. If Skein implementation changes this, then adapt these - * structures as well. - */ -struct skein_ctx { - u64 skein_size; - u64 x_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ - union { - struct skein_ctx_hdr h; - struct skein_256_ctx s256; - struct skein_512_ctx s512; - struct skein_1024_ctx s1024; - } m; -}; - -/** - * Prepare a Skein context. - * - * An application must call this function before it can use the Skein - * context. The functions clears memory and initializes size dependent - * variables. - * - * @param ctx - * Pointer to a Skein context. - * @param size - * Which Skein size to use. - * @return - * SKEIN_SUCCESS of SKEIN_FAIL - */ -int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size); - -/** - * Initialize a Skein context. - * - * Initializes the context with this data and saves the resulting Skein - * state variables for further use. - * - * @param ctx - * Pointer to a Skein context. - * @param hash_bit_len - * Number of MAC hash bits to compute - * @return - * SKEIN_SUCCESS of SKEIN_FAIL - * @see skein_reset - */ -int skein_init(struct skein_ctx *ctx, size_t hash_bit_len); - -/** - * Resets a Skein context for further use. - * - * Restores the saved chaining variables to reset the Skein context. - * Thus applications can reuse the same setup to process several - * messages. This saves a complete Skein initialization cycle. - * - * @param ctx - * Pointer to a pre-initialized Skein MAC context - */ -void skein_reset(struct skein_ctx *ctx); - -/** - * Initializes a Skein context for MAC usage. - * - * Initializes the context with this data and saves the resulting Skein - * state variables for further use. - * - * Applications call the normal Skein functions to update the MAC and - * get the final result. - * - * @param ctx - * Pointer to an empty or preinitialized Skein MAC context - * @param key - * Pointer to key bytes or NULL - * @param key_len - * Length of the key in bytes or zero - * @param hash_bit_len - * Number of MAC hash bits to compute - * @return - * SKEIN_SUCCESS of SKEIN_FAIL - */ -int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, - size_t hash_bit_len); - -/** - * Update Skein with the next part of the message. - * - * @param ctx - * Pointer to initialized Skein context - * @param msg - * Pointer to the message. - * @param msg_byte_cnt - * Length of the message in @b bytes - * @return - * Success or error code. - */ -int skein_update(struct skein_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); - -/** - * Update the hash with a message bit string. - * - * Skein can handle data not only as bytes but also as bit strings of - * arbitrary length (up to its maximum design size). - * - * @param ctx - * Pointer to initialized Skein context - * @param msg - * Pointer to the message. - * @param msg_bit_cnt - * Length of the message in @b bits. - */ -int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, - size_t msg_bit_cnt); - -/** - * Finalize Skein and return the hash. - * - * Before an application can reuse a Skein setup the application must - * reset the Skein context. - * - * @param ctx - * Pointer to initialized Skein context - * @param hash - * Pointer to buffer that receives the hash. The buffer must be large - * enough to store @c hash_bit_len bits. - * @return - * Success or error code. - * @see skein_reset - */ -int skein_final(struct skein_ctx *ctx, u8 *hash); - -/** - * @} - */ -#endif diff --git a/drivers/staging/skein/skein_base.c b/drivers/staging/skein/skein_base.c deleted file mode 100644 index 8db858a11875..000000000000 --- a/drivers/staging/skein/skein_base.c +++ /dev/null @@ -1,870 +0,0 @@ -/*********************************************************************** - ** - ** Implementation of the Skein hash function. - ** - ** Source code author: Doug Whiting, 2008. - ** - ** This algorithm and source code is released to the public domain. - ** - ************************************************************************/ - -#include /* get the memcpy/memset functions */ -#include -#include "skein_base.h" /* get the Skein API definitions */ -#include "skein_iv.h" /* get precomputed IVs */ -#include "skein_block.h" - -/*****************************************************************/ -/* 256-bit Skein */ -/*****************************************************************/ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a straight hashing operation */ -int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) -{ - union { - u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - - switch (hash_bit_len) { /* use pre-computed values, where available */ - case 256: - memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x)); - break; - case 224: - memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x)); - break; - case 160: - memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x)); - break; - case 128: - memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x)); - break; - default: - /* here if there is no precomputed IV value available */ - /* - * build/process the config block, type == CONFIG (could be - * precomputed) - */ - /* set tweaks: T0=0; T1=CFG | FINAL */ - skein_start_new_type(ctx, CFG_FINAL); - - /* set the schema, version */ - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - /* zero pad config block */ - memset(&cfg.w[3], 0, sizeof(cfg) - 3 * sizeof(cfg.w[0])); - - /* compute the initial chaining values from config block */ - /* zero the chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - /* The chaining vars ctx->x are now initialized for hash_bit_len. */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a MAC and/or tree hash operation */ -/* - * [identical to skein_256_init() when key_bytes == 0 && \ - * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] - */ -int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes) -{ - union { - u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - skein_assert_ret(key_bytes == 0 || key, SKEIN_FAIL); - - /* compute the initial chaining values ctx->x[], based on key */ - if (key_bytes == 0) { /* is there a key? */ - /* no key: use all zeroes as key for config block */ - memset(ctx->x, 0, sizeof(ctx->x)); - } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); - /* do a mini-Init right here */ - /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8 * sizeof(ctx->x); - /* set tweaks: T0 = 0; T1 = KEY type */ - skein_start_new_type(ctx, KEY); - /* zero the initial chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - /* hash the key */ - skein_256_update(ctx, key, key_bytes); - /* put result into cfg.b[] */ - skein_256_final_pad(ctx, cfg.b); - /* copy over into ctx->x[] */ - memcpy(ctx->x, cfg.b, sizeof(cfg.b)); - } - /* - * build/process the config block, type == CONFIG (could be - * precomputed for each key) - */ - /* output hash bit count */ - ctx->h.hash_bit_len = hash_bit_len; - skein_start_new_type(ctx, CFG_FINAL); - - /* pre-pad cfg.w[] with zeroes */ - memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = skein_swap64(tree_info); - - /* compute the initial chaining values from config block */ - skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->x are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process the input bytes */ -int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - size_t n; - - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* process full blocks, if any */ - if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) { - /* finish up any buffered message data */ - if (ctx->h.b_cnt) { - /* # bytes free in buffer b[] */ - n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt; - if (n) { - /* check on our logic here */ - skein_assert(n < msg_byte_cnt); - memcpy(&ctx->b[ctx->h.b_cnt], msg, n); - msg_byte_cnt -= n; - msg += n; - ctx->h.b_cnt += n; - } - skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES); - skein_256_process_block(ctx, ctx->b, 1, - SKEIN_256_BLOCK_BYTES); - ctx->h.b_cnt = 0; - } - /* - * now process any remaining full blocks, directly from input - * message data - */ - if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) { - /* number of full blocks to process */ - n = (msg_byte_cnt - 1) / SKEIN_256_BLOCK_BYTES; - skein_256_process_block(ctx, msg, n, - SKEIN_256_BLOCK_BYTES); - msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES; - msg += n * SKEIN_256_BLOCK_BYTES; - } - skein_assert(ctx->h.b_cnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msg_byte_cnt) { - skein_assert(msg_byte_cnt + ctx->h.b_cnt <= - SKEIN_256_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); - ctx->h.b_cnt += msg_byte_cnt; - } - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the result */ -int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_256_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); - - /* process the final block */ - skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i * SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64)i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i * SKEIN_256_BLOCK_BYTES; - if (n >= SKEIN_256_BLOCK_BYTES) - n = SKEIN_256_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val + (i * SKEIN_256_BLOCK_BYTES), - ctx->x, n); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*****************************************************************/ -/* 512-bit Skein */ -/*****************************************************************/ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a straight hashing operation */ -int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) -{ - union { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - - switch (hash_bit_len) { /* use pre-computed values, where available */ - case 512: - memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x)); - break; - case 384: - memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x)); - break; - case 256: - memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x)); - break; - case 224: - memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x)); - break; - default: - /* here if there is no precomputed IV value available */ - /* - * build/process the config block, type == CONFIG (could be - * precomputed) - */ - /* set tweaks: T0=0; T1=CFG | FINAL */ - skein_start_new_type(ctx, CFG_FINAL); - - /* set the schema, version */ - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - /* zero pad config block */ - memset(&cfg.w[3], 0, sizeof(cfg) - 3 * sizeof(cfg.w[0])); - - /* compute the initial chaining values from config block */ - /* zero the chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - - /* - * The chaining vars ctx->x are now initialized for the given - * hash_bit_len. - */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a MAC and/or tree hash operation */ -/* - * [identical to skein_512_init() when key_bytes == 0 && \ - * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] - */ -int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes) -{ - union { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - skein_assert_ret(key_bytes == 0 || key, SKEIN_FAIL); - - /* compute the initial chaining values ctx->x[], based on key */ - if (key_bytes == 0) { /* is there a key? */ - /* no key: use all zeroes as key for config block */ - memset(ctx->x, 0, sizeof(ctx->x)); - } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); - /* do a mini-Init right here */ - /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8 * sizeof(ctx->x); - /* set tweaks: T0 = 0; T1 = KEY type */ - skein_start_new_type(ctx, KEY); - /* zero the initial chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - /* hash the key */ - skein_512_update(ctx, key, key_bytes); - /* put result into cfg.b[] */ - skein_512_final_pad(ctx, cfg.b); - /* copy over into ctx->x[] */ - memcpy(ctx->x, cfg.b, sizeof(cfg.b)); - } - /* - * build/process the config block, type == CONFIG (could be - * precomputed for each key) - */ - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - skein_start_new_type(ctx, CFG_FINAL); - - /* pre-pad cfg.w[] with zeroes */ - memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = skein_swap64(tree_info); - - /* compute the initial chaining values from config block */ - skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->x are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process the input bytes */ -int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - size_t n; - - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* process full blocks, if any */ - if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) { - /* finish up any buffered message data */ - if (ctx->h.b_cnt) { - /* # bytes free in buffer b[] */ - n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt; - if (n) { - /* check on our logic here */ - skein_assert(n < msg_byte_cnt); - memcpy(&ctx->b[ctx->h.b_cnt], msg, n); - msg_byte_cnt -= n; - msg += n; - ctx->h.b_cnt += n; - } - skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES); - skein_512_process_block(ctx, ctx->b, 1, - SKEIN_512_BLOCK_BYTES); - ctx->h.b_cnt = 0; - } - /* - * now process any remaining full blocks, directly from input - * message data - */ - if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) { - /* number of full blocks to process */ - n = (msg_byte_cnt - 1) / SKEIN_512_BLOCK_BYTES; - skein_512_process_block(ctx, msg, n, - SKEIN_512_BLOCK_BYTES); - msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES; - msg += n * SKEIN_512_BLOCK_BYTES; - } - skein_assert(ctx->h.b_cnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msg_byte_cnt) { - skein_assert(msg_byte_cnt + ctx->h.b_cnt <= - SKEIN_512_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); - ctx->h.b_cnt += msg_byte_cnt; - } - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the result */ -int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_512_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); - - /* process the final block */ - skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i * SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64)i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i * SKEIN_512_BLOCK_BYTES; - if (n >= SKEIN_512_BLOCK_BYTES) - n = SKEIN_512_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val + (i * SKEIN_512_BLOCK_BYTES), - ctx->x, n); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*****************************************************************/ -/* 1024-bit Skein */ -/*****************************************************************/ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a straight hashing operation */ -int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) -{ - union { - u8 b[SKEIN_1024_STATE_BYTES]; - u64 w[SKEIN_1024_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - - switch (hash_bit_len) { /* use pre-computed values, where available */ - case 512: - memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x)); - break; - case 384: - memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x)); - break; - case 1024: - memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x)); - break; - default: - /* here if there is no precomputed IV value available */ - /* - * build/process the config block, type == CONFIG - * (could be precomputed) - */ - /* set tweaks: T0=0; T1=CFG | FINAL */ - skein_start_new_type(ctx, CFG_FINAL); - - /* set the schema, version */ - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - /* zero pad config block */ - memset(&cfg.w[3], 0, sizeof(cfg) - 3 * sizeof(cfg.w[0])); - - /* compute the initial chaining values from config block */ - /* zero the chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - - /* The chaining vars ctx->x are now initialized for the hash_bit_len. */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a MAC and/or tree hash operation */ -/* - * [identical to skein_1024_init() when key_bytes == 0 && \ - * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] - */ -int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes) -{ - union { - u8 b[SKEIN_1024_STATE_BYTES]; - u64 w[SKEIN_1024_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - skein_assert_ret(key_bytes == 0 || key, SKEIN_FAIL); - - /* compute the initial chaining values ctx->x[], based on key */ - if (key_bytes == 0) { /* is there a key? */ - /* no key: use all zeroes as key for config block */ - memset(ctx->x, 0, sizeof(ctx->x)); - } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); - /* do a mini-Init right here */ - /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8 * sizeof(ctx->x); - /* set tweaks: T0 = 0; T1 = KEY type */ - skein_start_new_type(ctx, KEY); - /* zero the initial chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - /* hash the key */ - skein_1024_update(ctx, key, key_bytes); - /* put result into cfg.b[] */ - skein_1024_final_pad(ctx, cfg.b); - /* copy over into ctx->x[] */ - memcpy(ctx->x, cfg.b, sizeof(cfg.b)); - } - /* - * build/process the config block, type == CONFIG (could be - * precomputed for each key) - */ - /* output hash bit count */ - ctx->h.hash_bit_len = hash_bit_len; - skein_start_new_type(ctx, CFG_FINAL); - - /* pre-pad cfg.w[] with zeroes */ - memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = skein_swap64(tree_info); - - /* compute the initial chaining values from config block */ - skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->x are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process the input bytes */ -int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - size_t n; - - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* process full blocks, if any */ - if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_1024_BLOCK_BYTES) { - /* finish up any buffered message data */ - if (ctx->h.b_cnt) { - /* # bytes free in buffer b[] */ - n = SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt; - if (n) { - /* check on our logic here */ - skein_assert(n < msg_byte_cnt); - memcpy(&ctx->b[ctx->h.b_cnt], msg, n); - msg_byte_cnt -= n; - msg += n; - ctx->h.b_cnt += n; - } - skein_assert(ctx->h.b_cnt == SKEIN_1024_BLOCK_BYTES); - skein_1024_process_block(ctx, ctx->b, 1, - SKEIN_1024_BLOCK_BYTES); - ctx->h.b_cnt = 0; - } - /* - * now process any remaining full blocks, directly from input - * message data - */ - if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) { - /* number of full blocks to process */ - n = (msg_byte_cnt - 1) / SKEIN_1024_BLOCK_BYTES; - skein_1024_process_block(ctx, msg, n, - SKEIN_1024_BLOCK_BYTES); - msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES; - msg += n * SKEIN_1024_BLOCK_BYTES; - } - skein_assert(ctx->h.b_cnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msg_byte_cnt) { - skein_assert(msg_byte_cnt + ctx->h.b_cnt <= - SKEIN_1024_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); - ctx->h.b_cnt += msg_byte_cnt; - } - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the result */ -int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_1024_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); - - /* process the final block */ - skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i * SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64)i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i * SKEIN_1024_BLOCK_BYTES; - if (n >= SKEIN_1024_BLOCK_BYTES) - n = SKEIN_1024_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val + (i * SKEIN_1024_BLOCK_BYTES), - ctx->x, n); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/**************** Functions to support MAC/tree hashing ***************/ -/* (this code is identical for Optimized and Reference versions) */ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) -{ - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); - /* process the final block */ - skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) -{ - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); - /* process the final block */ - skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) -{ - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); - /* process the final block */ - skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES); - - return SKEIN_SUCCESS; -} - -#if SKEIN_TREE_HASH -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* just do the OUTPUT stage */ -int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_256_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i * SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64)i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i * SKEIN_256_BLOCK_BYTES; - if (n >= SKEIN_256_BLOCK_BYTES) - n = SKEIN_256_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val + (i * SKEIN_256_BLOCK_BYTES), - ctx->x, n); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* just do the OUTPUT stage */ -int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_512_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i * SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64)i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i * SKEIN_512_BLOCK_BYTES; - if (n >= SKEIN_512_BLOCK_BYTES) - n = SKEIN_512_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val + (i * SKEIN_512_BLOCK_BYTES), - ctx->x, n); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* just do the OUTPUT stage */ -int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_1024_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i * SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64)i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i * SKEIN_1024_BLOCK_BYTES; - if (n >= SKEIN_1024_BLOCK_BYTES) - n = SKEIN_1024_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val + (i * SKEIN_1024_BLOCK_BYTES), - ctx->x, n); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} -#endif diff --git a/drivers/staging/skein/skein_base.h b/drivers/staging/skein/skein_base.h deleted file mode 100644 index cd794c1bc1bb..000000000000 --- a/drivers/staging/skein/skein_base.h +++ /dev/null @@ -1,336 +0,0 @@ -#ifndef _SKEIN_H_ -#define _SKEIN_H_ 1 -/* - ************************************************************************** - * - * Interface declarations and internal definitions for Skein hashing. - * - * Source code author: Doug Whiting, 2008. - * - * This algorithm and source code is released to the public domain. - * - ************************************************************************** - * - * The following compile-time switches may be defined to control some - * tradeoffs between speed, code size, error checking, and security. - * - * The "default" note explains what happens when the switch is not defined. - * - * SKEIN_ERR_CHECK -- how error checking is handled inside Skein - * code. If not defined, most error checking - * is disabled (for performance). Otherwise, - * the switch value is interpreted as: - * 0: use assert() to flag errors - * 1: return SKEIN_FAIL to flag errors - * - ************************************************************************** - */ - -/*Skein digest sizes for crypto api*/ -#define SKEIN256_DIGEST_BIT_SIZE 256 -#define SKEIN512_DIGEST_BIT_SIZE 512 -#define SKEIN1024_DIGEST_BIT_SIZE 1024 - -/* below two prototype assume we are handed aligned data */ -#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) -#define skein_get64_lsb_first(dst64, src08, w_cnt) \ - memcpy(dst64, src08, 8 * (w_cnt)) -#define skein_swap64(w64) (w64) - -enum { - SKEIN_SUCCESS = 0, /* return codes from Skein calls */ - SKEIN_FAIL = 1, - SKEIN_BAD_HASHLEN = 2 -}; - -#define SKEIN_MODIFIER_WORDS 2 /* number of modifier (tweak) words */ - -#define SKEIN_256_STATE_WORDS 4 -#define SKEIN_512_STATE_WORDS 8 -#define SKEIN_1024_STATE_WORDS 16 -#define SKEIN_MAX_STATE_WORDS 16 - -#define SKEIN_256_STATE_BYTES (8 * SKEIN_256_STATE_WORDS) -#define SKEIN_512_STATE_BYTES (8 * SKEIN_512_STATE_WORDS) -#define SKEIN_1024_STATE_BYTES (8 * SKEIN_1024_STATE_WORDS) - -#define SKEIN_256_STATE_BITS (64 * SKEIN_256_STATE_WORDS) -#define SKEIN_512_STATE_BITS (64 * SKEIN_512_STATE_WORDS) -#define SKEIN_1024_STATE_BITS (64 * SKEIN_1024_STATE_WORDS) - -#define SKEIN_256_BLOCK_BYTES (8 * SKEIN_256_STATE_WORDS) -#define SKEIN_512_BLOCK_BYTES (8 * SKEIN_512_STATE_WORDS) -#define SKEIN_1024_BLOCK_BYTES (8 * SKEIN_1024_STATE_WORDS) - -struct skein_ctx_hdr { - size_t hash_bit_len; /* size of hash result, in bits */ - size_t b_cnt; /* current byte count in buffer b[] */ - u64 tweak[SKEIN_MODIFIER_WORDS]; /* tweak[0]=byte cnt, tweak[1]=flags */ -}; - -struct skein_256_ctx { /* 256-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 x[SKEIN_256_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -struct skein_512_ctx { /* 512-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 x[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 x[SKEIN_1024_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -/* Skein APIs for (incremental) "straight hashing" */ -int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); -int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); -int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len); - -int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); -int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); -int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); - -int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); - -/* - * Skein APIs for "extended" initialization: MAC keys, tree hashing. - * After an init_ext() call, just use update/final calls as with init(). - * - * Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. - * When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, - * the results of init_ext() are identical to calling init(). - * The function init() may be called once to "precompute" the IV for - * a given hash_bit_len value, then by saving a copy of the context - * the IV computation may be avoided in later calls. - * Similarly, the function init_ext() may be called once per MAC key - * to precompute the MAC IV, then a copy of the context saved and - * reused for each new MAC computation. - */ -int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); -int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); -int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); - -/* - * Skein APIs for MAC and tree hash: - * final_pad: pad, do final block, but no OUTPUT type - * output: do just the output stage - */ -int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val); - -#ifndef SKEIN_TREE_HASH -#define SKEIN_TREE_HASH (1) -#endif -#if SKEIN_TREE_HASH -int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); -#endif - -/* - ***************************************************************** - * "Internal" Skein definitions - * -- not needed for sequential hashing API, but will be - * helpful for other uses of Skein (e.g., tree hash mode). - * -- included here so that they can be shared between - * reference and optimized code. - ***************************************************************** - */ - -/* tweak word tweak[1]: bit field starting positions */ -#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ - -#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ -#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* 119 part. final in byte */ -#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* 120..125 type field `*/ -#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ -#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ - -/* tweak word tweak[1]: flag bit definition(s) */ -#define SKEIN_T1_FLAG_FIRST (((u64)1) << SKEIN_T1_POS_FIRST) -#define SKEIN_T1_FLAG_FINAL (((u64)1) << SKEIN_T1_POS_FINAL) -#define SKEIN_T1_FLAG_BIT_PAD (((u64)1) << SKEIN_T1_POS_BIT_PAD) - -/* tweak word tweak[1]: tree level bit field mask */ -#define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) -#define SKEIN_T1_TREE_LEVEL(n) (((u64)(n)) << SKEIN_T1_POS_TREE_LVL) - -/* tweak word tweak[1]: block type field */ -#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ -#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ -#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ -#define SKEIN_BLK_TYPE_PK (12) /* pubkey (for digital sigs) */ -#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ -#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ -#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ -#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ -#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ - -#define SKEIN_T1_BLK_TYPE(T) (((u64)(SKEIN_BLK_TYPE_##T)) << \ - SKEIN_T1_POS_BLK_TYPE) -#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* for MAC and KDF */ -#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* config block */ -#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization */ -#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* pubkey (for sigs) */ -#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key ident for KDF */ -#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ -#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ -#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ -#define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ - -#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | \ - SKEIN_T1_FLAG_FINAL) -#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | \ - SKEIN_T1_FLAG_FINAL) - -#define SKEIN_VERSION (1) - -#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ -#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ -#endif - -#define SKEIN_MK_64(hi32, lo32) ((lo32) + (((u64)(hi32)) << 32)) -#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE) -#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22) - -#define SKEIN_CFG_STR_LEN (4 * 8) - -/* bit field definitions in config block tree_info word */ -#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) -#define SKEIN_CFG_TREE_NODE_SIZE_POS (8) -#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) - -#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_LEAF_SIZE_POS) -#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_NODE_SIZE_POS) -#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_MAX_LEVEL_POS) - -#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl) \ - ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ - (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) - -/* use as tree_info in InitExt() call for sequential processing */ -#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) - -/* - * Skein macros for getting/setting tweak words, etc. - * These are useful for partial input bytes, hash tree init/update, etc. - */ -#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.tweak[TWK_NUM]) -#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ - (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \ - } - -#define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) -#define skein_get_T1(ctx_ptr) skein_get_tweak(ctx_ptr, 1) -#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0) -#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1) - -/* set both tweak words at once */ -#define skein_set_T0_T1(ctx_ptr, T0, T1) \ - { \ - skein_set_T0(ctx_ptr, (T0)); \ - skein_set_T1(ctx_ptr, (T1)); \ - } - -#define skein_set_type(ctx_ptr, BLK_TYPE) \ - skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) - -/* - * setup for starting with a new type: - * h.tweak[0]=0; h.tweak[1] = NEW_TYPE; h.b_cnt=0; - */ -#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ - skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ - SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ - (ctx_ptr)->h.b_cnt = 0; \ - } - -#define skein_clear_first_flag(hdr) { \ - (hdr).tweak[1] &= ~SKEIN_T1_FLAG_FIRST; \ - } -#define skein_set_bit_pad_flag(hdr) { \ - (hdr).tweak[1] |= SKEIN_T1_FLAG_BIT_PAD; \ - } - -#define skein_set_tree_level(hdr, height) { \ - (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \ - } - -/* ignore all asserts, for performance */ -#define skein_assert_ret(x, ret_code) -#define skein_assert(x) - -/* - ***************************************************************** - * Skein block function constants (shared across Ref and Opt code) - ***************************************************************** - */ -enum { - /* SKEIN_256 round rotation constants */ - R_256_0_0 = 14, R_256_0_1 = 16, - R_256_1_0 = 52, R_256_1_1 = 57, - R_256_2_0 = 23, R_256_2_1 = 40, - R_256_3_0 = 5, R_256_3_1 = 37, - R_256_4_0 = 25, R_256_4_1 = 33, - R_256_5_0 = 46, R_256_5_1 = 12, - R_256_6_0 = 58, R_256_6_1 = 22, - R_256_7_0 = 32, R_256_7_1 = 32, - - /* SKEIN_512 round rotation constants */ - R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, - R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, - R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, - R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, - R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, - R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, - R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, - R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, - - /* SKEIN_1024 round rotation constants */ - R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, - R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, - R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, - R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, - R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, - R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, - R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, - R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, - R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, - R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, - R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, - R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, - R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, - R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, - R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, - R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 -}; - -#ifndef SKEIN_ROUNDS -#define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ -#define SKEIN_512_ROUNDS_TOTAL (72) -#define SKEIN_1024_ROUNDS_TOTAL (80) -#else /* allow command-line define in range 8*(5..14) */ -#define SKEIN_256_ROUNDS_TOTAL (8 * ((((SKEIN_ROUNDS / 100) + 5) % 10) + 5)) -#define SKEIN_512_ROUNDS_TOTAL (8 * ((((SKEIN_ROUNDS / 10) + 5) % 10) + 5)) -#define SKEIN_1024_ROUNDS_TOTAL (8 * ((((SKEIN_ROUNDS) + 5) % 10) + 5)) -#endif - -#endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c deleted file mode 100644 index 3bc25e149034..000000000000 --- a/drivers/staging/skein/skein_block.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - *********************************************************************** - * - * Implementation of the Skein block functions. - * - * Source code author: Doug Whiting, 2008. - * - * This algorithm and source code is released to the public domain. - * - * Compile-time switches: - * - * SKEIN_USE_ASM -- set bits (256/512/1024) to select which - * versions use ASM code for block processing - * [default: use C for all block sizes] - * - *********************************************************************** - */ - -#include -#include -#include "skein_base.h" -#include "skein_block.h" - -/***************************** SKEIN_256 ******************************/ -#if !(SKEIN_USE_ASM & 256) -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add) -{ /* do it in C */ - enum { - WCNT = SKEIN_256_STATE_WORDS - }; - size_t r; -#if SKEIN_UNROLL_256 - /* key schedule: chaining vars + tweak + "rot"*/ - u64 kw[WCNT + 4 + (RCNT * 2)]; -#else - /* key schedule words : chaining vars + tweak */ - u64 kw[WCNT + 4]; -#endif - u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ - u64 w[WCNT]; /* local copy of input block */ -#ifdef SKEIN_DEBUG - const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */ - - X_ptr[0] = &X0; - X_ptr[1] = &X1; - X_ptr[2] = &X2; - X_ptr[3] = &X3; -#endif - skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - ts[0] = ctx->h.tweak[0]; - ts[1] = ctx->h.tweak[1]; - do { - /* - * this implementation only supports 2**64 input bytes - * (no carry out here) - */ - ts[0] += byte_cnt_add; /* update processed length */ - - /* precompute the key schedule for this block */ - ks[0] = ctx->x[0]; - ks[1] = ctx->x[1]; - ks[2] = ctx->x[2]; - ks[3] = ctx->x[3]; - ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; - - ts[2] = ts[0] ^ ts[1]; - - /* get input block in little-endian format */ - skein_get64_lsb_first(w, blk_ptr, WCNT); - debug_save_tweak(ctx); - - /* do the first full key injection */ - X0 = w[0] + ks[0]; - X1 = w[1] + ks[1] + ts[0]; - X2 = w[2] + ks[2] + ts[1]; - X3 = w[3] + ks[3]; - - blk_ptr += SKEIN_256_BLOCK_BYTES; - - /* run the rounds */ - for (r = 1; - r < (SKEIN_UNROLL_256 ? 2 * RCNT : 2); - r += (SKEIN_UNROLL_256 ? 2 * SKEIN_UNROLL_256 : 1)) { - R256_8_ROUNDS(0); -#if R256_UNROLL_R(1) - R256_8_ROUNDS(1); -#endif -#if R256_UNROLL_R(2) - R256_8_ROUNDS(2); -#endif -#if R256_UNROLL_R(3) - R256_8_ROUNDS(3); -#endif -#if R256_UNROLL_R(4) - R256_8_ROUNDS(4); -#endif -#if R256_UNROLL_R(5) - R256_8_ROUNDS(5); -#endif -#if R256_UNROLL_R(6) - R256_8_ROUNDS(6); -#endif -#if R256_UNROLL_R(7) - R256_8_ROUNDS(7); -#endif -#if R256_UNROLL_R(8) - R256_8_ROUNDS(8); -#endif -#if R256_UNROLL_R(9) - R256_8_ROUNDS(9); -#endif -#if R256_UNROLL_R(10) - R256_8_ROUNDS(10); -#endif -#if R256_UNROLL_R(11) - R256_8_ROUNDS(11); -#endif -#if R256_UNROLL_R(12) - R256_8_ROUNDS(12); -#endif -#if R256_UNROLL_R(13) - R256_8_ROUNDS(13); -#endif -#if R256_UNROLL_R(14) - R256_8_ROUNDS(14); -#endif - } - /* do the final "feedforward" xor, update context chaining */ - ctx->x[0] = X0 ^ w[0]; - ctx->x[1] = X1 ^ w[1]; - ctx->x[2] = X2 ^ w[2]; - ctx->x[3] = X3 ^ w[3]; - - ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blk_cnt); - ctx->h.tweak[0] = ts[0]; - ctx->h.tweak[1] = ts[1]; -} - -#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -size_t skein_256_process_block_code_size(void) -{ - return ((u8 *)skein_256_process_block_code_size) - - ((u8 *)skein_256_process_block); -} - -unsigned int skein_256_unroll_cnt(void) -{ - return SKEIN_UNROLL_256; -} -#endif -#endif - -/***************************** SKEIN_512 ******************************/ -#if !(SKEIN_USE_ASM & 512) -void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add) -{ /* do it in C */ - enum { - WCNT = SKEIN_512_STATE_WORDS - }; - size_t r; -#if SKEIN_UNROLL_512 - /* key sched: chaining vars + tweak + "rot"*/ - u64 kw[WCNT + 4 + RCNT * 2]; -#else - /* key schedule words : chaining vars + tweak */ - u64 kw[WCNT + 4]; -#endif - u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copies, for speed */ - u64 w[WCNT]; /* local copy of input block */ -#ifdef SKEIN_DEBUG - const u64 *X_ptr[8]; /* use for debugging (help cc put Xn in regs) */ - - X_ptr[0] = &X0; - X_ptr[1] = &X1; - X_ptr[2] = &X2; - X_ptr[3] = &X3; - X_ptr[4] = &X4; - X_ptr[5] = &X5; - X_ptr[6] = &X6; - X_ptr[7] = &X7; -#endif - - skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - ts[0] = ctx->h.tweak[0]; - ts[1] = ctx->h.tweak[1]; - do { - /* - * this implementation only supports 2**64 input bytes - * (no carry out here) - */ - ts[0] += byte_cnt_add; /* update processed length */ - - /* precompute the key schedule for this block */ - ks[0] = ctx->x[0]; - ks[1] = ctx->x[1]; - ks[2] = ctx->x[2]; - ks[3] = ctx->x[3]; - ks[4] = ctx->x[4]; - ks[5] = ctx->x[5]; - ks[6] = ctx->x[6]; - ks[7] = ctx->x[7]; - ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ - ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; - - ts[2] = ts[0] ^ ts[1]; - - /* get input block in little-endian format */ - skein_get64_lsb_first(w, blk_ptr, WCNT); - debug_save_tweak(ctx); - - /* do the first full key injection */ - X0 = w[0] + ks[0]; - X1 = w[1] + ks[1]; - X2 = w[2] + ks[2]; - X3 = w[3] + ks[3]; - X4 = w[4] + ks[4]; - X5 = w[5] + ks[5] + ts[0]; - X6 = w[6] + ks[6] + ts[1]; - X7 = w[7] + ks[7]; - - blk_ptr += SKEIN_512_BLOCK_BYTES; - - /* run the rounds */ - for (r = 1; - r < (SKEIN_UNROLL_512 ? 2 * RCNT : 2); - r += (SKEIN_UNROLL_512 ? 2 * SKEIN_UNROLL_512 : 1)) { - R512_8_ROUNDS(0); - -#if R512_UNROLL_R(1) - R512_8_ROUNDS(1); -#endif -#if R512_UNROLL_R(2) - R512_8_ROUNDS(2); -#endif -#if R512_UNROLL_R(3) - R512_8_ROUNDS(3); -#endif -#if R512_UNROLL_R(4) - R512_8_ROUNDS(4); -#endif -#if R512_UNROLL_R(5) - R512_8_ROUNDS(5); -#endif -#if R512_UNROLL_R(6) - R512_8_ROUNDS(6); -#endif -#if R512_UNROLL_R(7) - R512_8_ROUNDS(7); -#endif -#if R512_UNROLL_R(8) - R512_8_ROUNDS(8); -#endif -#if R512_UNROLL_R(9) - R512_8_ROUNDS(9); -#endif -#if R512_UNROLL_R(10) - R512_8_ROUNDS(10); -#endif -#if R512_UNROLL_R(11) - R512_8_ROUNDS(11); -#endif -#if R512_UNROLL_R(12) - R512_8_ROUNDS(12); -#endif -#if R512_UNROLL_R(13) - R512_8_ROUNDS(13); -#endif -#if R512_UNROLL_R(14) - R512_8_ROUNDS(14); -#endif - } - - /* do the final "feedforward" xor, update context chaining */ - ctx->x[0] = X0 ^ w[0]; - ctx->x[1] = X1 ^ w[1]; - ctx->x[2] = X2 ^ w[2]; - ctx->x[3] = X3 ^ w[3]; - ctx->x[4] = X4 ^ w[4]; - ctx->x[5] = X5 ^ w[5]; - ctx->x[6] = X6 ^ w[6]; - ctx->x[7] = X7 ^ w[7]; - - ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blk_cnt); - ctx->h.tweak[0] = ts[0]; - ctx->h.tweak[1] = ts[1]; -} - -#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -size_t skein_512_process_block_code_size(void) -{ - return ((u8 *)skein_512_process_block_code_size) - - ((u8 *)skein_512_process_block); -} - -unsigned int skein_512_unroll_cnt(void) -{ - return SKEIN_UNROLL_512; -} -#endif -#endif - -/***************************** SKEIN_1024 ******************************/ -#if !(SKEIN_USE_ASM & 1024) -void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add) -{ /* do it in C, always looping (unrolled is bigger AND slower!) */ - enum { - WCNT = SKEIN_1024_STATE_WORDS - }; - size_t r; -#if (SKEIN_UNROLL_1024 != 0) - /* key sched: chaining vars + tweak + "rot" */ - u64 kw[WCNT + 4 + (RCNT * 2)]; -#else - /* key schedule words : chaining vars + tweak */ - u64 kw[WCNT + 4]; -#endif - - /* local copy of vars, for speed */ - u64 X00, X01, X02, X03, X04, X05, X06, X07, - X08, X09, X10, X11, X12, X13, X14, X15; - u64 w[WCNT]; /* local copy of input block */ - - skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - ts[0] = ctx->h.tweak[0]; - ts[1] = ctx->h.tweak[1]; - do { - /* - * this implementation only supports 2**64 input bytes - * (no carry out here) - */ - ts[0] += byte_cnt_add; /* update processed length */ - - /* precompute the key schedule for this block */ - ks[0] = ctx->x[0]; - ks[1] = ctx->x[1]; - ks[2] = ctx->x[2]; - ks[3] = ctx->x[3]; - ks[4] = ctx->x[4]; - ks[5] = ctx->x[5]; - ks[6] = ctx->x[6]; - ks[7] = ctx->x[7]; - ks[8] = ctx->x[8]; - ks[9] = ctx->x[9]; - ks[10] = ctx->x[10]; - ks[11] = ctx->x[11]; - ks[12] = ctx->x[12]; - ks[13] = ctx->x[13]; - ks[14] = ctx->x[14]; - ks[15] = ctx->x[15]; - ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ - ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ - ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ - ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ SKEIN_KS_PARITY; - - ts[2] = ts[0] ^ ts[1]; - - /* get input block in little-endian format */ - skein_get64_lsb_first(w, blk_ptr, WCNT); - debug_save_tweak(ctx); - - /* do the first full key injection */ - X00 = w[0] + ks[0]; - X01 = w[1] + ks[1]; - X02 = w[2] + ks[2]; - X03 = w[3] + ks[3]; - X04 = w[4] + ks[4]; - X05 = w[5] + ks[5]; - X06 = w[6] + ks[6]; - X07 = w[7] + ks[7]; - X08 = w[8] + ks[8]; - X09 = w[9] + ks[9]; - X10 = w[10] + ks[10]; - X11 = w[11] + ks[11]; - X12 = w[12] + ks[12]; - X13 = w[13] + ks[13] + ts[0]; - X14 = w[14] + ks[14] + ts[1]; - X15 = w[15] + ks[15]; - - for (r = 1; - r < (SKEIN_UNROLL_1024 ? 2 * RCNT : 2); - r += (SKEIN_UNROLL_1024 ? 2 * SKEIN_UNROLL_1024 : 1)) { - R1024_8_ROUNDS(0); -#if R1024_UNROLL_R(1) - R1024_8_ROUNDS(1); -#endif -#if R1024_UNROLL_R(2) - R1024_8_ROUNDS(2); -#endif -#if R1024_UNROLL_R(3) - R1024_8_ROUNDS(3); -#endif -#if R1024_UNROLL_R(4) - R1024_8_ROUNDS(4); -#endif -#if R1024_UNROLL_R(5) - R1024_8_ROUNDS(5); -#endif -#if R1024_UNROLL_R(6) - R1024_8_ROUNDS(6); -#endif -#if R1024_UNROLL_R(7) - R1024_8_ROUNDS(7); -#endif -#if R1024_UNROLL_R(8) - R1024_8_ROUNDS(8); -#endif -#if R1024_UNROLL_R(9) - R1024_8_ROUNDS(9); -#endif -#if R1024_UNROLL_R(10) - R1024_8_ROUNDS(10); -#endif -#if R1024_UNROLL_R(11) - R1024_8_ROUNDS(11); -#endif -#if R1024_UNROLL_R(12) - R1024_8_ROUNDS(12); -#endif -#if R1024_UNROLL_R(13) - R1024_8_ROUNDS(13); -#endif -#if R1024_UNROLL_R(14) - R1024_8_ROUNDS(14); -#endif - } - /* do the final "feedforward" xor, update context chaining */ - - ctx->x[0] = X00 ^ w[0]; - ctx->x[1] = X01 ^ w[1]; - ctx->x[2] = X02 ^ w[2]; - ctx->x[3] = X03 ^ w[3]; - ctx->x[4] = X04 ^ w[4]; - ctx->x[5] = X05 ^ w[5]; - ctx->x[6] = X06 ^ w[6]; - ctx->x[7] = X07 ^ w[7]; - ctx->x[8] = X08 ^ w[8]; - ctx->x[9] = X09 ^ w[9]; - ctx->x[10] = X10 ^ w[10]; - ctx->x[11] = X11 ^ w[11]; - ctx->x[12] = X12 ^ w[12]; - ctx->x[13] = X13 ^ w[13]; - ctx->x[14] = X14 ^ w[14]; - ctx->x[15] = X15 ^ w[15]; - - ts[1] &= ~SKEIN_T1_FLAG_FIRST; - blk_ptr += SKEIN_1024_BLOCK_BYTES; - } while (--blk_cnt); - ctx->h.tweak[0] = ts[0]; - ctx->h.tweak[1] = ts[1]; -} - -#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -size_t skein_1024_process_block_code_size(void) -{ - return ((u8 *)skein_1024_process_block_code_size) - - ((u8 *)skein_1024_process_block); -} - -unsigned int skein_1024_unroll_cnt(void) -{ - return SKEIN_UNROLL_1024; -} -#endif -#endif diff --git a/drivers/staging/skein/skein_block.h b/drivers/staging/skein/skein_block.h deleted file mode 100644 index b3bb3d24273b..000000000000 --- a/drivers/staging/skein/skein_block.h +++ /dev/null @@ -1,347 +0,0 @@ -/* - *********************************************************************** - * - * Implementation of the Skein hash function. - * - * Source code author: Doug Whiting, 2008. - * - * This algorithm and source code is released to the public domain. - * - *********************************************************************** - */ -#ifndef _SKEIN_BLOCK_H_ -#define _SKEIN_BLOCK_H_ - -#include "skein_base.h" /* get the Skein API definitions */ - -#ifndef SKEIN_USE_ASM -#define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ -#endif - -#ifndef SKEIN_LOOP -#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ -#endif - -#define BLK_BITS (WCNT * 64) /* some useful definitions for code here */ -#define KW_TWK_BASE (0) -#define KW_KEY_BASE (3) -#define ks (kw + KW_KEY_BASE) -#define ts (kw + KW_TWK_BASE) - -#ifdef SKEIN_DEBUG -#define debug_save_tweak(ctx) \ -{ \ - ctx->h.tweak[0] = ts[0]; \ - ctx->h.tweak[1] = ts[1]; \ -} -#else -#define debug_save_tweak(ctx) -#endif - -#if !(SKEIN_USE_ASM & 256) -#undef RCNT -#define RCNT (SKEIN_256_ROUNDS_TOTAL / 8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ -#define SKEIN_UNROLL_256 (((SKEIN_LOOP) / 100) % 10) -#else -#define SKEIN_UNROLL_256 (0) -#endif - -#if SKEIN_UNROLL_256 -#if (RCNT % SKEIN_UNROLL_256) -#error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */ -#endif -#endif -#define ROUND256(p0, p1, p2, p3, ROT, r_num) \ - do { \ - X##p0 += X##p1; \ - X##p1 = rol64(X##p1, ROT##_0); \ - X##p1 ^= X##p0; \ - X##p2 += X##p3; \ - X##p3 = rol64(X##p3, ROT##_1); \ - X##p3 ^= X##p2; \ - } while (0) - -#if SKEIN_UNROLL_256 == 0 -#define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \ - ROUND256(p0, p1, p2, p3, ROT, r_num) - -#define I256(R) \ - do { \ - /* inject the key schedule value */ \ - X0 += ks[((R) + 1) % 5]; \ - X1 += ks[((R) + 2) % 5] + ts[((R) + 1) % 3]; \ - X2 += ks[((R) + 3) % 5] + ts[((R) + 2) % 3]; \ - X3 += ks[((R) + 4) % 5] + (R) + 1; \ - } while (0) -#else -/* looping version */ -#define R256(p0, p1, p2, p3, ROT, r_num) ROUND256(p0, p1, p2, p3, ROT, r_num) - -#define I256(R) \ - do { \ - /* inject the key schedule value */ \ - X0 += ks[r + (R) + 0]; \ - X1 += ks[r + (R) + 1] + ts[r + (R) + 0];\ - X2 += ks[r + (R) + 2] + ts[r + (R) + 1];\ - X3 += ks[r + (R) + 3] + r + (R); \ - /* rotate key schedule */ \ - ks[r + (R) + 4] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - } while (0) -#endif -#define R256_8_ROUNDS(R) \ - do { \ - R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ - R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ - R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3); \ - R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4); \ - I256(2 * (R)); \ - R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5); \ - R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6); \ - R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7); \ - R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8); \ - I256(2 * (R) + 1); \ - } while (0) - -#define R256_UNROLL_R(NN) \ - ((SKEIN_UNROLL_256 == 0 && \ - SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \ - (SKEIN_UNROLL_256 > (NN))) - -#if (SKEIN_UNROLL_256 > 14) -#error "need more unrolling in skein_256_process_block" -#endif -#endif - -#if !(SKEIN_USE_ASM & 512) -#undef RCNT -#define RCNT (SKEIN_512_ROUNDS_TOTAL / 8) - -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ -#define SKEIN_UNROLL_512 (((SKEIN_LOOP) / 10) % 10) -#else -#define SKEIN_UNROLL_512 (0) -#endif - -#if SKEIN_UNROLL_512 -#if (RCNT % SKEIN_UNROLL_512) -#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ -#endif -#endif -#define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ - do { \ - X##p0 += X##p1; \ - X##p1 = rol64(X##p1, ROT##_0); \ - X##p1 ^= X##p0; \ - X##p2 += X##p3; \ - X##p3 = rol64(X##p3, ROT##_1); \ - X##p3 ^= X##p2; \ - X##p4 += X##p5; \ - X##p5 = rol64(X##p5, ROT##_2); \ - X##p5 ^= X##p4; \ - X##p6 += X##p7; \ - X##p7 = rol64(X##p7, ROT##_3); \ - X##p7 ^= X##p6; \ - } while (0) - -#if SKEIN_UNROLL_512 == 0 -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \ - ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) - -#define I512(R) \ - do { \ - /* inject the key schedule value */ \ - X0 += ks[((R) + 1) % 9]; \ - X1 += ks[((R) + 2) % 9]; \ - X2 += ks[((R) + 3) % 9]; \ - X3 += ks[((R) + 4) % 9]; \ - X4 += ks[((R) + 5) % 9]; \ - X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ - X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ - X7 += ks[((R) + 8) % 9] + (R) + 1; \ - } while (0) - -#else /* looping version */ -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ - ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ - -#define I512(R) \ - do { \ - /* inject the key schedule value */ \ - X0 += ks[r + (R) + 0]; \ - X1 += ks[r + (R) + 1]; \ - X2 += ks[r + (R) + 2]; \ - X3 += ks[r + (R) + 3]; \ - X4 += ks[r + (R) + 4]; \ - X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ - X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ - X7 += ks[r + (R) + 7] + r + (R); \ - /* rotate key schedule */ \ - ks[r + (R) + 8] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - } while (0) -#endif /* end of looped code definitions */ -#define R512_8_ROUNDS(R) /* do 8 full rounds */ \ - do { \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ - I512(2 * (R)); \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ - I512(2 * (R) + 1); /* and key injection */ \ - } while (0) -#define R512_UNROLL_R(NN) \ - ((SKEIN_UNROLL_512 == 0 && \ - SKEIN_512_ROUNDS_TOTAL / 8 > (NN)) || \ - (SKEIN_UNROLL_512 > (NN))) - -#if (SKEIN_UNROLL_512 > 14) -#error "need more unrolling in skein_512_process_block" -#endif -#endif - -#if !(SKEIN_USE_ASM & 1024) -#undef RCNT -#define RCNT (SKEIN_1024_ROUNDS_TOTAL / 8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ -#define SKEIN_UNROLL_1024 ((SKEIN_LOOP) % 10) -#else -#define SKEIN_UNROLL_1024 (0) -#endif - -#if (SKEIN_UNROLL_1024 != 0) -#if (RCNT % SKEIN_UNROLL_1024) -#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ -#endif -#endif -#define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, r_num) \ - do { \ - X##p0 += X##p1; \ - X##p1 = rol64(X##p1, ROT##_0); \ - X##p1 ^= X##p0; \ - X##p2 += X##p3; \ - X##p3 = rol64(X##p3, ROT##_1); \ - X##p3 ^= X##p2; \ - X##p4 += X##p5; \ - X##p5 = rol64(X##p5, ROT##_2); \ - X##p5 ^= X##p4; \ - X##p6 += X##p7; \ - X##p7 = rol64(X##p7, ROT##_3); \ - X##p7 ^= X##p6; \ - X##p8 += X##p9; \ - X##p9 = rol64(X##p9, ROT##_4); \ - X##p9 ^= X##p8; \ - X##pA += X##pB; \ - X##pB = rol64(X##pB, ROT##_5); \ - X##pB ^= X##pA; \ - X##pC += X##pD; \ - X##pD = rol64(X##pD, ROT##_6); \ - X##pD ^= X##pC; \ - X##pE += X##pF; \ - X##pF = rol64(X##pF, ROT##_7); \ - X##pF ^= X##pE; \ - } while (0) - -#if SKEIN_UNROLL_1024 == 0 -#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ - ROT, rn) \ - ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn) \ - -#define I1024(R) \ - do { \ - /* inject the key schedule value */ \ - X00 += ks[((R) + 1) % 17]; \ - X01 += ks[((R) + 2) % 17]; \ - X02 += ks[((R) + 3) % 17]; \ - X03 += ks[((R) + 4) % 17]; \ - X04 += ks[((R) + 5) % 17]; \ - X05 += ks[((R) + 6) % 17]; \ - X06 += ks[((R) + 7) % 17]; \ - X07 += ks[((R) + 8) % 17]; \ - X08 += ks[((R) + 9) % 17]; \ - X09 += ks[((R) + 10) % 17]; \ - X10 += ks[((R) + 11) % 17]; \ - X11 += ks[((R) + 12) % 17]; \ - X12 += ks[((R) + 13) % 17]; \ - X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ - X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ - X15 += ks[((R) + 16) % 17] + (R) + 1; \ - } while (0) -#else /* looping version */ -#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ - ROT, rn) \ - ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn) \ - -#define I1024(R) \ - do { \ - /* inject the key schedule value */ \ - X00 += ks[r + (R) + 0]; \ - X01 += ks[r + (R) + 1]; \ - X02 += ks[r + (R) + 2]; \ - X03 += ks[r + (R) + 3]; \ - X04 += ks[r + (R) + 4]; \ - X05 += ks[r + (R) + 5]; \ - X06 += ks[r + (R) + 6]; \ - X07 += ks[r + (R) + 7]; \ - X08 += ks[r + (R) + 8]; \ - X09 += ks[r + (R) + 9]; \ - X10 += ks[r + (R) + 10]; \ - X11 += ks[r + (R) + 11]; \ - X12 += ks[r + (R) + 12]; \ - X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ - X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ - X15 += ks[r + (R) + 15] + r + (R); \ - /* rotate key schedule */ \ - ks[r + (R) + 16] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - } while (0) - -#endif -#define R1024_8_ROUNDS(R) \ - do { \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, \ - 13, 14, 15, R1024_0, 8 * (R) + 1); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, \ - 05, 08, 01, R1024_1, 8 * (R) + 2); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, \ - 11, 10, 09, R1024_2, 8 * (R) + 3); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, \ - 03, 12, 07, R1024_3, 8 * (R) + 4); \ - I1024(2 * (R)); \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, \ - 13, 14, 15, R1024_4, 8 * (R) + 5); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, \ - 05, 08, 01, R1024_5, 8 * (R) + 6); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, \ - 11, 10, 09, R1024_6, 8 * (R) + 7); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, \ - 03, 12, 07, R1024_7, 8 * (R) + 8); \ - I1024(2 * (R) + 1); \ - } while (0) - -#define R1024_UNROLL_R(NN) \ - ((SKEIN_UNROLL_1024 == 0 && \ - SKEIN_1024_ROUNDS_TOTAL / 8 > (NN)) || \ - (SKEIN_UNROLL_1024 > (NN))) - -#if (SKEIN_UNROLL_1024 > 14) -#error "need more unrolling in Skein_1024_Process_Block" -#endif -#endif - -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add); -void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add); -void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add); - -#endif diff --git a/drivers/staging/skein/skein_generic.c b/drivers/staging/skein/skein_generic.c deleted file mode 100644 index 11f5e530a75f..000000000000 --- a/drivers/staging/skein/skein_generic.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Cryptographic API. - * - * Skein256 Hash Algorithm. - * - * Derived from cryptoapi implementation, adapted for in-place - * scatterlist interface. - * - * Copyright (c) Eric Rost - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - */ -#include -#include -#include -#include -#include "skein_base.h" - -static int skein256_init(struct shash_desc *desc) -{ - return skein_256_init((struct skein_256_ctx *)shash_desc_ctx(desc), - SKEIN256_DIGEST_BIT_SIZE); -} - -static int skein256_update(struct shash_desc *desc, const u8 *data, - unsigned int len) -{ - return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc), - data, len); -} - -static int skein256_final(struct shash_desc *desc, u8 *out) -{ - return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc), - out); -} - -static int skein256_export(struct shash_desc *desc, void *out) -{ - struct skein_256_ctx *sctx = shash_desc_ctx(desc); - - memcpy(out, sctx, sizeof(*sctx)); - return 0; -} - -static int skein256_import(struct shash_desc *desc, const void *in) -{ - struct skein_256_ctx *sctx = shash_desc_ctx(desc); - - memcpy(sctx, in, sizeof(*sctx)); - return 0; -} - -static int skein512_init(struct shash_desc *desc) -{ - return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc), - SKEIN512_DIGEST_BIT_SIZE); -} - -static int skein512_update(struct shash_desc *desc, const u8 *data, - unsigned int len) -{ - return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc), - data, len); -} - -static int skein512_final(struct shash_desc *desc, u8 *out) -{ - return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc), - out); -} - -static int skein512_export(struct shash_desc *desc, void *out) -{ - struct skein_512_ctx *sctx = shash_desc_ctx(desc); - - memcpy(out, sctx, sizeof(*sctx)); - return 0; -} - -static int skein512_import(struct shash_desc *desc, const void *in) -{ - struct skein_512_ctx *sctx = shash_desc_ctx(desc); - - memcpy(sctx, in, sizeof(*sctx)); - return 0; -} - -static int skein1024_init(struct shash_desc *desc) -{ - return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc), - SKEIN1024_DIGEST_BIT_SIZE); -} - -static int skein1024_update(struct shash_desc *desc, const u8 *data, - unsigned int len) -{ - return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc), - data, len); -} - -static int skein1024_final(struct shash_desc *desc, u8 *out) -{ - return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc), - out); -} - -static int skein1024_export(struct shash_desc *desc, void *out) -{ - struct skein_1024_ctx *sctx = shash_desc_ctx(desc); - - memcpy(out, sctx, sizeof(*sctx)); - return 0; -} - -static int skein1024_import(struct shash_desc *desc, const void *in) -{ - struct skein_1024_ctx *sctx = shash_desc_ctx(desc); - - memcpy(sctx, in, sizeof(*sctx)); - return 0; -} - -static struct shash_alg alg256 = { - .digestsize = (SKEIN256_DIGEST_BIT_SIZE / 8), - .init = skein256_init, - .update = skein256_update, - .final = skein256_final, - .export = skein256_export, - .import = skein256_import, - .descsize = sizeof(struct skein_256_ctx), - .statesize = sizeof(struct skein_256_ctx), - .base = { - .cra_name = "skein256", - .cra_driver_name = "skein", - .cra_flags = CRYPTO_ALG_TYPE_SHASH, - .cra_blocksize = SKEIN_256_BLOCK_BYTES, - .cra_module = THIS_MODULE, - } -}; - -static struct shash_alg alg512 = { - .digestsize = (SKEIN512_DIGEST_BIT_SIZE / 8), - .init = skein512_init, - .update = skein512_update, - .final = skein512_final, - .export = skein512_export, - .import = skein512_import, - .descsize = sizeof(struct skein_512_ctx), - .statesize = sizeof(struct skein_512_ctx), - .base = { - .cra_name = "skein512", - .cra_driver_name = "skein", - .cra_flags = CRYPTO_ALG_TYPE_SHASH, - .cra_blocksize = SKEIN_512_BLOCK_BYTES, - .cra_module = THIS_MODULE, - } -}; - -static struct shash_alg alg1024 = { - .digestsize = (SKEIN1024_DIGEST_BIT_SIZE / 8), - .init = skein1024_init, - .update = skein1024_update, - .final = skein1024_final, - .export = skein1024_export, - .import = skein1024_import, - .descsize = sizeof(struct skein_1024_ctx), - .statesize = sizeof(struct skein_1024_ctx), - .base = { - .cra_name = "skein1024", - .cra_driver_name = "skein", - .cra_flags = CRYPTO_ALG_TYPE_SHASH, - .cra_blocksize = SKEIN_1024_BLOCK_BYTES, - .cra_module = THIS_MODULE, - } -}; - -static int __init skein_generic_init(void) -{ - if (crypto_register_shash(&alg256)) - goto out; - if (crypto_register_shash(&alg512)) - goto unreg256; - if (crypto_register_shash(&alg1024)) - goto unreg512; - - return 0; - -unreg512: - crypto_unregister_shash(&alg512); -unreg256: - crypto_unregister_shash(&alg256); -out: - return -1; -} - -static void __exit skein_generic_fini(void) -{ - crypto_unregister_shash(&alg256); - crypto_unregister_shash(&alg512); - crypto_unregister_shash(&alg1024); -} - -module_init(skein_generic_init); -module_exit(skein_generic_fini); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Skein Hash Algorithm"); - -MODULE_ALIAS("skein"); diff --git a/drivers/staging/skein/skein_iv.h b/drivers/staging/skein/skein_iv.h deleted file mode 100644 index 916f029da726..000000000000 --- a/drivers/staging/skein/skein_iv.h +++ /dev/null @@ -1,187 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _SKEIN_IV_H_ -#define _SKEIN_IV_H_ - -#include "skein_base.h" /* get Skein macros and types */ - -/* - **************** Pre-computed Skein IVs ******************* - * - * NOTE: these values are not "magic" constants, but - * are generated using the Threefish block function. - * They are pre-computed here only for speed; i.e., to - * avoid the need for a Threefish call during Init(). - * - * The IV for any fixed hash length may be pre-computed. - * Only the most common values are included here. - * - *********************************************************** - */ - -#define MK_64 SKEIN_MK_64 - -/* blkSize = 256 bits. hashSize = 128 bits */ -static const u64 SKEIN_256_IV_128[] = { - MK_64(0xE1111906, 0x964D7260), - MK_64(0x883DAAA7, 0x7C8D811C), - MK_64(0x10080DF4, 0x91960F7A), - MK_64(0xCCF7DDE5, 0xB45BC1C2) -}; - -/* blkSize = 256 bits. hashSize = 160 bits */ -static const u64 SKEIN_256_IV_160[] = { - MK_64(0x14202314, 0x72825E98), - MK_64(0x2AC4E9A2, 0x5A77E590), - MK_64(0xD47A5856, 0x8838D63E), - MK_64(0x2DD2E496, 0x8586AB7D) -}; - -/* blkSize = 256 bits. hashSize = 224 bits */ -static const u64 SKEIN_256_IV_224[] = { - MK_64(0xC6098A8C, 0x9AE5EA0B), - MK_64(0x876D5686, 0x08C5191C), - MK_64(0x99CB88D7, 0xD7F53884), - MK_64(0x384BDDB1, 0xAEDDB5DE) -}; - -/* blkSize = 256 bits. hashSize = 256 bits */ -static const u64 SKEIN_256_IV_256[] = { - MK_64(0xFC9DA860, 0xD048B449), - MK_64(0x2FCA6647, 0x9FA7D833), - MK_64(0xB33BC389, 0x6656840F), - MK_64(0x6A54E920, 0xFDE8DA69) -}; - -/* blkSize = 512 bits. hashSize = 128 bits */ -static const u64 SKEIN_512_IV_128[] = { - MK_64(0xA8BC7BF3, 0x6FBF9F52), - MK_64(0x1E9872CE, 0xBD1AF0AA), - MK_64(0x309B1790, 0xB32190D3), - MK_64(0xBCFBB854, 0x3F94805C), - MK_64(0x0DA61BCD, 0x6E31B11B), - MK_64(0x1A18EBEA, 0xD46A32E3), - MK_64(0xA2CC5B18, 0xCE84AA82), - MK_64(0x6982AB28, 0x9D46982D) -}; - -/* blkSize = 512 bits. hashSize = 160 bits */ -static const u64 SKEIN_512_IV_160[] = { - MK_64(0x28B81A2A, 0xE013BD91), - MK_64(0xC2F11668, 0xB5BDF78F), - MK_64(0x1760D8F3, 0xF6A56F12), - MK_64(0x4FB74758, 0x8239904F), - MK_64(0x21EDE07F, 0x7EAF5056), - MK_64(0xD908922E, 0x63ED70B8), - MK_64(0xB8EC76FF, 0xECCB52FA), - MK_64(0x01A47BB8, 0xA3F27A6E) -}; - -/* blkSize = 512 bits. hashSize = 224 bits */ -static const u64 SKEIN_512_IV_224[] = { - MK_64(0xCCD06162, 0x48677224), - MK_64(0xCBA65CF3, 0xA92339EF), - MK_64(0x8CCD69D6, 0x52FF4B64), - MK_64(0x398AED7B, 0x3AB890B4), - MK_64(0x0F59D1B1, 0x457D2BD0), - MK_64(0x6776FE65, 0x75D4EB3D), - MK_64(0x99FBC70E, 0x997413E9), - MK_64(0x9E2CFCCF, 0xE1C41EF7) -}; - -/* blkSize = 512 bits. hashSize = 256 bits */ -static const u64 SKEIN_512_IV_256[] = { - MK_64(0xCCD044A1, 0x2FDB3E13), - MK_64(0xE8359030, 0x1A79A9EB), - MK_64(0x55AEA061, 0x4F816E6F), - MK_64(0x2A2767A4, 0xAE9B94DB), - MK_64(0xEC06025E, 0x74DD7683), - MK_64(0xE7A436CD, 0xC4746251), - MK_64(0xC36FBAF9, 0x393AD185), - MK_64(0x3EEDBA18, 0x33EDFC13) -}; - -/* blkSize = 512 bits. hashSize = 384 bits */ -static const u64 SKEIN_512_IV_384[] = { - MK_64(0xA3F6C6BF, 0x3A75EF5F), - MK_64(0xB0FEF9CC, 0xFD84FAA4), - MK_64(0x9D77DD66, 0x3D770CFE), - MK_64(0xD798CBF3, 0xB468FDDA), - MK_64(0x1BC4A666, 0x8A0E4465), - MK_64(0x7ED7D434, 0xE5807407), - MK_64(0x548FC1AC, 0xD4EC44D6), - MK_64(0x266E1754, 0x6AA18FF8) -}; - -/* blkSize = 512 bits. hashSize = 512 bits */ -static const u64 SKEIN_512_IV_512[] = { - MK_64(0x4903ADFF, 0x749C51CE), - MK_64(0x0D95DE39, 0x9746DF03), - MK_64(0x8FD19341, 0x27C79BCE), - MK_64(0x9A255629, 0xFF352CB1), - MK_64(0x5DB62599, 0xDF6CA7B0), - MK_64(0xEABE394C, 0xA9D5C3F4), - MK_64(0x991112C7, 0x1A75B523), - MK_64(0xAE18A40B, 0x660FCC33) -}; - -/* blkSize = 1024 bits. hashSize = 384 bits */ -static const u64 SKEIN_1024_IV_384[] = { - MK_64(0x5102B6B8, 0xC1894A35), - MK_64(0xFEEBC9E3, 0xFE8AF11A), - MK_64(0x0C807F06, 0xE32BED71), - MK_64(0x60C13A52, 0xB41A91F6), - MK_64(0x9716D35D, 0xD4917C38), - MK_64(0xE780DF12, 0x6FD31D3A), - MK_64(0x797846B6, 0xC898303A), - MK_64(0xB172C2A8, 0xB3572A3B), - MK_64(0xC9BC8203, 0xA6104A6C), - MK_64(0x65909338, 0xD75624F4), - MK_64(0x94BCC568, 0x4B3F81A0), - MK_64(0x3EBBF51E, 0x10ECFD46), - MK_64(0x2DF50F0B, 0xEEB08542), - MK_64(0x3B5A6530, 0x0DBC6516), - MK_64(0x484B9CD2, 0x167BBCE1), - MK_64(0x2D136947, 0xD4CBAFEA) -}; - -/* blkSize = 1024 bits. hashSize = 512 bits */ -static const u64 SKEIN_1024_IV_512[] = { - MK_64(0xCAEC0E5D, 0x7C1B1B18), - MK_64(0xA01B0E04, 0x5F03E802), - MK_64(0x33840451, 0xED912885), - MK_64(0x374AFB04, 0xEAEC2E1C), - MK_64(0xDF25A0E2, 0x813581F7), - MK_64(0xE4004093, 0x8B12F9D2), - MK_64(0xA662D539, 0xC2ED39B6), - MK_64(0xFA8B85CF, 0x45D8C75A), - MK_64(0x8316ED8E, 0x29EDE796), - MK_64(0x053289C0, 0x2E9F91B8), - MK_64(0xC3F8EF1D, 0x6D518B73), - MK_64(0xBDCEC3C4, 0xD5EF332E), - MK_64(0x549A7E52, 0x22974487), - MK_64(0x67070872, 0x5B749816), - MK_64(0xB9CD28FB, 0xF0581BD1), - MK_64(0x0E2940B8, 0x15804974) -}; - -/* blkSize = 1024 bits. hashSize = 1024 bits */ -static const u64 SKEIN_1024_IV_1024[] = { - MK_64(0xD593DA07, 0x41E72355), - MK_64(0x15B5E511, 0xAC73E00C), - MK_64(0x5180E5AE, 0xBAF2C4F0), - MK_64(0x03BD41D3, 0xFCBCAFAF), - MK_64(0x1CAEC6FD, 0x1983A898), - MK_64(0x6E510B8B, 0xCDD0589F), - MK_64(0x77E2BDFD, 0xC6394ADA), - MK_64(0xC11E1DB5, 0x24DCB0A3), - MK_64(0xD6D14AF9, 0xC6329AB5), - MK_64(0x6A9B0BFC, 0x6EB67E0D), - MK_64(0x9243C60D, 0xCCFF1332), - MK_64(0x1A1F1DDE, 0x743F02D4), - MK_64(0x0996753C, 0x10ED0BB8), - MK_64(0x6572DD22, 0xF2B4969A), - MK_64(0x61FD3062, 0xD00A579A), - MK_64(0x1DE0536E, 0x8682E539) -}; - -#endif /* _SKEIN_IV_H_ */ diff --git a/drivers/staging/skein/threefish_api.c b/drivers/staging/skein/threefish_api.c deleted file mode 100644 index e69cefa6b16a..000000000000 --- a/drivers/staging/skein/threefish_api.c +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include "threefish_api.h" - -void threefish_set_key(struct threefish_key *key_ctx, - enum threefish_size state_size, - u64 *key_data, u64 *tweak) -{ - int key_words = state_size / 64; - int i; - u64 parity = KEY_SCHEDULE_CONST; - - key_ctx->tweak[0] = tweak[0]; - key_ctx->tweak[1] = tweak[1]; - key_ctx->tweak[2] = tweak[0] ^ tweak[1]; - - for (i = 0; i < key_words; i++) { - key_ctx->key[i] = key_data[i]; - parity ^= key_data[i]; - } - key_ctx->key[i] = parity; - key_ctx->state_size = state_size; -} - -void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out) -{ - u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64 cipher[SKEIN_MAX_STATE_WORDS]; - - skein_get64_lsb_first(plain, in, key_ctx->state_size / 64); - threefish_encrypt_block_words(key_ctx, plain, cipher); - skein_put64_lsb_first(out, cipher, key_ctx->state_size / 8); -} - -void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out) -{ - switch (key_ctx->state_size) { - case THREEFISH_256: - threefish_encrypt_256(key_ctx, in, out); - break; - case THREEFISH_512: - threefish_encrypt_512(key_ctx, in, out); - break; - case THREEFISH_1024: - threefish_encrypt_1024(key_ctx, in, out); - break; - } -} - -void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out) -{ - u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64 cipher[SKEIN_MAX_STATE_WORDS]; - - skein_get64_lsb_first(cipher, in, key_ctx->state_size / 64); - threefish_decrypt_block_words(key_ctx, cipher, plain); - skein_put64_lsb_first(out, plain, key_ctx->state_size / 8); -} - -void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out) -{ - switch (key_ctx->state_size) { - case THREEFISH_256: - threefish_decrypt_256(key_ctx, in, out); - break; - case THREEFISH_512: - threefish_decrypt_512(key_ctx, in, out); - break; - case THREEFISH_1024: - threefish_decrypt_1024(key_ctx, in, out); - break; - } -} - diff --git a/drivers/staging/skein/threefish_api.h b/drivers/staging/skein/threefish_api.h deleted file mode 100644 index 21539c3cc7a0..000000000000 --- a/drivers/staging/skein/threefish_api.h +++ /dev/null @@ -1,171 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef THREEFISHAPI_H -#define THREEFISHAPI_H - -/** - * @file threefish_api.h - * @brief A Threefish cipher API and its functions. - * @{ - * - * This API and the functions that implement this API simplify the usage - * of the Threefish cipher. The design and the way to use the functions - * follow the openSSL design but at the same time take care of some Threefish - * specific behaviour and possibilities. - * - * These are the low level functions that deal with Threefish blocks only. - * Implementations for cipher modes such as ECB, CFB, or CBC may use these - * functions. - * -@code - // Threefish cipher context data - struct threefish_key key_ctx; - - // Initialize the context - threefish_set_key(&key_ctx, THREEFISH_512, key, tweak); - - // Encrypt - threefish_encrypt_block_bytes(&key_ctx, input, cipher); -@endcode - */ - -#include -#include "skein_base.h" - -#define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L - -/** - * Which Threefish size to use - */ -enum threefish_size { - THREEFISH_256 = 256, /*!< Skein with 256 bit state */ - THREEFISH_512 = 512, /*!< Skein with 512 bit state */ - THREEFISH_1024 = 1024 /*!< Skein with 1024 bit state */ -}; - -/** - * Context for Threefish key and tweak words. - * - * This structure was setup with some know-how of the internal - * Skein structures, in particular ordering of header and size dependent - * variables. If Skein implementation changes this, the adapt these - * structures as well. - */ -struct threefish_key { - u64 state_size; - u64 key[SKEIN_MAX_STATE_WORDS + 1]; /* max number of key words*/ - u64 tweak[3]; -}; - -/** - * Set Threefish key and tweak data. - * - * This function sets the key and tweak data for the Threefish cipher of - * the given size. The key data must have the same length (number of bits) - * as the state size - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param size - * Which Skein size to use. - * @param key_data - * Pointer to the key words (word has 64 bits). - * @param tweak - * Pointer to the two tweak words (word has 64 bits). - */ -void threefish_set_key(struct threefish_key *key_ctx, - enum threefish_size state_size, - u64 *key_data, u64 *tweak); - -/** - * Encrypt Threefish block (bytes). - * - * The buffer must have at least the same length (number of bits) as the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to plaintext data buffer. - * @param out - * Pointer to cipher buffer. - */ -void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out); - -/** - * Encrypt Threefish block (words). - * - * The buffer must have at least the same length (number of bits) as the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * The wordsize ist set to 64 bits. - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to plaintext data buffer. - * @param out - * Pointer to cipher buffer. - */ -void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out); - -/** - * Decrypt Threefish block (bytes). - * - * The buffer must have at least the same length (number of bits) as the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, decrypts them and stores the result in the output - * buffer - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to cipher data buffer. - * @param out - * Pointer to plaintext buffer. - */ -void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out); - -/** - * Decrypt Threefish block (words). - * - * The buffer must have at least the same length (number of bits) as the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * The wordsize ist set to 64 bits. - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to cipher data buffer. - * @param out - * Pointer to plaintext buffer. - */ -void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out); - -void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output); -/** - * @} - */ -#endif diff --git a/drivers/staging/skein/threefish_block.c b/drivers/staging/skein/threefish_block.c deleted file mode 100644 index 87f055890544..000000000000 --- a/drivers/staging/skein/threefish_block.c +++ /dev/null @@ -1,8244 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include "threefish_api.h" - -void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1 + t0; - b0 += b1 + k0; - b1 = rol64(b1, 14) ^ b0; - - b3 += k3; - b2 += b3 + k2 + t1; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k2 + t1; - b0 += b1 + k1; - b1 = rol64(b1, 25) ^ b0; - - b3 += k4 + 1; - b2 += b3 + k3 + t2; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k3 + t2; - b0 += b1 + k2; - b1 = rol64(b1, 14) ^ b0; - - b3 += k0 + 2; - b2 += b3 + k4 + t0; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k4 + t0; - b0 += b1 + k3; - b1 = rol64(b1, 25) ^ b0; - - b3 += k1 + 3; - b2 += b3 + k0 + t1; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k0 + t1; - b0 += b1 + k4; - b1 = rol64(b1, 14) ^ b0; - - b3 += k2 + 4; - b2 += b3 + k1 + t2; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k1 + t2; - b0 += b1 + k0; - b1 = rol64(b1, 25) ^ b0; - - b3 += k3 + 5; - b2 += b3 + k2 + t0; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k2 + t0; - b0 += b1 + k1; - b1 = rol64(b1, 14) ^ b0; - - b3 += k4 + 6; - b2 += b3 + k3 + t1; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k3 + t1; - b0 += b1 + k2; - b1 = rol64(b1, 25) ^ b0; - - b3 += k0 + 7; - b2 += b3 + k4 + t2; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k4 + t2; - b0 += b1 + k3; - b1 = rol64(b1, 14) ^ b0; - - b3 += k1 + 8; - b2 += b3 + k0 + t0; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k0 + t0; - b0 += b1 + k4; - b1 = rol64(b1, 25) ^ b0; - - b3 += k2 + 9; - b2 += b3 + k1 + t1; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k1 + t1; - b0 += b1 + k0; - b1 = rol64(b1, 14) ^ b0; - - b3 += k3 + 10; - b2 += b3 + k2 + t2; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k2 + t2; - b0 += b1 + k1; - b1 = rol64(b1, 25) ^ b0; - - b3 += k4 + 11; - b2 += b3 + k3 + t0; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k3 + t0; - b0 += b1 + k2; - b1 = rol64(b1, 14) ^ b0; - - b3 += k0 + 12; - b2 += b3 + k4 + t1; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k4 + t1; - b0 += b1 + k3; - b1 = rol64(b1, 25) ^ b0; - - b3 += k1 + 13; - b2 += b3 + k0 + t2; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k0 + t2; - b0 += b1 + k4; - b1 = rol64(b1, 14) ^ b0; - - b3 += k2 + 14; - b2 += b3 + k1 + t0; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k1 + t0; - b0 += b1 + k0; - b1 = rol64(b1, 25) ^ b0; - - b3 += k3 + 15; - b2 += b3 + k2 + t1; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - b1 += k2 + t1; - b0 += b1 + k1; - b1 = rol64(b1, 14) ^ b0; - - b3 += k4 + 16; - b2 += b3 + k3 + t2; - b3 = rol64(b3, 16) ^ b2; - - b0 += b3; - b3 = rol64(b3, 52) ^ b0; - - b2 += b1; - b1 = rol64(b1, 57) ^ b2; - - b0 += b1; - b1 = rol64(b1, 23) ^ b0; - - b2 += b3; - b3 = rol64(b3, 40) ^ b2; - - b0 += b3; - b3 = rol64(b3, 5) ^ b0; - - b2 += b1; - b1 = rol64(b1, 37) ^ b2; - - b1 += k3 + t2; - b0 += b1 + k2; - b1 = rol64(b1, 25) ^ b0; - - b3 += k0 + 17; - b2 += b3 + k4 + t0; - b3 = rol64(b3, 33) ^ b2; - - b0 += b3; - b3 = rol64(b3, 46) ^ b0; - - b2 += b1; - b1 = rol64(b1, 12) ^ b2; - - b0 += b1; - b1 = rol64(b1, 58) ^ b0; - - b2 += b3; - b3 = rol64(b3, 22) ^ b2; - - b0 += b3; - b3 = rol64(b3, 32) ^ b0; - - b2 += b1; - b1 = rol64(b1, 32) ^ b2; - - output[0] = b0 + k3; - output[1] = b1 + k4 + t0; - output[2] = b2 + k0 + t1; - output[3] = b3 + k1 + 18; -} - -void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - u64 tmp; - - b0 -= k3; - b1 -= k4 + t0; - b2 -= k0 + t1; - b3 -= k1 + 18; - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k2; - b1 -= k3 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k4 + t0; - b3 -= k0 + 17; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k1; - b1 -= k2 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k3 + t2; - b3 -= k4 + 16; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k0; - b1 -= k1 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k2 + t1; - b3 -= k3 + 15; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k4; - b1 -= k0 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k1 + t0; - b3 -= k2 + 14; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k3; - b1 -= k4 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k0 + t2; - b3 -= k1 + 13; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k2; - b1 -= k3 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k4 + t1; - b3 -= k0 + 12; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k1; - b1 -= k2 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k3 + t0; - b3 -= k4 + 11; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k0; - b1 -= k1 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k2 + t2; - b3 -= k3 + 10; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k4; - b1 -= k0 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k1 + t1; - b3 -= k2 + 9; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k3; - b1 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k0 + t0; - b3 -= k1 + 8; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k2; - b1 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k4 + t2; - b3 -= k0 + 7; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k1; - b1 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k3 + t1; - b3 -= k4 + 6; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k0; - b1 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k2 + t0; - b3 -= k3 + 5; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k4; - b1 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k1 + t2; - b3 -= k2 + 4; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k3; - b1 -= k4 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k0 + t1; - b3 -= k1 + 3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k2; - b1 -= k3 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k4 + t0; - b3 -= k0 + 2; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 32); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 32); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 58); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 22); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 46); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 12); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 25); - b0 -= b1 + k1; - b1 -= k2 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 33); - b2 -= b3 + k3 + t2; - b3 -= k4 + 1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 5); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 37); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 23); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 40); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 52); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 57); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 14); - b0 -= b1 + k0; - b1 -= k1 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 16); - b2 -= b3 + k2 + t1; - b3 -= k3; - - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; -} - -void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1; - b0 += b1 + k0; - b1 = rol64(b1, 46) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = rol64(b3, 36) ^ b2; - - b5 += k5 + t0; - b4 += b5 + k4; - b5 = rol64(b5, 19) ^ b4; - - b7 += k7; - b6 += b7 + k6 + t1; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k2; - b0 += b1 + k1; - b1 = rol64(b1, 39) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = rol64(b3, 30) ^ b2; - - b5 += k6 + t1; - b4 += b5 + k5; - b5 = rol64(b5, 34) ^ b4; - - b7 += k8 + 1; - b6 += b7 + k7 + t2; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k3; - b0 += b1 + k2; - b1 = rol64(b1, 46) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = rol64(b3, 36) ^ b2; - - b5 += k7 + t2; - b4 += b5 + k6; - b5 = rol64(b5, 19) ^ b4; - - b7 += k0 + 2; - b6 += b7 + k8 + t0; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k4; - b0 += b1 + k3; - b1 = rol64(b1, 39) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = rol64(b3, 30) ^ b2; - - b5 += k8 + t0; - b4 += b5 + k7; - b5 = rol64(b5, 34) ^ b4; - - b7 += k1 + 3; - b6 += b7 + k0 + t1; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k5; - b0 += b1 + k4; - b1 = rol64(b1, 46) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = rol64(b3, 36) ^ b2; - - b5 += k0 + t1; - b4 += b5 + k8; - b5 = rol64(b5, 19) ^ b4; - - b7 += k2 + 4; - b6 += b7 + k1 + t2; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k6; - b0 += b1 + k5; - b1 = rol64(b1, 39) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = rol64(b3, 30) ^ b2; - - b5 += k1 + t2; - b4 += b5 + k0; - b5 = rol64(b5, 34) ^ b4; - - b7 += k3 + 5; - b6 += b7 + k2 + t0; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k7; - b0 += b1 + k6; - b1 = rol64(b1, 46) ^ b0; - - b3 += k0; - b2 += b3 + k8; - b3 = rol64(b3, 36) ^ b2; - - b5 += k2 + t0; - b4 += b5 + k1; - b5 = rol64(b5, 19) ^ b4; - - b7 += k4 + 6; - b6 += b7 + k3 + t1; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k8; - b0 += b1 + k7; - b1 = rol64(b1, 39) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = rol64(b3, 30) ^ b2; - - b5 += k3 + t1; - b4 += b5 + k2; - b5 = rol64(b5, 34) ^ b4; - - b7 += k5 + 7; - b6 += b7 + k4 + t2; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k0; - b0 += b1 + k8; - b1 = rol64(b1, 46) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = rol64(b3, 36) ^ b2; - - b5 += k4 + t2; - b4 += b5 + k3; - b5 = rol64(b5, 19) ^ b4; - - b7 += k6 + 8; - b6 += b7 + k5 + t0; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k1; - b0 += b1 + k0; - b1 = rol64(b1, 39) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = rol64(b3, 30) ^ b2; - - b5 += k5 + t0; - b4 += b5 + k4; - b5 = rol64(b5, 34) ^ b4; - - b7 += k7 + 9; - b6 += b7 + k6 + t1; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k2; - b0 += b1 + k1; - b1 = rol64(b1, 46) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = rol64(b3, 36) ^ b2; - - b5 += k6 + t1; - b4 += b5 + k5; - b5 = rol64(b5, 19) ^ b4; - - b7 += k8 + 10; - b6 += b7 + k7 + t2; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k3; - b0 += b1 + k2; - b1 = rol64(b1, 39) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = rol64(b3, 30) ^ b2; - - b5 += k7 + t2; - b4 += b5 + k6; - b5 = rol64(b5, 34) ^ b4; - - b7 += k0 + 11; - b6 += b7 + k8 + t0; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k4; - b0 += b1 + k3; - b1 = rol64(b1, 46) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = rol64(b3, 36) ^ b2; - - b5 += k8 + t0; - b4 += b5 + k7; - b5 = rol64(b5, 19) ^ b4; - - b7 += k1 + 12; - b6 += b7 + k0 + t1; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k5; - b0 += b1 + k4; - b1 = rol64(b1, 39) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = rol64(b3, 30) ^ b2; - - b5 += k0 + t1; - b4 += b5 + k8; - b5 = rol64(b5, 34) ^ b4; - - b7 += k2 + 13; - b6 += b7 + k1 + t2; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k6; - b0 += b1 + k5; - b1 = rol64(b1, 46) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = rol64(b3, 36) ^ b2; - - b5 += k1 + t2; - b4 += b5 + k0; - b5 = rol64(b5, 19) ^ b4; - - b7 += k3 + 14; - b6 += b7 + k2 + t0; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k7; - b0 += b1 + k6; - b1 = rol64(b1, 39) ^ b0; - - b3 += k0; - b2 += b3 + k8; - b3 = rol64(b3, 30) ^ b2; - - b5 += k2 + t0; - b4 += b5 + k1; - b5 = rol64(b5, 34) ^ b4; - - b7 += k4 + 15; - b6 += b7 + k3 + t1; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - b1 += k8; - b0 += b1 + k7; - b1 = rol64(b1, 46) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = rol64(b3, 36) ^ b2; - - b5 += k3 + t1; - b4 += b5 + k2; - b5 = rol64(b5, 19) ^ b4; - - b7 += k5 + 16; - b6 += b7 + k4 + t2; - b7 = rol64(b7, 37) ^ b6; - - b2 += b1; - b1 = rol64(b1, 33) ^ b2; - - b4 += b7; - b7 = rol64(b7, 27) ^ b4; - - b6 += b5; - b5 = rol64(b5, 14) ^ b6; - - b0 += b3; - b3 = rol64(b3, 42) ^ b0; - - b4 += b1; - b1 = rol64(b1, 17) ^ b4; - - b6 += b3; - b3 = rol64(b3, 49) ^ b6; - - b0 += b5; - b5 = rol64(b5, 36) ^ b0; - - b2 += b7; - b7 = rol64(b7, 39) ^ b2; - - b6 += b1; - b1 = rol64(b1, 44) ^ b6; - - b0 += b7; - b7 = rol64(b7, 9) ^ b0; - - b2 += b5; - b5 = rol64(b5, 54) ^ b2; - - b4 += b3; - b3 = rol64(b3, 56) ^ b4; - - b1 += k0; - b0 += b1 + k8; - b1 = rol64(b1, 39) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = rol64(b3, 30) ^ b2; - - b5 += k4 + t2; - b4 += b5 + k3; - b5 = rol64(b5, 34) ^ b4; - - b7 += k6 + 17; - b6 += b7 + k5 + t0; - b7 = rol64(b7, 24) ^ b6; - - b2 += b1; - b1 = rol64(b1, 13) ^ b2; - - b4 += b7; - b7 = rol64(b7, 50) ^ b4; - - b6 += b5; - b5 = rol64(b5, 10) ^ b6; - - b0 += b3; - b3 = rol64(b3, 17) ^ b0; - - b4 += b1; - b1 = rol64(b1, 25) ^ b4; - - b6 += b3; - b3 = rol64(b3, 29) ^ b6; - - b0 += b5; - b5 = rol64(b5, 39) ^ b0; - - b2 += b7; - b7 = rol64(b7, 43) ^ b2; - - b6 += b1; - b1 = rol64(b1, 8) ^ b6; - - b0 += b7; - b7 = rol64(b7, 35) ^ b0; - - b2 += b5; - b5 = rol64(b5, 56) ^ b2; - - b4 += b3; - b3 = rol64(b3, 22) ^ b4; - - output[0] = b0 + k0; - output[1] = b1 + k1; - output[2] = b2 + k2; - output[3] = b3 + k3; - output[4] = b4 + k4; - output[5] = b5 + k5 + t0; - output[6] = b6 + k6 + t1; - output[7] = b7 + k7 + 18; -} - -void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - u64 tmp; - - b0 -= k0; - b1 -= k1; - b2 -= k2; - b3 -= k3; - b4 -= k4; - b5 -= k5 + t0; - b6 -= k6 + t1; - b7 -= k7 + 18; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k5 + t0; - b7 -= k6 + 17; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k3; - b5 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k8; - b1 -= k0; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k4 + t2; - b7 -= k5 + 16; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k2; - b5 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k3 + t1; - b7 -= k4 + 15; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k1; - b5 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k8; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k2 + t0; - b7 -= k3 + 14; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k0; - b5 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k1 + t2; - b7 -= k2 + 13; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k8; - b5 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k0 + t1; - b7 -= k1 + 12; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k7; - b5 -= k8 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k8 + t0; - b7 -= k0 + 11; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k6; - b5 -= k7 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k7 + t2; - b7 -= k8 + 10; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k5; - b5 -= k6 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k6 + t1; - b7 -= k7 + 9; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k4; - b5 -= k5 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k0; - b1 -= k1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k5 + t0; - b7 -= k6 + 8; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k3; - b5 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k8; - b1 -= k0; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k4 + t2; - b7 -= k5 + 7; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k2; - b5 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k3 + t1; - b7 -= k4 + 6; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k1; - b5 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k8; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k2 + t0; - b7 -= k3 + 5; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k0; - b5 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k1 + t2; - b7 -= k2 + 4; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k8; - b5 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k0 + t1; - b7 -= k1 + 3; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k7; - b5 -= k8 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k8 + t0; - b7 -= k0 + 2; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k6; - b5 -= k7 + t2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 22); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 56); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 35); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 8); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 43); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 39); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 29); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 25); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 17); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 10); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 50); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 13); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 24); - b6 -= b7 + k7 + t2; - b7 -= k8 + 1; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 34); - b4 -= b5 + k5; - b5 -= k6 + t1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 30); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 39); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 56); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 54); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 9); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 44); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = ror64(tmp, 39); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = ror64(tmp, 36); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = ror64(tmp, 49); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = ror64(tmp, 17); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = ror64(tmp, 42); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = ror64(tmp, 14); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = ror64(tmp, 27); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = ror64(tmp, 33); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 37); - b6 -= b7 + k6 + t1; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 19); - b4 -= b5 + k4; - b5 -= k5 + t0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 36); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 46); - b0 -= b1 + k0; - b1 -= k1; - - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; - - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; -} - -void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8], k9 = key_ctx->key[9], - k10 = key_ctx->key[10], k11 = key_ctx->key[11], - k12 = key_ctx->key[12], k13 = key_ctx->key[13], - k14 = key_ctx->key[14], k15 = key_ctx->key[15], - k16 = key_ctx->key[16]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1; - b0 += b1 + k0; - b1 = rol64(b1, 24) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = rol64(b3, 13) ^ b2; - - b5 += k5; - b4 += b5 + k4; - b5 = rol64(b5, 8) ^ b4; - - b7 += k7; - b6 += b7 + k6; - b7 = rol64(b7, 47) ^ b6; - - b9 += k9; - b8 += b9 + k8; - b9 = rol64(b9, 8) ^ b8; - - b11 += k11; - b10 += b11 + k10; - b11 = rol64(b11, 17) ^ b10; - - b13 += k13 + t0; - b12 += b13 + k12; - b13 = rol64(b13, 22) ^ b12; - - b15 += k15; - b14 += b15 + k14 + t1; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k2; - b0 += b1 + k1; - b1 = rol64(b1, 41) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = rol64(b3, 9) ^ b2; - - b5 += k6; - b4 += b5 + k5; - b5 = rol64(b5, 37) ^ b4; - - b7 += k8; - b6 += b7 + k7; - b7 = rol64(b7, 31) ^ b6; - - b9 += k10; - b8 += b9 + k9; - b9 = rol64(b9, 12) ^ b8; - - b11 += k12; - b10 += b11 + k11; - b11 = rol64(b11, 47) ^ b10; - - b13 += k14 + t1; - b12 += b13 + k13; - b13 = rol64(b13, 44) ^ b12; - - b15 += k16 + 1; - b14 += b15 + k15 + t2; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k3; - b0 += b1 + k2; - b1 = rol64(b1, 24) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = rol64(b3, 13) ^ b2; - - b5 += k7; - b4 += b5 + k6; - b5 = rol64(b5, 8) ^ b4; - - b7 += k9; - b6 += b7 + k8; - b7 = rol64(b7, 47) ^ b6; - - b9 += k11; - b8 += b9 + k10; - b9 = rol64(b9, 8) ^ b8; - - b11 += k13; - b10 += b11 + k12; - b11 = rol64(b11, 17) ^ b10; - - b13 += k15 + t2; - b12 += b13 + k14; - b13 = rol64(b13, 22) ^ b12; - - b15 += k0 + 2; - b14 += b15 + k16 + t0; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k4; - b0 += b1 + k3; - b1 = rol64(b1, 41) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = rol64(b3, 9) ^ b2; - - b5 += k8; - b4 += b5 + k7; - b5 = rol64(b5, 37) ^ b4; - - b7 += k10; - b6 += b7 + k9; - b7 = rol64(b7, 31) ^ b6; - - b9 += k12; - b8 += b9 + k11; - b9 = rol64(b9, 12) ^ b8; - - b11 += k14; - b10 += b11 + k13; - b11 = rol64(b11, 47) ^ b10; - - b13 += k16 + t0; - b12 += b13 + k15; - b13 = rol64(b13, 44) ^ b12; - - b15 += k1 + 3; - b14 += b15 + k0 + t1; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k5; - b0 += b1 + k4; - b1 = rol64(b1, 24) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = rol64(b3, 13) ^ b2; - - b5 += k9; - b4 += b5 + k8; - b5 = rol64(b5, 8) ^ b4; - - b7 += k11; - b6 += b7 + k10; - b7 = rol64(b7, 47) ^ b6; - - b9 += k13; - b8 += b9 + k12; - b9 = rol64(b9, 8) ^ b8; - - b11 += k15; - b10 += b11 + k14; - b11 = rol64(b11, 17) ^ b10; - - b13 += k0 + t1; - b12 += b13 + k16; - b13 = rol64(b13, 22) ^ b12; - - b15 += k2 + 4; - b14 += b15 + k1 + t2; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k6; - b0 += b1 + k5; - b1 = rol64(b1, 41) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = rol64(b3, 9) ^ b2; - - b5 += k10; - b4 += b5 + k9; - b5 = rol64(b5, 37) ^ b4; - - b7 += k12; - b6 += b7 + k11; - b7 = rol64(b7, 31) ^ b6; - - b9 += k14; - b8 += b9 + k13; - b9 = rol64(b9, 12) ^ b8; - - b11 += k16; - b10 += b11 + k15; - b11 = rol64(b11, 47) ^ b10; - - b13 += k1 + t2; - b12 += b13 + k0; - b13 = rol64(b13, 44) ^ b12; - - b15 += k3 + 5; - b14 += b15 + k2 + t0; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k7; - b0 += b1 + k6; - b1 = rol64(b1, 24) ^ b0; - - b3 += k9; - b2 += b3 + k8; - b3 = rol64(b3, 13) ^ b2; - - b5 += k11; - b4 += b5 + k10; - b5 = rol64(b5, 8) ^ b4; - - b7 += k13; - b6 += b7 + k12; - b7 = rol64(b7, 47) ^ b6; - - b9 += k15; - b8 += b9 + k14; - b9 = rol64(b9, 8) ^ b8; - - b11 += k0; - b10 += b11 + k16; - b11 = rol64(b11, 17) ^ b10; - - b13 += k2 + t0; - b12 += b13 + k1; - b13 = rol64(b13, 22) ^ b12; - - b15 += k4 + 6; - b14 += b15 + k3 + t1; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k8; - b0 += b1 + k7; - b1 = rol64(b1, 41) ^ b0; - - b3 += k10; - b2 += b3 + k9; - b3 = rol64(b3, 9) ^ b2; - - b5 += k12; - b4 += b5 + k11; - b5 = rol64(b5, 37) ^ b4; - - b7 += k14; - b6 += b7 + k13; - b7 = rol64(b7, 31) ^ b6; - - b9 += k16; - b8 += b9 + k15; - b9 = rol64(b9, 12) ^ b8; - - b11 += k1; - b10 += b11 + k0; - b11 = rol64(b11, 47) ^ b10; - - b13 += k3 + t1; - b12 += b13 + k2; - b13 = rol64(b13, 44) ^ b12; - - b15 += k5 + 7; - b14 += b15 + k4 + t2; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k9; - b0 += b1 + k8; - b1 = rol64(b1, 24) ^ b0; - - b3 += k11; - b2 += b3 + k10; - b3 = rol64(b3, 13) ^ b2; - - b5 += k13; - b4 += b5 + k12; - b5 = rol64(b5, 8) ^ b4; - - b7 += k15; - b6 += b7 + k14; - b7 = rol64(b7, 47) ^ b6; - - b9 += k0; - b8 += b9 + k16; - b9 = rol64(b9, 8) ^ b8; - - b11 += k2; - b10 += b11 + k1; - b11 = rol64(b11, 17) ^ b10; - - b13 += k4 + t2; - b12 += b13 + k3; - b13 = rol64(b13, 22) ^ b12; - - b15 += k6 + 8; - b14 += b15 + k5 + t0; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k10; - b0 += b1 + k9; - b1 = rol64(b1, 41) ^ b0; - - b3 += k12; - b2 += b3 + k11; - b3 = rol64(b3, 9) ^ b2; - - b5 += k14; - b4 += b5 + k13; - b5 = rol64(b5, 37) ^ b4; - - b7 += k16; - b6 += b7 + k15; - b7 = rol64(b7, 31) ^ b6; - - b9 += k1; - b8 += b9 + k0; - b9 = rol64(b9, 12) ^ b8; - - b11 += k3; - b10 += b11 + k2; - b11 = rol64(b11, 47) ^ b10; - - b13 += k5 + t0; - b12 += b13 + k4; - b13 = rol64(b13, 44) ^ b12; - - b15 += k7 + 9; - b14 += b15 + k6 + t1; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k11; - b0 += b1 + k10; - b1 = rol64(b1, 24) ^ b0; - - b3 += k13; - b2 += b3 + k12; - b3 = rol64(b3, 13) ^ b2; - - b5 += k15; - b4 += b5 + k14; - b5 = rol64(b5, 8) ^ b4; - - b7 += k0; - b6 += b7 + k16; - b7 = rol64(b7, 47) ^ b6; - - b9 += k2; - b8 += b9 + k1; - b9 = rol64(b9, 8) ^ b8; - - b11 += k4; - b10 += b11 + k3; - b11 = rol64(b11, 17) ^ b10; - - b13 += k6 + t1; - b12 += b13 + k5; - b13 = rol64(b13, 22) ^ b12; - - b15 += k8 + 10; - b14 += b15 + k7 + t2; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k12; - b0 += b1 + k11; - b1 = rol64(b1, 41) ^ b0; - - b3 += k14; - b2 += b3 + k13; - b3 = rol64(b3, 9) ^ b2; - - b5 += k16; - b4 += b5 + k15; - b5 = rol64(b5, 37) ^ b4; - - b7 += k1; - b6 += b7 + k0; - b7 = rol64(b7, 31) ^ b6; - - b9 += k3; - b8 += b9 + k2; - b9 = rol64(b9, 12) ^ b8; - - b11 += k5; - b10 += b11 + k4; - b11 = rol64(b11, 47) ^ b10; - - b13 += k7 + t2; - b12 += b13 + k6; - b13 = rol64(b13, 44) ^ b12; - - b15 += k9 + 11; - b14 += b15 + k8 + t0; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k13; - b0 += b1 + k12; - b1 = rol64(b1, 24) ^ b0; - - b3 += k15; - b2 += b3 + k14; - b3 = rol64(b3, 13) ^ b2; - - b5 += k0; - b4 += b5 + k16; - b5 = rol64(b5, 8) ^ b4; - - b7 += k2; - b6 += b7 + k1; - b7 = rol64(b7, 47) ^ b6; - - b9 += k4; - b8 += b9 + k3; - b9 = rol64(b9, 8) ^ b8; - - b11 += k6; - b10 += b11 + k5; - b11 = rol64(b11, 17) ^ b10; - - b13 += k8 + t0; - b12 += b13 + k7; - b13 = rol64(b13, 22) ^ b12; - - b15 += k10 + 12; - b14 += b15 + k9 + t1; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k14; - b0 += b1 + k13; - b1 = rol64(b1, 41) ^ b0; - - b3 += k16; - b2 += b3 + k15; - b3 = rol64(b3, 9) ^ b2; - - b5 += k1; - b4 += b5 + k0; - b5 = rol64(b5, 37) ^ b4; - - b7 += k3; - b6 += b7 + k2; - b7 = rol64(b7, 31) ^ b6; - - b9 += k5; - b8 += b9 + k4; - b9 = rol64(b9, 12) ^ b8; - - b11 += k7; - b10 += b11 + k6; - b11 = rol64(b11, 47) ^ b10; - - b13 += k9 + t1; - b12 += b13 + k8; - b13 = rol64(b13, 44) ^ b12; - - b15 += k11 + 13; - b14 += b15 + k10 + t2; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k15; - b0 += b1 + k14; - b1 = rol64(b1, 24) ^ b0; - - b3 += k0; - b2 += b3 + k16; - b3 = rol64(b3, 13) ^ b2; - - b5 += k2; - b4 += b5 + k1; - b5 = rol64(b5, 8) ^ b4; - - b7 += k4; - b6 += b7 + k3; - b7 = rol64(b7, 47) ^ b6; - - b9 += k6; - b8 += b9 + k5; - b9 = rol64(b9, 8) ^ b8; - - b11 += k8; - b10 += b11 + k7; - b11 = rol64(b11, 17) ^ b10; - - b13 += k10 + t2; - b12 += b13 + k9; - b13 = rol64(b13, 22) ^ b12; - - b15 += k12 + 14; - b14 += b15 + k11 + t0; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k16; - b0 += b1 + k15; - b1 = rol64(b1, 41) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = rol64(b3, 9) ^ b2; - - b5 += k3; - b4 += b5 + k2; - b5 = rol64(b5, 37) ^ b4; - - b7 += k5; - b6 += b7 + k4; - b7 = rol64(b7, 31) ^ b6; - - b9 += k7; - b8 += b9 + k6; - b9 = rol64(b9, 12) ^ b8; - - b11 += k9; - b10 += b11 + k8; - b11 = rol64(b11, 47) ^ b10; - - b13 += k11 + t0; - b12 += b13 + k10; - b13 = rol64(b13, 44) ^ b12; - - b15 += k13 + 15; - b14 += b15 + k12 + t1; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k0; - b0 += b1 + k16; - b1 = rol64(b1, 24) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = rol64(b3, 13) ^ b2; - - b5 += k4; - b4 += b5 + k3; - b5 = rol64(b5, 8) ^ b4; - - b7 += k6; - b6 += b7 + k5; - b7 = rol64(b7, 47) ^ b6; - - b9 += k8; - b8 += b9 + k7; - b9 = rol64(b9, 8) ^ b8; - - b11 += k10; - b10 += b11 + k9; - b11 = rol64(b11, 17) ^ b10; - - b13 += k12 + t1; - b12 += b13 + k11; - b13 = rol64(b13, 22) ^ b12; - - b15 += k14 + 16; - b14 += b15 + k13 + t2; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k1; - b0 += b1 + k0; - b1 = rol64(b1, 41) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = rol64(b3, 9) ^ b2; - - b5 += k5; - b4 += b5 + k4; - b5 = rol64(b5, 37) ^ b4; - - b7 += k7; - b6 += b7 + k6; - b7 = rol64(b7, 31) ^ b6; - - b9 += k9; - b8 += b9 + k8; - b9 = rol64(b9, 12) ^ b8; - - b11 += k11; - b10 += b11 + k10; - b11 = rol64(b11, 47) ^ b10; - - b13 += k13 + t2; - b12 += b13 + k12; - b13 = rol64(b13, 44) ^ b12; - - b15 += k15 + 17; - b14 += b15 + k14 + t0; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - b1 += k2; - b0 += b1 + k1; - b1 = rol64(b1, 24) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = rol64(b3, 13) ^ b2; - - b5 += k6; - b4 += b5 + k5; - b5 = rol64(b5, 8) ^ b4; - - b7 += k8; - b6 += b7 + k7; - b7 = rol64(b7, 47) ^ b6; - - b9 += k10; - b8 += b9 + k9; - b9 = rol64(b9, 8) ^ b8; - - b11 += k12; - b10 += b11 + k11; - b11 = rol64(b11, 17) ^ b10; - - b13 += k14 + t0; - b12 += b13 + k13; - b13 = rol64(b13, 22) ^ b12; - - b15 += k16 + 18; - b14 += b15 + k15 + t1; - b15 = rol64(b15, 37) ^ b14; - - b0 += b9; - b9 = rol64(b9, 38) ^ b0; - - b2 += b13; - b13 = rol64(b13, 19) ^ b2; - - b6 += b11; - b11 = rol64(b11, 10) ^ b6; - - b4 += b15; - b15 = rol64(b15, 55) ^ b4; - - b10 += b7; - b7 = rol64(b7, 49) ^ b10; - - b12 += b3; - b3 = rol64(b3, 18) ^ b12; - - b14 += b5; - b5 = rol64(b5, 23) ^ b14; - - b8 += b1; - b1 = rol64(b1, 52) ^ b8; - - b0 += b7; - b7 = rol64(b7, 33) ^ b0; - - b2 += b5; - b5 = rol64(b5, 4) ^ b2; - - b4 += b3; - b3 = rol64(b3, 51) ^ b4; - - b6 += b1; - b1 = rol64(b1, 13) ^ b6; - - b12 += b15; - b15 = rol64(b15, 34) ^ b12; - - b14 += b13; - b13 = rol64(b13, 41) ^ b14; - - b8 += b11; - b11 = rol64(b11, 59) ^ b8; - - b10 += b9; - b9 = rol64(b9, 17) ^ b10; - - b0 += b15; - b15 = rol64(b15, 5) ^ b0; - - b2 += b11; - b11 = rol64(b11, 20) ^ b2; - - b6 += b13; - b13 = rol64(b13, 48) ^ b6; - - b4 += b9; - b9 = rol64(b9, 41) ^ b4; - - b14 += b1; - b1 = rol64(b1, 47) ^ b14; - - b8 += b5; - b5 = rol64(b5, 28) ^ b8; - - b10 += b3; - b3 = rol64(b3, 16) ^ b10; - - b12 += b7; - b7 = rol64(b7, 25) ^ b12; - - b1 += k3; - b0 += b1 + k2; - b1 = rol64(b1, 41) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = rol64(b3, 9) ^ b2; - - b5 += k7; - b4 += b5 + k6; - b5 = rol64(b5, 37) ^ b4; - - b7 += k9; - b6 += b7 + k8; - b7 = rol64(b7, 31) ^ b6; - - b9 += k11; - b8 += b9 + k10; - b9 = rol64(b9, 12) ^ b8; - - b11 += k13; - b10 += b11 + k12; - b11 = rol64(b11, 47) ^ b10; - - b13 += k15 + t1; - b12 += b13 + k14; - b13 = rol64(b13, 44) ^ b12; - - b15 += k0 + 19; - b14 += b15 + k16 + t2; - b15 = rol64(b15, 30) ^ b14; - - b0 += b9; - b9 = rol64(b9, 16) ^ b0; - - b2 += b13; - b13 = rol64(b13, 34) ^ b2; - - b6 += b11; - b11 = rol64(b11, 56) ^ b6; - - b4 += b15; - b15 = rol64(b15, 51) ^ b4; - - b10 += b7; - b7 = rol64(b7, 4) ^ b10; - - b12 += b3; - b3 = rol64(b3, 53) ^ b12; - - b14 += b5; - b5 = rol64(b5, 42) ^ b14; - - b8 += b1; - b1 = rol64(b1, 41) ^ b8; - - b0 += b7; - b7 = rol64(b7, 31) ^ b0; - - b2 += b5; - b5 = rol64(b5, 44) ^ b2; - - b4 += b3; - b3 = rol64(b3, 47) ^ b4; - - b6 += b1; - b1 = rol64(b1, 46) ^ b6; - - b12 += b15; - b15 = rol64(b15, 19) ^ b12; - - b14 += b13; - b13 = rol64(b13, 42) ^ b14; - - b8 += b11; - b11 = rol64(b11, 44) ^ b8; - - b10 += b9; - b9 = rol64(b9, 25) ^ b10; - - b0 += b15; - b15 = rol64(b15, 9) ^ b0; - - b2 += b11; - b11 = rol64(b11, 48) ^ b2; - - b6 += b13; - b13 = rol64(b13, 35) ^ b6; - - b4 += b9; - b9 = rol64(b9, 52) ^ b4; - - b14 += b1; - b1 = rol64(b1, 23) ^ b14; - - b8 += b5; - b5 = rol64(b5, 31) ^ b8; - - b10 += b3; - b3 = rol64(b3, 37) ^ b10; - - b12 += b7; - b7 = rol64(b7, 20) ^ b12; - - output[0] = b0 + k3; - output[1] = b1 + k4; - output[2] = b2 + k5; - output[3] = b3 + k6; - output[4] = b4 + k7; - output[5] = b5 + k8; - output[6] = b6 + k9; - output[7] = b7 + k10; - output[8] = b8 + k11; - output[9] = b9 + k12; - output[10] = b10 + k13; - output[11] = b11 + k14; - output[12] = b12 + k15; - output[13] = b13 + k16 + t2; - output[14] = b14 + k0 + t0; - output[15] = b15 + k1 + 20; -} - -void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8], k9 = key_ctx->key[9], - k10 = key_ctx->key[10], k11 = key_ctx->key[11], - k12 = key_ctx->key[12], k13 = key_ctx->key[13], - k14 = key_ctx->key[14], k15 = key_ctx->key[15], - k16 = key_ctx->key[16]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - u64 tmp; - - b0 -= k3; - b1 -= k4; - b2 -= k5; - b3 -= k6; - b4 -= k7; - b5 -= k8; - b6 -= k9; - b7 -= k10; - b8 -= k11; - b9 -= k12; - b10 -= k13; - b11 -= k14; - b12 -= k15; - b13 -= k16 + t2; - b14 -= k0 + t0; - b15 -= k1 + 20; - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k16 + t2; - b15 -= k0 + 19; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k14; - b13 -= k15 + t1; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k12; - b11 -= k13; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k10; - b9 -= k11; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k8; - b7 -= k9; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k6; - b5 -= k7; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k15 + t1; - b15 -= k16 + 18; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k13; - b13 -= k14 + t0; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k11; - b11 -= k12; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k9; - b9 -= k10; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k7; - b7 -= k8; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k5; - b5 -= k6; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k14 + t0; - b15 -= k15 + 17; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k12; - b13 -= k13 + t2; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k10; - b11 -= k11; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k8; - b9 -= k9; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k6; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k4; - b5 -= k5; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k0; - b1 -= k1; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k13 + t2; - b15 -= k14 + 16; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k11; - b13 -= k12 + t1; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k9; - b11 -= k10; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k7; - b9 -= k8; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k5; - b7 -= k6; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k3; - b5 -= k4; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k16; - b1 -= k0; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k12 + t1; - b15 -= k13 + 15; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k10; - b13 -= k11 + t0; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k8; - b11 -= k9; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k6; - b9 -= k7; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k4; - b7 -= k5; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k2; - b5 -= k3; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k15; - b1 -= k16; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k11 + t0; - b15 -= k12 + 14; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k9; - b13 -= k10 + t2; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k7; - b11 -= k8; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k5; - b9 -= k6; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k3; - b7 -= k4; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k1; - b5 -= k2; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k16; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k14; - b1 -= k15; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k10 + t2; - b15 -= k11 + 13; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k8; - b13 -= k9 + t1; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k6; - b11 -= k7; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k4; - b9 -= k5; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k2; - b7 -= k3; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k0; - b5 -= k1; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k15; - b3 -= k16; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k13; - b1 -= k14; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k9 + t1; - b15 -= k10 + 12; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k7; - b13 -= k8 + t0; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k5; - b11 -= k6; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k3; - b9 -= k4; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k1; - b7 -= k2; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k16; - b5 -= k0; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k14; - b3 -= k15; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k12; - b1 -= k13; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k8 + t0; - b15 -= k9 + 11; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k6; - b13 -= k7 + t2; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k4; - b11 -= k5; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k2; - b9 -= k3; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k0; - b7 -= k1; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k15; - b5 -= k16; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k13; - b3 -= k14; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k11; - b1 -= k12; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k7 + t2; - b15 -= k8 + 10; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k5; - b13 -= k6 + t1; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k3; - b11 -= k4; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k1; - b9 -= k2; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k16; - b7 -= k0; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k14; - b5 -= k15; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k12; - b3 -= k13; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k10; - b1 -= k11; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k6 + t1; - b15 -= k7 + 9; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k4; - b13 -= k5 + t0; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k2; - b11 -= k3; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k0; - b9 -= k1; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k15; - b7 -= k16; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k13; - b5 -= k14; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k11; - b3 -= k12; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k9; - b1 -= k10; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k5 + t0; - b15 -= k6 + 8; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k3; - b13 -= k4 + t2; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k1; - b11 -= k2; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k16; - b9 -= k0; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k14; - b7 -= k15; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k12; - b5 -= k13; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k10; - b3 -= k11; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k8; - b1 -= k9; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k4 + t2; - b15 -= k5 + 7; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k2; - b13 -= k3 + t1; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k0; - b11 -= k1; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k15; - b9 -= k16; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k13; - b7 -= k14; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k11; - b5 -= k12; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k9; - b3 -= k10; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k3 + t1; - b15 -= k4 + 6; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k1; - b13 -= k2 + t0; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k16; - b11 -= k0; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k14; - b9 -= k15; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k12; - b7 -= k13; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k10; - b5 -= k11; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k8; - b3 -= k9; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k2 + t0; - b15 -= k3 + 5; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k0; - b13 -= k1 + t2; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k15; - b11 -= k16; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k13; - b9 -= k14; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k11; - b7 -= k12; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k9; - b5 -= k10; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k1 + t2; - b15 -= k2 + 4; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k16; - b13 -= k0 + t1; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k14; - b11 -= k15; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k12; - b9 -= k13; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k10; - b7 -= k11; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k8; - b5 -= k9; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k0 + t1; - b15 -= k1 + 3; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k15; - b13 -= k16 + t0; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k13; - b11 -= k14; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k11; - b9 -= k12; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k9; - b7 -= k10; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k7; - b5 -= k8; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k16 + t0; - b15 -= k0 + 2; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k14; - b13 -= k15 + t2; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k12; - b11 -= k13; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k10; - b9 -= k11; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k8; - b7 -= k9; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k6; - b5 -= k7; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 20); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 37); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 31); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 23); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 52); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 35); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 48); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 9); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 25); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 44); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 42); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 19); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 46); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 47); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 44); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 31); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 41); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 42); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 53); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 4); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 51); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 56); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 34); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 16); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 30); - b14 -= b15 + k15 + t2; - b15 -= k16 + 1; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 44); - b12 -= b13 + k13; - b13 -= k14 + t1; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 47); - b10 -= b11 + k11; - b11 -= k12; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 12); - b8 -= b9 + k9; - b9 -= k10; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 31); - b6 -= b7 + k7; - b7 -= k8; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 37); - b4 -= b5 + k5; - b5 -= k6; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 9); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 41); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b7 ^ b12; - b7 = ror64(tmp, 25); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = ror64(tmp, 16); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = ror64(tmp, 28); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = ror64(tmp, 47); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = ror64(tmp, 41); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = ror64(tmp, 48); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = ror64(tmp, 20); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = ror64(tmp, 5); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = ror64(tmp, 17); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = ror64(tmp, 59); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = ror64(tmp, 41); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = ror64(tmp, 34); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = ror64(tmp, 13); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = ror64(tmp, 51); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = ror64(tmp, 4); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = ror64(tmp, 33); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = ror64(tmp, 52); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = ror64(tmp, 23); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = ror64(tmp, 18); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = ror64(tmp, 49); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = ror64(tmp, 55); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = ror64(tmp, 10); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = ror64(tmp, 19); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = ror64(tmp, 38); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = ror64(tmp, 37); - b14 -= b15 + k14 + t1; - b15 -= k15; - - tmp = b13 ^ b12; - b13 = ror64(tmp, 22); - b12 -= b13 + k12; - b13 -= k13 + t0; - - tmp = b11 ^ b10; - b11 = ror64(tmp, 17); - b10 -= b11 + k10; - b11 -= k11; - - tmp = b9 ^ b8; - b9 = ror64(tmp, 8); - b8 -= b9 + k8; - b9 -= k9; - - tmp = b7 ^ b6; - b7 = ror64(tmp, 47); - b6 -= b7 + k6; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = ror64(tmp, 8); - b4 -= b5 + k4; - b5 -= k5; - - tmp = b3 ^ b2; - b3 = ror64(tmp, 13); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = ror64(tmp, 24); - b0 -= b1 + k0; - b1 -= k1; - - output[15] = b15; - output[14] = b14; - output[13] = b13; - output[12] = b12; - output[11] = b11; - output[10] = b10; - output[9] = b9; - output[8] = b8; - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; - output[3] = b3; - output[2] = b2; - output[1] = b1; - output[0] = b0; -} From 9a69f5087ccc20bb411025decab455836df04168 Mon Sep 17 00:00:00 2001 From: Simon Que Date: Fri, 29 Jun 2018 22:49:38 -0400 Subject: [PATCH 210/903] drivers/staging: Gasket driver framework + Apex driver The Gasket (Google ASIC Software, Kernel Extensions, and Tools) kernel framework is a generic, flexible system that supports thin kernel drivers. Gasket kernel drivers are expected to handle opening and closing devices, mmap'ing BAR space as requested, a small selection of ioctls, and handling page table translation (covered below). Any other functions should be handled by userspace code. The Gasket common module is not enough to run a device. In order to customize the Gasket code for a given piece of hardware, a device specific module must be created. At a minimum, this module must define a struct gasket_driver_desc containing the device-specific data for use by the framework; in addition, the module must declare an __init function that calls gasket_register_device with the module's gasket_driver_desc struct. Finally, the driver must define an exit function that calls gasket_unregister_device with the module's gasket_driver_desc struct. One of the core assumptions of the Gasket framework is that precisely one process is allowed to have an open write handle to the device node at any given time. (That process may, once it has one write handle, open any number of additional write handles.) This is accomplished by tracking open and close data for each driver instance. Signed-off-by: Rob Springer Signed-off-by: John Joseph Signed-off-by: Simon Que Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 7 + drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/gasket/Kconfig | 23 + drivers/staging/gasket/Makefile | 9 + drivers/staging/gasket/TODO | 17 + drivers/staging/gasket/apex.h | 95 + drivers/staging/gasket/apex_driver.c | 771 +++++++ drivers/staging/gasket/gasket.h | 129 ++ drivers/staging/gasket/gasket_constants.h | 56 + drivers/staging/gasket/gasket_core.c | 2157 ++++++++++++++++++++ drivers/staging/gasket/gasket_core.h | 719 +++++++ drivers/staging/gasket/gasket_interrupt.c | 638 ++++++ drivers/staging/gasket/gasket_interrupt.h | 172 ++ drivers/staging/gasket/gasket_ioctl.c | 449 ++++ drivers/staging/gasket/gasket_ioctl.h | 35 + drivers/staging/gasket/gasket_logging.h | 71 + drivers/staging/gasket/gasket_page_table.c | 1771 ++++++++++++++++ drivers/staging/gasket/gasket_page_table.h | 265 +++ drivers/staging/gasket/gasket_sysfs.c | 497 +++++ drivers/staging/gasket/gasket_sysfs.h | 199 ++ 21 files changed, 8083 insertions(+) create mode 100644 drivers/staging/gasket/Kconfig create mode 100644 drivers/staging/gasket/Makefile create mode 100644 drivers/staging/gasket/TODO create mode 100644 drivers/staging/gasket/apex.h create mode 100644 drivers/staging/gasket/apex_driver.c create mode 100644 drivers/staging/gasket/gasket.h create mode 100644 drivers/staging/gasket/gasket_constants.h create mode 100644 drivers/staging/gasket/gasket_core.c create mode 100644 drivers/staging/gasket/gasket_core.h create mode 100644 drivers/staging/gasket/gasket_interrupt.c create mode 100644 drivers/staging/gasket/gasket_interrupt.h create mode 100644 drivers/staging/gasket/gasket_ioctl.c create mode 100644 drivers/staging/gasket/gasket_ioctl.h create mode 100644 drivers/staging/gasket/gasket_logging.h create mode 100644 drivers/staging/gasket/gasket_page_table.c create mode 100644 drivers/staging/gasket/gasket_page_table.h create mode 100644 drivers/staging/gasket/gasket_sysfs.c create mode 100644 drivers/staging/gasket/gasket_sysfs.h diff --git a/MAINTAINERS b/MAINTAINERS index 681c9e411b86..b6d0cc0f5374 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5928,6 +5928,13 @@ F: scripts/gcc-plugin.sh F: scripts/Makefile.gcc-plugins F: Documentation/gcc-plugins.txt +GASKET DRIVER FRAMEWORK +M: Rob Springer +M: John Joseph +M: Ben Chan +S: Maintained +F: drivers/staging/gasket/ + GCOV BASED KERNEL PROFILING M: Peter Oberparleiter S: Maintained diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 5b96f972135a..6f578551d8e3 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -124,4 +124,6 @@ source "drivers/staging/mt7621-eth/Kconfig" source "drivers/staging/mt7621-dts/Kconfig" +source "drivers/staging/gasket/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 5d3740320577..3872351cf63e 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dma/ obj-$(CONFIG_SOC_MT7621) += mt7621-mmc/ obj-$(CONFIG_SOC_MT7621) += mt7621-eth/ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ +obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ diff --git a/drivers/staging/gasket/Kconfig b/drivers/staging/gasket/Kconfig new file mode 100644 index 000000000000..c836389c1402 --- /dev/null +++ b/drivers/staging/gasket/Kconfig @@ -0,0 +1,23 @@ +menu "Gasket devices" + +config STAGING_GASKET_FRAMEWORK + tristate "Gasket framework" + depends on PCI && X86_64 + help + This framework supports Gasket-compatible devices, such as Apex. + It is required for any of the following module(s). + + To compile this driver as a module, choose M here. The module + will be called "gasket". + +config STAGING_APEX_DRIVER + tristate "Apex Driver" + depends on STAGING_GASKET_FRAMEWORK + help + This driver supports the Apex device. Say Y if you want to + include this driver in the kernel. + + To compile this driver as a module, choose M here. The module + will be called "apex". + +endmenu diff --git a/drivers/staging/gasket/Makefile b/drivers/staging/gasket/Makefile new file mode 100644 index 000000000000..cec813ece678 --- /dev/null +++ b/drivers/staging/gasket/Makefile @@ -0,0 +1,9 @@ +# +# Makefile for Gasket framework and dependent drivers. +# + +obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket.o +obj-$(CONFIG_STAGING_APEX_DRIVER) += apex.o + +gasket-objs := gasket_core.o gasket_ioctl.o gasket_interrupt.o gasket_page_table.o gasket_sysfs.o +apex-objs := apex_driver.o diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO new file mode 100644 index 000000000000..0d8ee9602c80 --- /dev/null +++ b/drivers/staging/gasket/TODO @@ -0,0 +1,17 @@ +This is a list of things that need to be done to get this driver out of the +staging directory. +- Use SPDX tags to show the license of the file, and no more "boiler-plate" + license text is needed. +- Remove static function declarations. +- Document sysfs files with Documentation/ABI/ entries. +- Use misc interface instead of major number for driver version description. +- Add descriptions of module_param's +- Remove gasket-specific logging functions. +- apex_get_status() should actually check status. +- Static functions don't need kernel doc formatting, can be simplified. +- Fix multi-line alignment formatting to look like: + int ret = long_function_name(device, VARIABLE1, VARIABLE2, + VARIABLE3, VARIABLE4); +- "drivers" should never be dealing with "raw" sysfs calls or mess around with + kobjects at all. The driver core should handle all of this for you + automaically. There should not be a need for raw attribute macros. diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h new file mode 100644 index 000000000000..f2600aa05191 --- /dev/null +++ b/drivers/staging/gasket/apex.h @@ -0,0 +1,95 @@ +/* + * Apex kernel-userspace interface definition(s). + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __APEX_H__ +#define __APEX_H__ + +#include +#include + +#include "gasket.h" + +/* Structural definitions/macros. */ +/* The number of PCI BARs. */ +#define APEX_NUM_BARS 3 + +/* Size of a memory page in bytes, and the related number of bits to shift. */ +#define APEX_PAGE_SHIFT 12 +#define APEX_PAGE_SIZE BIT(APEX_PAGE_SHIFT) + +#define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */ + +/* Addresses are 2^3=8 bytes each. */ +/* page in second level page table */ +/* holds APEX_PAGE_SIZE/8 addresses */ +#define APEX_ADDR_SHIFT 3 +#define APEX_LEVEL_SHIFT (APEX_PAGE_SHIFT - APEX_ADDR_SHIFT) +#define APEX_LEVEL_SIZE BIT(APEX_LEVEL_SHIFT) + +#define APEX_PAGE_TABLE_MAX 65536 +#define APEX_SIMPLE_PAGE_MAX APEX_PAGE_TABLE_MAX +#define APEX_EXTENDED_PAGE_MAX (APEX_PAGE_TABLE_MAX << APEX_LEVEL_SHIFT) + +/* Check reset 120 times */ +#define APEX_RESET_RETRY 120 +/* Wait 100 ms between checks. Total 12 sec wait maximum. */ +#define APEX_RESET_DELAY 100 + +#define APEX_CHIP_INIT_DONE 2 +#define APEX_RESET_ACCEPTED 0 + +enum apex_reset_types { + APEX_CHIP_REINIT_RESET = 3, +}; + +/* Interrupt defines */ +/* Gasket device interrupts enums must be dense (i.e., no empty slots). */ +enum apex_interrupt { + APEX_INTERRUPT_INSTR_QUEUE = 0, + APEX_INTERRUPT_INPUT_ACTV_QUEUE = 1, + APEX_INTERRUPT_PARAM_QUEUE = 2, + APEX_INTERRUPT_OUTPUT_ACTV_QUEUE = 3, + APEX_INTERRUPT_SC_HOST_0 = 4, + APEX_INTERRUPT_SC_HOST_1 = 5, + APEX_INTERRUPT_SC_HOST_2 = 6, + APEX_INTERRUPT_SC_HOST_3 = 7, + APEX_INTERRUPT_TOP_LEVEL_0 = 8, + APEX_INTERRUPT_TOP_LEVEL_1 = 9, + APEX_INTERRUPT_TOP_LEVEL_2 = 10, + APEX_INTERRUPT_TOP_LEVEL_3 = 11, + APEX_INTERRUPT_FATAL_ERR = 12, + APEX_INTERRUPT_COUNT = 13, +}; + +/* + * Clock Gating ioctl. + */ +struct apex_gate_clock_ioctl { + /* Enter or leave clock gated state. */ + u64 enable; + + /* If set, enter clock gating state, regardless of custom block's + * internal idle state + */ + u64 force_idle; +}; + +/* Base number for all Apex-common IOCTLs */ +#define APEX_IOCTL_BASE 0x7F + +/* Enable/Disable clock gating. */ +#define APEX_IOCTL_GATE_CLOCK \ + _IOW(APEX_IOCTL_BASE, 0, struct apex_gate_clock_ioctl) + +#endif /* __APEX_H__ */ diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c new file mode 100644 index 000000000000..395256704428 --- /dev/null +++ b/drivers/staging/gasket/apex_driver.c @@ -0,0 +1,771 @@ +/* Driver for the Apex chip. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "apex.h" + +#include "gasket_core.h" +#include "gasket_interrupt.h" +#include "gasket_logging.h" +#include "gasket_page_table.h" +#include "gasket_sysfs.h" + +/* Constants */ +#define APEX_DEVICE_NAME "Apex" +#define APEX_DRIVER_VERSION "1.0" + +/* CSRs are in BAR 2. */ +#define APEX_BAR_INDEX 2 + +#define APEX_PCI_VENDOR_ID 0x1ac1 +#define APEX_PCI_DEVICE_ID 0x089a + +/* Bar Offsets. */ +#define APEX_BAR_OFFSET 0 +#define APEX_CM_OFFSET 0x1000000 + +/* The sizes of each Apex BAR 2. */ +#define APEX_BAR_BYTES 0x100000 +#define APEX_CH_MEM_BYTES (PAGE_SIZE * MAX_NUM_COHERENT_PAGES) + +/* The number of user-mappable memory ranges in BAR2 of a Apex chip. */ +#define NUM_REGIONS 3 + +/* The number of nodes in a Apex chip. */ +#define NUM_NODES 1 + +/* + * The total number of entries in the page table. Should match the value read + * from the register APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_SIZE. + */ +#define APEX_PAGE_TABLE_TOTAL_ENTRIES 8192 + +/* Enumeration of the supported sysfs entries. */ +enum sysfs_attribute_type { + ATTR_KERNEL_HIB_PAGE_TABLE_SIZE, + ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE, + ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES, +}; + +/* + * Register offsets into BAR2 memory. + * Only values necessary for driver implementation are defined. + */ +enum apex_bar2_regs { + APEX_BAR2_REG_SCU_BASE = 0x1A300, + APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_SIZE = 0x46000, + APEX_BAR2_REG_KERNEL_HIB_EXTENDED_TABLE = 0x46008, + APEX_BAR2_REG_KERNEL_HIB_TRANSLATION_ENABLE = 0x46010, + APEX_BAR2_REG_KERNEL_HIB_INSTR_QUEUE_INTVECCTL = 0x46018, + APEX_BAR2_REG_KERNEL_HIB_INPUT_ACTV_QUEUE_INTVECCTL = 0x46020, + APEX_BAR2_REG_KERNEL_HIB_PARAM_QUEUE_INTVECCTL = 0x46028, + APEX_BAR2_REG_KERNEL_HIB_OUTPUT_ACTV_QUEUE_INTVECCTL = 0x46030, + APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL = 0x46038, + APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL = 0x46040, + APEX_BAR2_REG_KERNEL_HIB_FATAL_ERR_INTVECCTL = 0x46048, + APEX_BAR2_REG_KERNEL_HIB_DMA_PAUSE = 0x46050, + APEX_BAR2_REG_KERNEL_HIB_DMA_PAUSE_MASK = 0x46058, + APEX_BAR2_REG_KERNEL_HIB_STATUS_BLOCK_DELAY = 0x46060, + APEX_BAR2_REG_KERNEL_HIB_MSIX_PENDING_BIT_ARRAY0 = 0x46068, + APEX_BAR2_REG_KERNEL_HIB_MSIX_PENDING_BIT_ARRAY1 = 0x46070, + APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT = 0x46078, + APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT = 0x46080, + APEX_BAR2_REG_KERNEL_WIRE_INT_PENDING_BIT_ARRAY = 0x48778, + APEX_BAR2_REG_KERNEL_WIRE_INT_MASK_ARRAY = 0x48780, + APEX_BAR2_REG_USER_HIB_DMA_PAUSE = 0x486D8, + APEX_BAR2_REG_USER_HIB_DMA_PAUSED = 0x486E0, + APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER = 0x4A000, + APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE = 0x50000, + + /* Error registers - Used mostly for debug */ + APEX_BAR2_REG_USER_HIB_ERROR_STATUS = 0x86f0, + APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS = 0x41a0, +}; + +/* Addresses for packed registers. */ +#define APEX_BAR2_REG_AXI_QUIESCE (APEX_BAR2_REG_SCU_BASE + 0x2C) +#define APEX_BAR2_REG_GCB_CLOCK_GATE (APEX_BAR2_REG_SCU_BASE + 0x14) +#define APEX_BAR2_REG_SCU_0 (APEX_BAR2_REG_SCU_BASE + 0xc) +#define APEX_BAR2_REG_SCU_1 (APEX_BAR2_REG_SCU_BASE + 0x10) +#define APEX_BAR2_REG_SCU_2 (APEX_BAR2_REG_SCU_BASE + 0x14) +#define APEX_BAR2_REG_SCU_3 (APEX_BAR2_REG_SCU_BASE + 0x18) +#define APEX_BAR2_REG_SCU_4 (APEX_BAR2_REG_SCU_BASE + 0x1c) +#define APEX_BAR2_REG_SCU_5 (APEX_BAR2_REG_SCU_BASE + 0x20) + +#define SCU3_RG_PWR_STATE_OVR_BIT_OFFSET 26 +#define SCU3_RG_PWR_STATE_OVR_MASK_WIDTH 2 +#define SCU3_CUR_RST_GCB_BIT_MASK 0x10 +#define SCU2_RG_RST_GCB_BIT_MASK 0xc + +/* Configuration for page table. */ +static struct gasket_page_table_config apex_page_table_configs[NUM_NODES] = { + { + .id = 0, + .mode = GASKET_PAGE_TABLE_MODE_NORMAL, + .total_entries = APEX_PAGE_TABLE_TOTAL_ENTRIES, + .base_reg = APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE, + .extended_reg = APEX_BAR2_REG_KERNEL_HIB_EXTENDED_TABLE, + .extended_bit = APEX_EXTENDED_SHIFT, + }, +}; + +/* Function declarations */ +static int __init apex_init(void); +static void apex_exit(void); + +static int apex_add_dev_cb(struct gasket_dev *gasket_dev); + +static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev); + +static int apex_device_cleanup(struct gasket_dev *gasket_dev); + +static int apex_device_open_cb(struct gasket_dev *gasket_dev); + +static ssize_t sysfs_show( + struct device *device, struct device_attribute *attr, char *buf); + +static int apex_reset(struct gasket_dev *gasket_dev, uint type); + +static int apex_get_status(struct gasket_dev *gasket_dev); + +static uint apex_ioctl_check_permissions(struct file *file, uint cmd); + +static long apex_ioctl(struct file *file, uint cmd, ulong arg); + +static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg); + +static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type); + +static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type); + +static bool is_gcb_in_reset(struct gasket_dev *gasket_dev); + +/* Data definitions */ + +/* The data necessary to display this file's sysfs entries. */ +static struct gasket_sysfs_attribute apex_sysfs_attrs[] = { + GASKET_SYSFS_RO(node_0_page_table_entries, sysfs_show, + ATTR_KERNEL_HIB_PAGE_TABLE_SIZE), + GASKET_SYSFS_RO(node_0_simple_page_table_entries, sysfs_show, + ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE), + GASKET_SYSFS_RO(node_0_num_mapped_pages, sysfs_show, + ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES), + GASKET_END_OF_ATTR_ARRAY +}; + +static const struct pci_device_id apex_pci_ids[] = { + { PCI_DEVICE(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID) }, { 0 } +}; + +/* The regions in the BAR2 space that can be mapped into user space. */ +static const struct gasket_mappable_region mappable_regions[NUM_REGIONS] = { + { 0x40000, 0x1000 }, + { 0x44000, 0x1000 }, + { 0x48000, 0x1000 }, +}; + +static const struct gasket_mappable_region cm_mappable_regions[1] = { { 0x0, + APEX_CH_MEM_BYTES } }; + +/* Interrupt descriptors for Apex */ +static struct gasket_interrupt_desc apex_interrupts[] = { + { + APEX_INTERRUPT_INSTR_QUEUE, + APEX_BAR2_REG_KERNEL_HIB_INSTR_QUEUE_INTVECCTL, + UNPACKED, + }, + { + APEX_INTERRUPT_INPUT_ACTV_QUEUE, + APEX_BAR2_REG_KERNEL_HIB_INPUT_ACTV_QUEUE_INTVECCTL, + UNPACKED + }, + { + APEX_INTERRUPT_PARAM_QUEUE, + APEX_BAR2_REG_KERNEL_HIB_PARAM_QUEUE_INTVECCTL, + UNPACKED + }, + { + APEX_INTERRUPT_OUTPUT_ACTV_QUEUE, + APEX_BAR2_REG_KERNEL_HIB_OUTPUT_ACTV_QUEUE_INTVECCTL, + UNPACKED + }, + { + APEX_INTERRUPT_SC_HOST_0, + APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL, + PACK_0 + }, + { + APEX_INTERRUPT_SC_HOST_1, + APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL, + PACK_1 + }, + { + APEX_INTERRUPT_SC_HOST_2, + APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL, + PACK_2 + }, + { + APEX_INTERRUPT_SC_HOST_3, + APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL, + PACK_3 + }, + { + APEX_INTERRUPT_TOP_LEVEL_0, + APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL, + PACK_0 + }, + { + APEX_INTERRUPT_TOP_LEVEL_1, + APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL, + PACK_1 + }, + { + APEX_INTERRUPT_TOP_LEVEL_2, + APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL, + PACK_2 + }, + { + APEX_INTERRUPT_TOP_LEVEL_3, + APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL, + PACK_3 + }, + { + APEX_INTERRUPT_FATAL_ERR, + APEX_BAR2_REG_KERNEL_HIB_FATAL_ERR_INTVECCTL, + UNPACKED + }, +}; + +static struct gasket_driver_desc apex_desc = { + .name = "apex", + .driver_version = APEX_DRIVER_VERSION, + .major = 120, + .minor = 0, + .module = THIS_MODULE, + .pci_id_table = apex_pci_ids, + + .num_page_tables = NUM_NODES, + .page_table_bar_index = APEX_BAR_INDEX, + .page_table_configs = apex_page_table_configs, + .page_table_extended_bit = APEX_EXTENDED_SHIFT, + + .bar_descriptions = { + GASKET_UNUSED_BAR, + GASKET_UNUSED_BAR, + { APEX_BAR_BYTES, (VM_WRITE | VM_READ), APEX_BAR_OFFSET, + NUM_REGIONS, mappable_regions, PCI_BAR }, + GASKET_UNUSED_BAR, + GASKET_UNUSED_BAR, + GASKET_UNUSED_BAR, + }, + .coherent_buffer_description = { + APEX_CH_MEM_BYTES, + (VM_WRITE | VM_READ), + APEX_CM_OFFSET, + }, + .interrupt_type = PCI_MSIX, + .interrupt_bar_index = APEX_BAR_INDEX, + .num_interrupts = APEX_INTERRUPT_COUNT, + .interrupts = apex_interrupts, + .interrupt_pack_width = 7, + + .add_dev_cb = apex_add_dev_cb, + .remove_dev_cb = NULL, + + .enable_dev_cb = NULL, + .disable_dev_cb = NULL, + + .sysfs_setup_cb = apex_sysfs_setup_cb, + .sysfs_cleanup_cb = NULL, + + .device_open_cb = apex_device_open_cb, + .device_close_cb = apex_device_cleanup, + + .ioctl_handler_cb = apex_ioctl, + .device_status_cb = apex_get_status, + .hardware_revision_cb = NULL, + .device_reset_cb = apex_reset, +}; + +/* Module registration boilerplate */ +MODULE_DESCRIPTION("Google Apex driver"); +MODULE_VERSION(APEX_DRIVER_VERSION); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("John Joseph "); +MODULE_DEVICE_TABLE(pci, apex_pci_ids); +module_init(apex_init); +module_exit(apex_exit); + +/* Allows device to enter power save upon driver close(). */ +static int allow_power_save; + +/* Allows SW based clock gating. */ +static int allow_sw_clock_gating; + +/* Allows HW based clock gating. */ +/* Note: this is not mutual exclusive with SW clock gating. */ +static int allow_hw_clock_gating = 1; + +/* Act as if only GCB is instantiated. */ +static int bypass_top_level; + +module_param(allow_power_save, int, 0644); +module_param(allow_sw_clock_gating, int, 0644); +module_param(allow_hw_clock_gating, int, 0644); +module_param(bypass_top_level, int, 0644); + +static int __init apex_init(void) +{ + return gasket_register_device(&apex_desc); +} + +static void apex_exit(void) +{ + gasket_unregister_device(&apex_desc); +} + +static int apex_add_dev_cb(struct gasket_dev *gasket_dev) +{ + ulong page_table_ready, msix_table_ready; + int retries = 0; + + gasket_log_error(gasket_dev, "apex_add_dev_cb."); + + apex_reset(gasket_dev, 0); + + while (retries < APEX_RESET_RETRY) { + page_table_ready = + gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT); + msix_table_ready = + gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT); + if (page_table_ready && msix_table_ready) + break; + schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY)); + retries++; + } + + if (retries == APEX_RESET_RETRY) { + if (!page_table_ready) + gasket_log_error( + gasket_dev, "Page table init timed out."); + if (!msix_table_ready) + gasket_log_error( + gasket_dev, "MSI-X table init timed out."); + return -ETIMEDOUT; + } + + return 0; +} + +static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev) +{ + return gasket_sysfs_create_entries( + gasket_dev->dev_info.device, apex_sysfs_attrs); +} + +/* On device open, we want to perform a core reinit reset. */ +static int apex_device_open_cb(struct gasket_dev *gasket_dev) +{ + return gasket_reset_nolock(gasket_dev, APEX_CHIP_REINIT_RESET); +} + +/** + * apex_get_status - Set device status. + * @dev: Apex device struct. + * + * Description: Check the device status registers and set the driver status + * to ALIVE or DEAD. + * + * Returns 0 if status is ALIVE, a negative error number otherwise. + */ +static int apex_get_status(struct gasket_dev *gasket_dev) +{ + /* TODO: Check device status. */ + return GASKET_STATUS_ALIVE; +} + +/** + * apex_device_cleanup - Clean up Apex HW after close. + * @gasket_dev: Gasket device pointer. + * + * Description: Resets the Apex hardware. Called on final close via + * device_close_cb. + */ +static int apex_device_cleanup(struct gasket_dev *gasket_dev) +{ + u64 scalar_error; + u64 hib_error; + int ret = 0; + + hib_error = gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_USER_HIB_ERROR_STATUS); + scalar_error = gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS); + + gasket_log_info( + gasket_dev, + "apex_device_cleanup 0x%p hib_error 0x%llx scalar_error " + "0x%llx.", + gasket_dev, hib_error, scalar_error); + + if (allow_power_save) + ret = apex_enter_reset(gasket_dev, APEX_CHIP_REINIT_RESET); + + return ret; +} + +/** + * apex_reset - Quits reset. + * @gasket_dev: Gasket device pointer. + * + * Description: Resets the hardware, then quits reset. + * Called on device open. + * + */ +static int apex_reset(struct gasket_dev *gasket_dev, uint type) +{ + int ret; + + if (bypass_top_level) + return 0; + + gasket_log_debug(gasket_dev, "apex_reset."); + + if (!is_gcb_in_reset(gasket_dev)) { + /* We are not in reset - toggle the reset bit so as to force + * re-init of custom block + */ + gasket_log_debug(gasket_dev, "apex_reset: toggle reset."); + + ret = apex_enter_reset(gasket_dev, type); + if (ret) + return ret; + } + ret = apex_quit_reset(gasket_dev, type); + + return ret; +} + +/* + * Enters GCB reset state. + */ +static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) +{ + if (bypass_top_level) + return 0; + + gasket_log_debug(gasket_dev, "apex_enter_reset."); + + /* + * Software reset: + * Enable sleep mode + * - Software force GCB idle + * - Enable GCB idle + */ + gasket_read_modify_write_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER, 0x0, 1, 32); + + /* - Initiate DMA pause */ + gasket_dev_write_64(gasket_dev, 1, APEX_BAR_INDEX, + APEX_BAR2_REG_USER_HIB_DMA_PAUSE); + + /* - Wait for DMA pause complete. */ + if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_USER_HIB_DMA_PAUSED, 1, 1, + APEX_RESET_DELAY, APEX_RESET_RETRY)) { + gasket_log_error(gasket_dev, + "DMAs did not quiece within timeout (%d ms)", + APEX_RESET_RETRY * APEX_RESET_DELAY); + return -EINVAL; + } + + /* - Enable GCB reset (0x1 to rg_rst_gcb) */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x1, 2, 2); + + /* - Enable GCB clock Gate (0x1 to rg_gated_gcb) */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x1, 2, 18); + + /* - Enable GCB memory shut down (0x3 to rg_force_ram_sd) */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 0x3, 2, 14); + + /* - Wait for RAM shutdown. */ + if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3, 1 << 6, 1 << 6, + APEX_RESET_DELAY, APEX_RESET_RETRY)) { + gasket_log_error( + gasket_dev, + "RAM did not shut down within timeout (%d ms)", + APEX_RESET_RETRY * APEX_RESET_DELAY); + return -EINVAL; + } + + return 0; +} + +/* + * Quits GCB reset state. + */ +static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) +{ + u32 val0, val1; + + if (bypass_top_level) + return 0; + + gasket_log_debug(gasket_dev, "apex_quit_reset."); + + /* + * Disable sleep mode: + * - Disable GCB memory shut down: + * - b00: Not forced (HW controlled) + * - b1x: Force disable + */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 0x0, 2, 14); + + /* + * - Disable software clock gate: + * - b00: Not forced (HW controlled) + * - b1x: Force disable + */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x0, 2, 18); + + /* + * - Disable GCB reset (rg_rst_gcb): + * - b00: Not forced (HW controlled) + * - b1x: Force disable = Force not Reset + */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x2, 2, 2); + + /* - Wait for RAM enable. */ + if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3, 1 << 6, 0, + APEX_RESET_DELAY, APEX_RESET_RETRY)) { + gasket_log_error( + gasket_dev, + "RAM did not enable within timeout (%d ms)", + APEX_RESET_RETRY * APEX_RESET_DELAY); + return -EINVAL; + } + + /* - Wait for Reset complete. */ + if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3, + SCU3_CUR_RST_GCB_BIT_MASK, 0, + APEX_RESET_DELAY, APEX_RESET_RETRY)) { + gasket_log_error( + gasket_dev, + "GCB did not leave reset within timeout (%d ms)", + APEX_RESET_RETRY * APEX_RESET_DELAY); + return -EINVAL; + } + + if (!allow_hw_clock_gating) { + val0 = gasket_dev_read_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + /* Inactive and Sleep mode are disabled. */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 0x3, + SCU3_RG_PWR_STATE_OVR_MASK_WIDTH, + SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); + val1 = gasket_dev_read_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + gasket_log_error( + gasket_dev, "Disallow HW clock gating 0x%x -> 0x%x", + val0, val1); + } else { + val0 = gasket_dev_read_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + /* Inactive mode enabled - Sleep mode disabled. */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 2, + SCU3_RG_PWR_STATE_OVR_MASK_WIDTH, + SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); + val1 = gasket_dev_read_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + gasket_log_error( + gasket_dev, "Allow HW clock gating 0x%x -> 0x%x", val0, + val1); + } + + return 0; +} + +/* + * Determines if GCB is in reset state. + */ +static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) +{ + u32 val = gasket_dev_read_32( + gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + + /* Masks rg_rst_gcb bit of SCU_CTRL_2 */ + return (val & SCU3_CUR_RST_GCB_BIT_MASK); +} + +/* + * Check permissions for Apex ioctls. + * @file: File pointer from ioctl. + * @cmd: ioctl command. + * + * Returns 1 if the current user may execute this ioctl, and 0 otherwise. + */ +static uint apex_ioctl_check_permissions(struct file *filp, uint cmd) +{ + struct gasket_dev *gasket_dev = filp->private_data; + int root = capable(CAP_SYS_ADMIN); + int is_owner = gasket_dev->dev_info.ownership.is_owned && + current->tgid == gasket_dev->dev_info.ownership.owner; + + if (root || is_owner) + return 1; + return 0; +} + +/* + * Apex-specific ioctl handler. + */ +static long apex_ioctl(struct file *filp, uint cmd, ulong arg) +{ + struct gasket_dev *gasket_dev = filp->private_data; + + if (!apex_ioctl_check_permissions(filp, cmd)) + return -EPERM; + + switch (cmd) { + case APEX_IOCTL_GATE_CLOCK: + return apex_clock_gating(gasket_dev, arg); + default: + return -ENOTTY; /* unknown command */ + } +} + +/* + * Gates or un-gates Apex clock. + * @gasket_dev: Gasket device pointer. + * @arg: User ioctl arg, in this case to a apex_gate_clock_ioctl struct. + */ +static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg) +{ + struct apex_gate_clock_ioctl ibuf; + + if (bypass_top_level) + return 0; + + if (allow_sw_clock_gating) { + if (copy_from_user(&ibuf, (void __user *)arg, sizeof(ibuf))) + return -EFAULT; + + gasket_log_error( + gasket_dev, "apex_clock_gating %llu", ibuf.enable); + + if (ibuf.enable) { + /* Quiesce AXI, gate GCB clock. */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_AXI_QUIESCE, 0x1, 1, 16); + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_GCB_CLOCK_GATE, 0x1, 2, 18); + } else { + /* Un-gate GCB clock, un-quiesce AXI. */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_GCB_CLOCK_GATE, 0x0, 2, 18); + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_AXI_QUIESCE, 0x0, 1, 16); + } + } + return 0; +} + +/* + * Display driver sysfs entries. + * @device: Kernel device structure. + * @attr: Attribute to display. + * @buf: Buffer to which to write output. + * + * Description: Looks up the driver data and file-specific attribute data (the + * type of the attribute), then fills "buf" accordingly. + */ +static ssize_t sysfs_show( + struct device *device, struct device_attribute *attr, char *buf) +{ + int ret; + struct gasket_dev *gasket_dev; + struct gasket_sysfs_attribute *gasket_attr; + enum sysfs_attribute_type type; + + gasket_dev = gasket_sysfs_get_device_data(device); + if (!gasket_dev) { + gasket_nodev_error("No Apex device sysfs mapping found"); + return 0; + } + + gasket_attr = gasket_sysfs_get_attr(device, attr); + if (!gasket_attr) { + gasket_nodev_error("No Apex device sysfs attr data found"); + gasket_sysfs_put_device_data(device, gasket_dev); + return 0; + } + + type = (enum sysfs_attribute_type)gasket_sysfs_get_attr(device, attr); + switch (type) { + case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE: + ret = scnprintf(buf, PAGE_SIZE, "%u\n", + gasket_page_table_num_entries( + gasket_dev->page_table[0])); + break; + case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE: + ret = scnprintf(buf, PAGE_SIZE, "%u\n", + gasket_page_table_num_entries( + gasket_dev->page_table[0])); + break; + case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES: + ret = scnprintf(buf, PAGE_SIZE, "%u\n", + gasket_page_table_num_active_pages( + gasket_dev->page_table[0])); + break; + default: + gasket_log_error( + gasket_dev, "Unknown attribute: %s", attr->attr.name); + ret = 0; + break; + } + + gasket_sysfs_put_attr(device, gasket_attr); + gasket_sysfs_put_device_data(device, gasket_dev); + return ret; +} diff --git a/drivers/staging/gasket/gasket.h b/drivers/staging/gasket/gasket.h new file mode 100644 index 000000000000..593d50820c65 --- /dev/null +++ b/drivers/staging/gasket/gasket.h @@ -0,0 +1,129 @@ +/* Common Gasket device kernel and user space declarations. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __GASKET_H__ +#define __GASKET_H__ + +#include +#include + +/* ioctl structure declarations */ + +/* Ioctl structures are padded to a multiple of 64 bits */ +/* and padded to put 64 bit values on 64 bit boundaries. */ +/* Unsigned 64 bit integers are used to hold pointers. */ +/* This helps compatibility between 32 and 64 bits. */ + +/* + * Common structure for ioctls associating an eventfd with a device interrupt, + * when using the Gasket interrupt module. + */ +struct gasket_interrupt_eventfd { + u64 interrupt; + u64 event_fd; +}; + +/* + * Common structure for ioctls mapping and unmapping buffers when using the + * Gasket page_table module. + */ +struct gasket_page_table_ioctl { + u64 page_table_index; + u64 size; + u64 host_address; + u64 device_address; +}; + +/* + * Common structure for ioctls mapping and unmapping buffers when using the + * Gasket page_table module. + * dma_address: phys addr start of coherent memory, allocated by kernel + */ +struct gasket_coherent_alloc_config_ioctl { + u64 page_table_index; + u64 enable; + u64 size; + u64 dma_address; +}; + +/* Base number for all Gasket-common IOCTLs */ +#define GASKET_IOCTL_BASE 0xDC + +/* Reset the device using the specified reset type. */ +#define GASKET_IOCTL_RESET _IOW(GASKET_IOCTL_BASE, 0, unsigned long) + +/* Associate the specified [event]fd with the specified interrupt. */ +#define GASKET_IOCTL_SET_EVENTFD \ + _IOW(GASKET_IOCTL_BASE, 1, struct gasket_interrupt_eventfd) + +/* + * Clears any eventfd associated with the specified interrupt. The (ulong) + * argument is the interrupt number to clear. + */ +#define GASKET_IOCTL_CLEAR_EVENTFD _IOW(GASKET_IOCTL_BASE, 2, unsigned long) + +/* + * [Loopbacks only] Requests that the loopback device send the specified + * interrupt to the host. The (ulong) argument is the number of the interrupt to + * send. + */ +#define GASKET_IOCTL_LOOPBACK_INTERRUPT \ + _IOW(GASKET_IOCTL_BASE, 3, unsigned long) + +/* Queries the kernel for the number of page tables supported by the device. */ +#define GASKET_IOCTL_NUMBER_PAGE_TABLES _IOR(GASKET_IOCTL_BASE, 4, u64) + +/* + * Queries the kernel for the maximum size of the page table. Only the size and + * page_table_index fields are used from the struct gasket_page_table_ioctl. + */ +#define GASKET_IOCTL_PAGE_TABLE_SIZE \ + _IOWR(GASKET_IOCTL_BASE, 5, struct gasket_page_table_ioctl) + +/* + * Queries the kernel for the current simple page table size. Only the size and + * page_table_index fields are used from the struct gasket_page_table_ioctl. + */ +#define GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE \ + _IOWR(GASKET_IOCTL_BASE, 6, struct gasket_page_table_ioctl) + +/* + * Tells the kernel to change the split between the number of simple and + * extended entries in the given page table. Only the size and page_table_index + * fields are used from the struct gasket_page_table_ioctl. + */ +#define GASKET_IOCTL_PARTITION_PAGE_TABLE \ + _IOW(GASKET_IOCTL_BASE, 7, struct gasket_page_table_ioctl) + +/* + * Tells the kernel to map size bytes at host_address to device_address in + * page_table_index page table. + */ +#define GASKET_IOCTL_MAP_BUFFER \ + _IOW(GASKET_IOCTL_BASE, 8, struct gasket_page_table_ioctl) + +/* + * Tells the kernel to unmap size bytes at host_address from device_address in + * page_table_index page table. + */ +#define GASKET_IOCTL_UNMAP_BUFFER \ + _IOW(GASKET_IOCTL_BASE, 9, struct gasket_page_table_ioctl) + +/* Clear the interrupt counts stored for this device. */ +#define GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS _IO(GASKET_IOCTL_BASE, 10) + +/* Enable/Disable and configure the coherent allocator. */ +#define GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR \ + _IOWR(GASKET_IOCTL_BASE, 11, struct gasket_coherent_alloc_config_ioctl) + +#endif /* __GASKET_H__ */ diff --git a/drivers/staging/gasket/gasket_constants.h b/drivers/staging/gasket/gasket_constants.h new file mode 100644 index 000000000000..b39e3e3f7d2c --- /dev/null +++ b/drivers/staging/gasket/gasket_constants.h @@ -0,0 +1,56 @@ +/* Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __GASKET_CONSTANTS_H__ +#define __GASKET_CONSTANTS_H__ + +#define GASKET_FRAMEWORK_VERSION "1.1.1" + +/* + * The maximum number of simultaneous device types supported by the framework. + */ +#define GASKET_FRAMEWORK_DESC_MAX 2 + +/* The maximum devices per each type. */ +#define GASKET_DEV_MAX 256 + +/* The number of supported (and possible) PCI BARs. */ +#define GASKET_NUM_BARS 6 + +/* The number of supported Gasket page tables per device. */ +#define GASKET_MAX_NUM_PAGE_TABLES 1 + +/* Maximum length of device names (driver name + minor number suffix + NULL). */ +#define GASKET_NAME_MAX 32 + +/* Device status enumeration. */ +enum gasket_status { + /* + * A device is DEAD if it has not been initialized or has had an error. + */ + GASKET_STATUS_DEAD = 0, + /* + * A device is LAMED if the hardware is healthy but the kernel was + * unable to enable some functionality (e.g. interrupts). + */ + GASKET_STATUS_LAMED, + + /* A device is ALIVE if it is ready for operation. */ + GASKET_STATUS_ALIVE, + + /* + * This status is set when the driver is exiting and waiting for all + * handles to be closed. + */ + GASKET_STATUS_DRIVER_EXIT, +}; + +#endif diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c new file mode 100644 index 000000000000..6511a33eb658 --- /dev/null +++ b/drivers/staging/gasket/gasket_core.c @@ -0,0 +1,2157 @@ +/* Gasket generic driver framework. This file contains the implementation + * for the Gasket generic driver framework - the functionality that is common + * across Gasket devices. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include "gasket_core.h" + +#include "gasket_interrupt.h" +#include "gasket_ioctl.h" +#include "gasket_logging.h" +#include "gasket_page_table.h" +#include "gasket_sysfs.h" + +#include +#include +#include + +#ifdef GASKET_KERNEL_TRACE_SUPPORT +#define CREATE_TRACE_POINTS +#include +#else +#define trace_gasket_mmap_exit(x) +#define trace_gasket_mmap_entry(x, ...) +#endif + +/* + * "Private" members of gasket_driver_desc. + * + * Contains internal per-device type tracking data, i.e., data not appropriate + * as part of the public interface for the generic framework. + */ +struct gasket_internal_desc { + /* Device-specific-driver-provided configuration information. */ + const struct gasket_driver_desc *driver_desc; + + /* Protects access to per-driver data (i.e. this structure). */ + struct mutex mutex; + + /* Kernel-internal device class. */ + struct class *class; + + /* PCI subsystem metadata associated with this driver. */ + struct pci_driver pci; + + /* Instantiated / present devices of this type. */ + struct gasket_dev *devs[GASKET_DEV_MAX]; +}; + +/* do_map_region() needs be able to return more than just true/false. */ +enum do_map_region_status { + /* The region was successfully mapped. */ + DO_MAP_REGION_SUCCESS, + + /* Attempted to map region and failed. */ + DO_MAP_REGION_FAILURE, + + /* The requested region to map was not part of a mappable region. */ + DO_MAP_REGION_INVALID, +}; + +/* Function declarations; comments are with definitions. */ +static int __init gasket_init(void); +static void __exit gasket_exit(void); + +static int gasket_pci_probe( + struct pci_dev *pci_dev, const struct pci_device_id *id); +static void gasket_pci_remove(struct pci_dev *pci_dev); + +static int gasket_setup_pci(struct pci_dev *pci_dev, struct gasket_dev *dev); +static void gasket_cleanup_pci(struct gasket_dev *dev); + +static int gasket_map_pci_bar(struct gasket_dev *dev, int bar_num); +static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num); + +static int gasket_alloc_dev( + struct gasket_internal_desc *internal_desc, struct device *dev, + struct gasket_dev **pdev, const char *kobj_name); +static void gasket_free_dev(struct gasket_dev *dev); + +static int gasket_find_dev_slot( + struct gasket_internal_desc *internal_desc, const char *kobj_name); + +static int gasket_add_cdev( + struct gasket_cdev_info *dev_info, + const struct file_operations *file_ops, struct module *owner); + +static int gasket_enable_dev( + struct gasket_internal_desc *internal_desc, + struct gasket_dev *gasket_dev); +static void gasket_disable_dev(struct gasket_dev *gasket_dev); + +static struct gasket_internal_desc *lookup_internal_desc( + struct pci_dev *pci_dev); + +static ssize_t gasket_sysfs_data_show( + struct device *device, struct device_attribute *attr, char *buf); + +static int gasket_mmap(struct file *filp, struct vm_area_struct *vma); +static int gasket_open(struct inode *inode, struct file *file); +static int gasket_release(struct inode *inode, struct file *file); +static long gasket_ioctl(struct file *filp, uint cmd, ulong arg); + +static int gasket_mm_vma_bar_offset( + const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, + ulong *bar_offset); +static bool gasket_mm_get_mapping_addrs( + const struct gasket_mappable_region *region, ulong bar_offset, + ulong requested_length, struct gasket_mappable_region *mappable_region, + ulong *virt_offset); +static enum do_map_region_status do_map_region( + const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, + struct gasket_mappable_region *map_region); + +static int gasket_get_hw_status(struct gasket_dev *gasket_dev); + +/* Global data definitions. */ +/* Mutex - only for framework-wide data. Other data should be protected by + * finer-grained locks. + */ +static DEFINE_MUTEX(g_mutex); + +/* List of all registered device descriptions & their supporting data. */ +static struct gasket_internal_desc g_descs[GASKET_FRAMEWORK_DESC_MAX]; + +/* Mapping of statuses to human-readable strings. Must end with {0,NULL}. */ +static const struct gasket_num_name gasket_status_name_table[] = { + { GASKET_STATUS_DEAD, "DEAD" }, + { GASKET_STATUS_ALIVE, "ALIVE" }, + { GASKET_STATUS_LAMED, "LAMED" }, + { GASKET_STATUS_DRIVER_EXIT, "DRIVER_EXITING" }, + { 0, NULL }, +}; + +/* Enumeration of the automatic Gasket framework sysfs nodes. */ +enum gasket_sysfs_attribute_type { + ATTR_BAR_OFFSETS, + ATTR_BAR_SIZES, + ATTR_DRIVER_VERSION, + ATTR_FRAMEWORK_VERSION, + ATTR_DEVICE_TYPE, + ATTR_HARDWARE_REVISION, + ATTR_PCI_ADDRESS, + ATTR_STATUS, + ATTR_IS_DEVICE_OWNED, + ATTR_DEVICE_OWNER, + ATTR_WRITE_OPEN_COUNT, + ATTR_RESET_COUNT, + ATTR_USER_MEM_RANGES +}; + +/* File operations for all Gasket devices. */ +static const struct file_operations gasket_file_ops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .mmap = gasket_mmap, + .open = gasket_open, + .release = gasket_release, + .unlocked_ioctl = gasket_ioctl, +}; + +/* These attributes apply to all Gasket driver instances. */ +static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = { + GASKET_SYSFS_RO(bar_offsets, gasket_sysfs_data_show, ATTR_BAR_OFFSETS), + GASKET_SYSFS_RO(bar_sizes, gasket_sysfs_data_show, ATTR_BAR_SIZES), + GASKET_SYSFS_RO(driver_version, gasket_sysfs_data_show, + ATTR_DRIVER_VERSION), + GASKET_SYSFS_RO(framework_version, gasket_sysfs_data_show, + ATTR_FRAMEWORK_VERSION), + GASKET_SYSFS_RO(device_type, gasket_sysfs_data_show, ATTR_DEVICE_TYPE), + GASKET_SYSFS_RO(revision, gasket_sysfs_data_show, + ATTR_HARDWARE_REVISION), + GASKET_SYSFS_RO(pci_address, gasket_sysfs_data_show, ATTR_PCI_ADDRESS), + GASKET_SYSFS_RO(status, gasket_sysfs_data_show, ATTR_STATUS), + GASKET_SYSFS_RO(is_device_owned, gasket_sysfs_data_show, + ATTR_IS_DEVICE_OWNED), + GASKET_SYSFS_RO(device_owner, gasket_sysfs_data_show, + ATTR_DEVICE_OWNER), + GASKET_SYSFS_RO(write_open_count, gasket_sysfs_data_show, + ATTR_WRITE_OPEN_COUNT), + GASKET_SYSFS_RO(reset_count, gasket_sysfs_data_show, ATTR_RESET_COUNT), + GASKET_SYSFS_RO(user_mem_ranges, gasket_sysfs_data_show, + ATTR_USER_MEM_RANGES), + GASKET_END_OF_ATTR_ARRAY +}; + +MODULE_DESCRIPTION("Google Gasket driver framework"); +MODULE_VERSION(GASKET_FRAMEWORK_VERSION); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Rob Springer "); +module_init(gasket_init); +module_exit(gasket_exit); + +/* + * Perform a standard Gasket callback. + * @gasket_dev: Device specific pointer to forward. + * @cb_function: Standard callback to perform. + */ +static inline int check_and_invoke_callback( + struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) +{ + int ret = 0; + + gasket_nodev_error("check_and_invoke_callback %p", gasket_dev); + if (cb_function) { + mutex_lock(&gasket_dev->mutex); + ret = cb_function(gasket_dev); + mutex_unlock(&gasket_dev->mutex); + } + return ret; +} + +/* + * Perform a standard Gasket callback + * without grabbing gasket_dev->mutex. + * @gasket_dev: Device specific pointer to forward. + * @cb_function: Standard callback to perform. + * + */ +static inline int gasket_check_and_invoke_callback_nolock( + struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) +{ + int ret = 0; + + if (cb_function) { + gasket_log_info( + gasket_dev, "Invoking device-specific callback."); + ret = cb_function(gasket_dev); + } + return ret; +} + +/* + * Retrieve device-specific data via cdev pointer. + * @cdev_ptr: Character device pointer associated with the device. + * + * This function returns the pointer to the device-specific data allocated in + * add_dev_cb for the device associated with cdev_ptr. + */ +static struct gasket_cdev_info *gasket_cdev_get_info(struct cdev *cdev_ptr) +{ + return container_of(cdev_ptr, struct gasket_cdev_info, cdev); +} + +/* + * Returns nonzero if the gasket_cdev_info is owned by the current thread group + * ID. + * @info: Device node info. + */ +static int gasket_owned_by_current_tgid(struct gasket_cdev_info *info) +{ + return (info->ownership.is_owned && + (info->ownership.owner == current->tgid)); +} + +static int __init gasket_init(void) +{ + int i; + + gasket_nodev_info("Performing one-time init of the Gasket framework."); + /* Check for duplicates and find a free slot. */ + mutex_lock(&g_mutex); + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + g_descs[i].driver_desc = NULL; + mutex_init(&g_descs[i].mutex); + } + + gasket_sysfs_init(); + + mutex_unlock(&g_mutex); + return 0; +} + +static void __exit gasket_exit(void) +{ + /* No deinit/dealloc needed at present. */ + gasket_nodev_info("Removing Gasket framework module."); +} + +/* See gasket_core.h for description. */ +int gasket_register_device(const struct gasket_driver_desc *driver_desc) +{ + int i, ret; + int desc_idx = -1; + struct gasket_internal_desc *internal; + + gasket_nodev_info("Initializing Gasket framework device"); + /* Check for duplicates and find a free slot. */ + mutex_lock(&g_mutex); + + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + if (g_descs[i].driver_desc == driver_desc) { + gasket_nodev_error( + "%s driver already loaded/registered", + driver_desc->name); + mutex_unlock(&g_mutex); + return -EBUSY; + } + } + + /* This and the above loop could be combined, but this reads easier. */ + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + if (!g_descs[i].driver_desc) { + g_descs[i].driver_desc = driver_desc; + desc_idx = i; + break; + } + } + mutex_unlock(&g_mutex); + + gasket_nodev_info("Loaded %s driver, framework version %s", + driver_desc->name, GASKET_FRAMEWORK_VERSION); + + if (desc_idx == -1) { + gasket_nodev_error("Too many Gasket drivers loaded: %d\n", + GASKET_FRAMEWORK_DESC_MAX); + return -EBUSY; + } + + /* Internal structure setup. */ + gasket_nodev_info("Performing initial internal structure setup."); + internal = &g_descs[desc_idx]; + mutex_init(&internal->mutex); + memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX); + memset(&internal->pci, 0, sizeof(internal->pci)); + internal->pci.name = driver_desc->name; + internal->pci.id_table = driver_desc->pci_id_table; + internal->pci.probe = gasket_pci_probe; + internal->pci.remove = gasket_pci_remove; + internal->class = + class_create(driver_desc->module, driver_desc->name); + + if (IS_ERR_OR_NULL(internal->class)) { + gasket_nodev_error("Cannot register %s class [ret=%ld]", + driver_desc->name, PTR_ERR(internal->class)); + return PTR_ERR(internal->class); + } + + /* + * Not using pci_register_driver() (without underscores), as it + * depends on KBUILD_MODNAME, and this is a shared file. + */ + gasket_nodev_info("Registering PCI driver."); + ret = __pci_register_driver( + &internal->pci, driver_desc->module, driver_desc->name); + if (ret) { + gasket_nodev_error( + "cannot register pci driver [ret=%d]", ret); + goto fail1; + } + + gasket_nodev_info("Registering char driver."); + ret = register_chrdev_region( + MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, + driver_desc->name); + if (ret) { + gasket_nodev_error("cannot register char driver [ret=%d]", ret); + goto fail2; + } + + gasket_nodev_info("Driver registered successfully."); + return 0; + +fail2: + pci_unregister_driver(&internal->pci); + +fail1: + class_destroy(internal->class); + + g_descs[desc_idx].driver_desc = NULL; + return ret; +} +EXPORT_SYMBOL(gasket_register_device); + +/* See gasket_core.h for description. */ +void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) +{ + int i, desc_idx; + struct gasket_internal_desc *internal_desc = NULL; + + mutex_lock(&g_mutex); + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + if (g_descs[i].driver_desc == driver_desc) { + internal_desc = &g_descs[i]; + desc_idx = i; + break; + } + } + mutex_unlock(&g_mutex); + + if (!internal_desc) { + gasket_nodev_error( + "request to unregister unknown desc: %s, %d:%d", + driver_desc->name, driver_desc->major, + driver_desc->minor); + return; + } + + unregister_chrdev_region( + MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX); + + pci_unregister_driver(&internal_desc->pci); + + class_destroy(internal_desc->class); + + /* Finally, effectively "remove" the driver. */ + g_descs[desc_idx].driver_desc = NULL; + + gasket_nodev_info("removed %s driver", driver_desc->name); +} +EXPORT_SYMBOL(gasket_unregister_device); + +/** + * Allocate a Gasket device. + * @internal_desc: Pointer to the internal data for the device driver. + * @pdev: Pointer to the Gasket device pointer, the allocated device. + * @kobj_name: PCIe name for the device + * + * Description: Allocates and initializes a Gasket device structure. + * Adds the device to the device list. + * + * Returns 0 if successful, a negative error code otherwise. + */ +static int gasket_alloc_dev( + struct gasket_internal_desc *internal_desc, struct device *parent, + struct gasket_dev **pdev, const char *kobj_name) +{ + int dev_idx; + const struct gasket_driver_desc *driver_desc = + internal_desc->driver_desc; + struct gasket_dev *gasket_dev; + struct gasket_cdev_info *dev_info; + + gasket_nodev_info("Allocating a Gasket device %s.", kobj_name); + + *pdev = NULL; + + dev_idx = gasket_find_dev_slot(internal_desc, kobj_name); + if (dev_idx < 0) + return dev_idx; + + gasket_dev = *pdev = kzalloc(sizeof(*gasket_dev), GFP_KERNEL); + if (!gasket_dev) { + gasket_nodev_error("no memory for device"); + return -ENOMEM; + } + internal_desc->devs[dev_idx] = gasket_dev; + + mutex_init(&gasket_dev->mutex); + + gasket_dev->internal_desc = internal_desc; + gasket_dev->dev_idx = dev_idx; + snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", kobj_name); + /* gasket_bar_data is uninitialized. */ + gasket_dev->num_page_tables = driver_desc->num_page_tables; + /* max_page_table_size and *page table are uninit'ed */ + /* interrupt_data is not initialized. */ + /* status is 0, or GASKET_STATUS_DEAD */ + + dev_info = &gasket_dev->dev_info; + snprintf(dev_info->name, GASKET_NAME_MAX, "%s_%u", driver_desc->name, + gasket_dev->dev_idx); + dev_info->devt = + MKDEV(driver_desc->major, driver_desc->minor + + gasket_dev->dev_idx); + dev_info->device = device_create(internal_desc->class, parent, + dev_info->devt, gasket_dev, dev_info->name); + + gasket_nodev_info("Gasket device allocated: %p.", dev_info->device); + + /* cdev has not yet been added; cdev_added is 0 */ + dev_info->gasket_dev_ptr = gasket_dev; + /* ownership is all 0, indicating no owner or opens. */ + + return 0; +} + +/* + * Free a Gasket device. + * @internal_dev: Gasket device pointer; the device to unregister and free. + * + * Description: Removes the device from the device list and frees + * the Gasket device structure. + */ +static void gasket_free_dev(struct gasket_dev *gasket_dev) +{ + struct gasket_internal_desc *internal_desc = gasket_dev->internal_desc; + + mutex_lock(&internal_desc->mutex); + internal_desc->devs[gasket_dev->dev_idx] = NULL; + mutex_unlock(&internal_desc->mutex); + + kfree(gasket_dev); +} + +/* + * Finds the next free gasket_internal_dev slot. + * + * Returns the located slot number on success or a negative number on failure. + */ +static int gasket_find_dev_slot( + struct gasket_internal_desc *internal_desc, const char *kobj_name) +{ + int i; + + mutex_lock(&internal_desc->mutex); + + /* Search for a previous instance of this device. */ + for (i = 0; i < GASKET_DEV_MAX; i++) { + if (internal_desc->devs[i] && + strcmp(internal_desc->devs[i]->kobj_name, kobj_name) == 0) { + gasket_nodev_error("Duplicate device %s", kobj_name); + mutex_unlock(&internal_desc->mutex); + return -EBUSY; + } + } + + /* Find a free device slot. */ + for (i = 0; i < GASKET_DEV_MAX; i++) { + if (!internal_desc->devs[i]) + break; + } + + if (i == GASKET_DEV_MAX) { + gasket_nodev_info( + "Too many registered devices; max %d", GASKET_DEV_MAX); + mutex_unlock(&internal_desc->mutex); + return -EBUSY; + } + + mutex_unlock(&internal_desc->mutex); + return i; +} + +/** + * PCI subsystem probe function. + * @pci_dev: PCI device pointer to the new device. + * @id: PCI device id structure pointer, the vendor and device ids. + * + * Called when a Gasket device is found. Allocates device metadata, maps device + * memory, and calls gasket_enable_dev to prepare the device for active use. + * + * Returns 0 if successful and a negative value otherwise. + */ +static int gasket_pci_probe( + struct pci_dev *pci_dev, const struct pci_device_id *id) +{ + int ret; + const char *kobj_name = dev_name(&pci_dev->dev); + struct gasket_internal_desc *internal_desc; + struct gasket_dev *gasket_dev; + const struct gasket_driver_desc *driver_desc; + struct device *parent; + + gasket_nodev_info("Add Gasket device %s", kobj_name); + + mutex_lock(&g_mutex); + internal_desc = lookup_internal_desc(pci_dev); + mutex_unlock(&g_mutex); + if (!internal_desc) { + gasket_nodev_info("PCI probe called for unknown driver type"); + return -ENODEV; + } + + driver_desc = internal_desc->driver_desc; + + parent = &pci_dev->dev; + ret = gasket_alloc_dev(internal_desc, parent, &gasket_dev, kobj_name); + if (ret) + return ret; + if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) { + gasket_nodev_error("Cannot create %s device %s [ret = %ld]", + driver_desc->name, gasket_dev->dev_info.name, + PTR_ERR(gasket_dev->dev_info.device)); + ret = -ENODEV; + goto fail1; + } + gasket_dev->pci_dev = pci_dev; + + ret = gasket_setup_pci(pci_dev, gasket_dev); + if (ret) + goto fail2; + + ret = check_and_invoke_callback(gasket_dev, driver_desc->add_dev_cb); + if (ret) { + gasket_log_error(gasket_dev, "Error in add device cb: %d", ret); + goto fail2; + } + + ret = gasket_sysfs_create_mapping( + gasket_dev->dev_info.device, gasket_dev); + if (ret) + goto fail3; + + /* + * Once we've created the mapping structures successfully, attempt to + * create a symlink to the pci directory of this object. + */ + ret = sysfs_create_link(&gasket_dev->dev_info.device->kobj, + &pci_dev->dev.kobj, dev_name(&pci_dev->dev)); + if (ret) { + gasket_log_error( + gasket_dev, "Cannot create sysfs pci link: %d", ret); + goto fail3; + } + ret = gasket_sysfs_create_entries( + gasket_dev->dev_info.device, gasket_sysfs_generic_attrs); + if (ret) + goto fail4; + + ret = check_and_invoke_callback( + gasket_dev, driver_desc->sysfs_setup_cb); + if (ret) { + gasket_log_error( + gasket_dev, "Error in sysfs setup cb: %d", ret); + goto fail5; + } + + ret = gasket_enable_dev(internal_desc, gasket_dev); + if (ret) { + gasket_nodev_error("cannot setup %s device", driver_desc->name); + gasket_disable_dev(gasket_dev); + goto fail5; + } + + return 0; + +fail5: + check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); +fail4: +fail3: + gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); +fail2: + gasket_cleanup_pci(gasket_dev); + check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); + device_destroy(internal_desc->class, gasket_dev->dev_info.devt); +fail1: + gasket_free_dev(gasket_dev); + return ret; +} + +/* + * PCI subsystem remove function. + * @pci_dev: PCI device pointer; the device to remove. + * + * Called to remove a Gasket device. Finds the device in the device list and + * cleans up metadata. + */ +static void gasket_pci_remove(struct pci_dev *pci_dev) +{ + int i; + struct gasket_internal_desc *internal_desc; + struct gasket_dev *gasket_dev = NULL; + const struct gasket_driver_desc *driver_desc; + /* Find the device desc. */ + mutex_lock(&g_mutex); + internal_desc = lookup_internal_desc(pci_dev); + if (!internal_desc) { + mutex_unlock(&g_mutex); + return; + } + mutex_unlock(&g_mutex); + + driver_desc = internal_desc->driver_desc; + + /* Now find the specific device */ + mutex_lock(&internal_desc->mutex); + for (i = 0; i < GASKET_DEV_MAX; i++) { + if (internal_desc->devs[i] && + internal_desc->devs[i]->pci_dev == pci_dev) { + gasket_dev = internal_desc->devs[i]; + break; + } + } + mutex_unlock(&internal_desc->mutex); + + if (!gasket_dev) + return; + + gasket_nodev_info( + "remove %s device %s", internal_desc->driver_desc->name, + gasket_dev->kobj_name); + + gasket_disable_dev(gasket_dev); + gasket_cleanup_pci(gasket_dev); + + check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); + gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); + + check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); + + device_destroy(internal_desc->class, gasket_dev->dev_info.devt); + gasket_free_dev(gasket_dev); +} + +/* + * Setup PCI & set up memory mapping for the specified device. + * @pci_dev: pointer to the particular PCI device. + * @internal_dev: Corresponding Gasket device pointer. + * + * Enables the PCI device, reads the BAR registers and sets up pointers to the + * device's memory mapped IO space. + * + * Returns 0 on success and a negative value otherwise. + */ +static int gasket_setup_pci( + struct pci_dev *pci_dev, struct gasket_dev *gasket_dev) +{ + int i, mapped_bars, ret; + + gasket_dev->pci_dev = pci_dev; + ret = pci_enable_device(pci_dev); + if (ret) { + gasket_log_error(gasket_dev, "cannot enable PCI device"); + return ret; + } + + pci_set_master(pci_dev); + + for (i = 0; i < GASKET_NUM_BARS; i++) { + ret = gasket_map_pci_bar(gasket_dev, i); + if (ret) { + mapped_bars = i; + goto fail; + } + } + + return 0; + +fail: + for (i = 0; i < mapped_bars; i++) + gasket_unmap_pci_bar(gasket_dev, i); + + pci_disable_device(pci_dev); + return -ENOMEM; +} + +/* Unmaps memory and cleans up PCI for the specified device. */ +static void gasket_cleanup_pci(struct gasket_dev *gasket_dev) +{ + int i; + + for (i = 0; i < GASKET_NUM_BARS; i++) + gasket_unmap_pci_bar(gasket_dev, i); + + pci_disable_device(gasket_dev->pci_dev); +} + +/* + * Maps the specified bar into kernel space. + * @internal_dev: Device possessing the BAR to map. + * @bar_num: The BAR to map. + * + * Returns 0 on success, a negative error code otherwise. + * A zero-sized BAR will not be mapped, but is not an error. + */ +static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) +{ + struct gasket_internal_desc *internal_desc = gasket_dev->internal_desc; + const struct gasket_driver_desc *driver_desc = + internal_desc->driver_desc; + ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size; + int ret; + + if (desc_bytes == 0) + return 0; + + if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) { + /* not PCI: skip this entry */ + return 0; + } + /* + * pci_resource_start and pci_resource_len return a "resource_size_t", + * which is safely castable to ulong (which itself is the arg to + * request_mem_region). + */ + gasket_dev->bar_data[bar_num].phys_base = + (ulong)pci_resource_start(gasket_dev->pci_dev, bar_num); + if (!gasket_dev->bar_data[bar_num].phys_base) { + gasket_log_error(gasket_dev, "Cannot get BAR%u base address", + bar_num); + return -EINVAL; + } + + gasket_dev->bar_data[bar_num].length_bytes = + (ulong)pci_resource_len(gasket_dev->pci_dev, bar_num); + if (gasket_dev->bar_data[bar_num].length_bytes < desc_bytes) { + gasket_log_error( + gasket_dev, + "PCI BAR %u space is too small: %lu; expected >= %lu", + bar_num, gasket_dev->bar_data[bar_num].length_bytes, + desc_bytes); + return -ENOMEM; + } + + if (!request_mem_region(gasket_dev->bar_data[bar_num].phys_base, + gasket_dev->bar_data[bar_num].length_bytes, + gasket_dev->dev_info.name)) { + gasket_log_error( + gasket_dev, + "Cannot get BAR %d memory region %p", + bar_num, &gasket_dev->pci_dev->resource[bar_num]); + return -EINVAL; + } + + gasket_dev->bar_data[bar_num].virt_base = + ioremap_nocache(gasket_dev->bar_data[bar_num].phys_base, + gasket_dev->bar_data[bar_num].length_bytes); + if (!gasket_dev->bar_data[bar_num].virt_base) { + gasket_log_error( + gasket_dev, + "Cannot remap BAR %d memory region %p", + bar_num, &gasket_dev->pci_dev->resource[bar_num]); + ret = -ENOMEM; + goto fail; + } + + dma_set_mask(&gasket_dev->pci_dev->dev, DMA_BIT_MASK(64)); + dma_set_coherent_mask(&gasket_dev->pci_dev->dev, DMA_BIT_MASK(64)); + + return 0; + +fail: + iounmap(gasket_dev->bar_data[bar_num].virt_base); + release_mem_region(gasket_dev->bar_data[bar_num].phys_base, + gasket_dev->bar_data[bar_num].length_bytes); + return ret; +} + +/* + * Releases PCI BAR mapping. + * @internal_dev: Device possessing the BAR to unmap. + * + * A zero-sized or not-mapped BAR will not be unmapped, but is not an error. + */ +static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num) +{ + ulong base, bytes; + struct gasket_internal_desc *internal_desc = dev->internal_desc; + const struct gasket_driver_desc *driver_desc = + internal_desc->driver_desc; + + if (driver_desc->bar_descriptions[bar_num].size == 0 || + !dev->bar_data[bar_num].virt_base) + return; + + if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) + return; + + iounmap(dev->bar_data[bar_num].virt_base); + dev->bar_data[bar_num].virt_base = NULL; + + base = pci_resource_start(dev->pci_dev, bar_num); + if (!base) { + gasket_log_error( + dev, "cannot get PCI BAR%u base address", bar_num); + return; + } + + bytes = pci_resource_len(dev->pci_dev, bar_num); + release_mem_region(base, bytes); +} + +/* + * Handle adding a char device and related info. + * @dev_info: Pointer to the dev_info struct for this device. + * @file_ops: The file operations for this device. + * @owner: The owning module for this device. + */ +static int gasket_add_cdev( + struct gasket_cdev_info *dev_info, + const struct file_operations *file_ops, struct module *owner) +{ + int ret; + + cdev_init(&dev_info->cdev, file_ops); + dev_info->cdev.owner = owner; + ret = cdev_add(&dev_info->cdev, dev_info->devt, 1); + if (ret) { + gasket_log_error( + dev_info->gasket_dev_ptr, + "cannot add char device [ret=%d]", ret); + return ret; + } + dev_info->cdev_added = 1; + + return 0; +} + +/* + * Performs final init and marks the device as active. + * @internal_desc: Pointer to Gasket [internal] driver descriptor structure. + * @internal_dev: Pointer to Gasket [internal] device structure. + * + * Currently forwards all work to device-specific callback; a future phase will + * extract elements of character device registration here. + */ +static int gasket_enable_dev( + struct gasket_internal_desc *internal_desc, + struct gasket_dev *gasket_dev) +{ + int tbl_idx; + int ret; + bool has_dma_ops; + struct device *ddev; + const struct gasket_driver_desc *driver_desc = + internal_desc->driver_desc; + + ret = gasket_interrupt_init( + gasket_dev, driver_desc->name, + driver_desc->interrupt_type, driver_desc->interrupts, + driver_desc->num_interrupts, driver_desc->interrupt_pack_width, + driver_desc->interrupt_bar_index, + driver_desc->wire_interrupt_offsets); + if (ret) { + gasket_log_error(gasket_dev, + "Critical failure to allocate interrupts: %d", + ret); + gasket_interrupt_cleanup(gasket_dev); + return ret; + } + + has_dma_ops = true; + + for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { + gasket_log_debug( + gasket_dev, "Initializing page table %d.", tbl_idx); + if (gasket_dev->pci_dev) { + ddev = &gasket_dev->pci_dev->dev; + } else { + gasket_log_error( + gasket_dev, + "gasket_enable_dev with no physical device!!"); + WARN_ON(1); + ddev = NULL; + } + ret = gasket_page_table_init( + &gasket_dev->page_table[tbl_idx], + &gasket_dev->bar_data[ + driver_desc->page_table_bar_index], + &driver_desc->page_table_configs[tbl_idx], + ddev, gasket_dev->pci_dev, has_dma_ops); + if (ret) { + gasket_log_error( + gasket_dev, + "Couldn't init page table %d: %d", + tbl_idx, ret); + return ret; + } + /* + * Make sure that the page table is clear and set to simple + * addresses. + */ + gasket_page_table_reset(gasket_dev->page_table[tbl_idx]); + } + + /* + * hardware_revision_cb returns a positive integer (the rev) if + * successful.) + */ + ret = check_and_invoke_callback( + gasket_dev, driver_desc->hardware_revision_cb); + if (ret < 0) { + gasket_log_error( + gasket_dev, "Error getting hardware revision: %d", ret); + return ret; + } + gasket_dev->hardware_revision = ret; + + ret = check_and_invoke_callback(gasket_dev, driver_desc->enable_dev_cb); + if (ret) { + gasket_log_error( + gasket_dev, "Error in enable device cb: %d", ret); + return ret; + } + + /* device_status_cb returns a device status, not an error code. */ + gasket_dev->status = gasket_get_hw_status(gasket_dev); + if (gasket_dev->status == GASKET_STATUS_DEAD) + gasket_log_error(gasket_dev, "Device reported as unhealthy."); + + ret = gasket_add_cdev( + &gasket_dev->dev_info, &gasket_file_ops, driver_desc->module); + if (ret) + return ret; + + return 0; +} + +/* + * Disable device operations. + * @gasket_dev: Pointer to Gasket device structure. + * + * Currently forwards all work to device-specific callback; a future phase will + * extract elements of character device unregistration here. + */ +static void gasket_disable_dev(struct gasket_dev *gasket_dev) +{ + const struct gasket_driver_desc *driver_desc = + gasket_dev->internal_desc->driver_desc; + int i; + + /* Only delete the device if it has been successfully added. */ + if (gasket_dev->dev_info.cdev_added) + cdev_del(&gasket_dev->dev_info.cdev); + + gasket_dev->status = GASKET_STATUS_DEAD; + + gasket_interrupt_cleanup(gasket_dev); + + for (i = 0; i < driver_desc->num_page_tables; ++i) { + if (gasket_dev->page_table[i]) { + gasket_page_table_reset(gasket_dev->page_table[i]); + gasket_page_table_cleanup(gasket_dev->page_table[i]); + } + } + + check_and_invoke_callback(gasket_dev, driver_desc->disable_dev_cb); +} + +/** + * Registered descriptor lookup. + * + * Precondition: Called with g_mutex held (to avoid a race on return). + * Returns NULL if no matching device was found. + */ +static struct gasket_internal_desc *lookup_internal_desc( + struct pci_dev *pci_dev) +{ + int i; + + __must_hold(&g_mutex); + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + if (g_descs[i].driver_desc && + g_descs[i].driver_desc->pci_id_table && + pci_match_id(g_descs[i].driver_desc->pci_id_table, pci_dev)) + return &g_descs[i]; + } + + return NULL; +} + +/** + * Lookup a name by number in a num_name table. + * @num: Number to lookup. + * @table: Array of num_name structures, the table for the lookup. + * + * Description: Searches for num in the table. If found, the + * corresponding name is returned; otherwise NULL + * is returned. + * + * The table must have a NULL name pointer at the end. + */ +const char *gasket_num_name_lookup( + uint num, const struct gasket_num_name *table) +{ + uint i = 0; + + while (table[i].snn_name) { + if (num == table[i].snn_num) + break; + ++i; + } + + return table[i].snn_name; +} +EXPORT_SYMBOL(gasket_num_name_lookup); + +/** + * Opens the char device file. + * @inode: Inode structure pointer of the device file. + * @file: File structure pointer. + * + * Description: Called on an open of the device file. If the open is for + * writing, and the device is not owned, this process becomes + * the owner. If the open is for writing and the device is + * already owned by some other process, it is an error. If + * this process is the owner, increment the open count. + * + * Returns 0 if successful, a negative error number otherwise. + */ +static int gasket_open(struct inode *inode, struct file *filp) +{ + int ret; + struct gasket_dev *gasket_dev; + const struct gasket_driver_desc *driver_desc; + struct gasket_ownership *ownership; + char task_name[TASK_COMM_LEN]; + struct gasket_cdev_info *dev_info = gasket_cdev_get_info(inode->i_cdev); + + if (!dev_info) { + gasket_nodev_error("Unable to retrieve device data"); + return -EINVAL; + } + gasket_dev = dev_info->gasket_dev_ptr; + driver_desc = gasket_dev->internal_desc->driver_desc; + ownership = &dev_info->ownership; + get_task_comm(task_name, current); + filp->private_data = gasket_dev; + inode->i_size = 0; + + gasket_log_debug( + gasket_dev, + "Attempting to open with tgid %u (%s) (f_mode: 0%03o, " + "fmode_write: %d is_root: %u)", + current->tgid, task_name, filp->f_mode, + (filp->f_mode & FMODE_WRITE), capable(CAP_SYS_ADMIN)); + + /* Always allow non-writing accesses. */ + if (!(filp->f_mode & FMODE_WRITE)) { + gasket_log_debug(gasket_dev, "Allowing read-only opening."); + return 0; + } + + mutex_lock(&gasket_dev->mutex); + + gasket_log_debug( + gasket_dev, "Current owner open count (owning tgid %u): %d.", + ownership->owner, ownership->write_open_count); + + /* Opening a node owned by another TGID is an error (even root.) */ + if (ownership->is_owned && ownership->owner != current->tgid) { + gasket_log_error( + gasket_dev, + "Process %u is opening a node held by %u.", + current->tgid, ownership->owner); + mutex_unlock(&gasket_dev->mutex); + return -EPERM; + } + + /* If the node is not owned, assign it to the current TGID. */ + if (!ownership->is_owned) { + ret = gasket_check_and_invoke_callback_nolock( + gasket_dev, driver_desc->device_open_cb); + if (ret) { + gasket_log_error( + gasket_dev, "Error in device open cb: %d", ret); + mutex_unlock(&gasket_dev->mutex); + return ret; + } + ownership->is_owned = 1; + ownership->owner = current->tgid; + gasket_log_debug(gasket_dev, "Device owner is now tgid %u", + ownership->owner); + } + + ownership->write_open_count++; + + gasket_log_debug(gasket_dev, "New open count (owning tgid %u): %d", + ownership->owner, ownership->write_open_count); + + mutex_unlock(&gasket_dev->mutex); + return 0; +} + +/** + * gasket_release - Close of the char device file. + * @inode: Inode structure pointer of the device file. + * @file: File structure pointer. + * + * Description: Called on a close of the device file. If this process + * is the owner, decrement the open count. On last close + * by the owner, free up buffers and eventfd contexts, and + * release ownership. + * + * Returns 0 if successful, a negative error number otherwise. + */ +static int gasket_release(struct inode *inode, struct file *file) +{ + int i; + struct gasket_dev *gasket_dev; + struct gasket_ownership *ownership; + const struct gasket_driver_desc *driver_desc; + char task_name[TASK_COMM_LEN]; + struct gasket_cdev_info *dev_info = + (struct gasket_cdev_info *)gasket_cdev_get_info(inode->i_cdev); + if (!dev_info) { + gasket_nodev_error("Unable to retrieve device data"); + return -EINVAL; + } + gasket_dev = dev_info->gasket_dev_ptr; + driver_desc = gasket_dev->internal_desc->driver_desc; + ownership = &dev_info->ownership; + get_task_comm(task_name, current); + mutex_lock(&gasket_dev->mutex); + + gasket_log_debug( + gasket_dev, + "Releasing device node. Call origin: tgid %u (%s) " + "(f_mode: 0%03o, fmode_write: %d, is_root: %u)", + current->tgid, task_name, file->f_mode, + (file->f_mode & FMODE_WRITE), capable(CAP_SYS_ADMIN)); + gasket_log_debug(gasket_dev, "Current open count (owning tgid %u): %d", + ownership->owner, ownership->write_open_count); + + if (file->f_mode & FMODE_WRITE) { + ownership->write_open_count--; + if (ownership->write_open_count == 0) { + gasket_log_info(gasket_dev, "Device is now free"); + ownership->is_owned = 0; + ownership->owner = 0; + + /* Forces chip reset before we unmap the page tables. */ + driver_desc->device_reset_cb(gasket_dev, 0); + + for (i = 0; i < driver_desc->num_page_tables; ++i) { + gasket_page_table_unmap_all( + gasket_dev->page_table[i]); + gasket_page_table_garbage_collect( + gasket_dev->page_table[i]); + gasket_free_coherent_memory_all(gasket_dev, i); + } + + /* Closes device, enters power save. */ + gasket_check_and_invoke_callback_nolock( + gasket_dev, driver_desc->device_close_cb); + } + } + + gasket_log_info( + gasket_dev, "New open count (owning tgid %u): %d", + ownership->owner, ownership->write_open_count); + mutex_unlock(&gasket_dev->mutex); + return 0; +} + +/* + * Permission and validity checking for mmap ops. + * @gasket_dev: Gasket device information structure. + * @vma: Standard virtual memory area descriptor. + * + * Verifies that the user has permissions to perform the requested mapping and + * that the provided descriptor/range is of adequate size to hold the range to + * be mapped. + */ +static int gasket_mmap_has_permissions( + struct gasket_dev *gasket_dev, struct vm_area_struct *vma, + int bar_permissions) +{ + int requested_permissions; + /* Always allow sysadmin to access. */ + if (capable(CAP_SYS_ADMIN)) + return 1; + + /* Never allow non-sysadmins to access to a dead device. */ + if (gasket_dev->status != GASKET_STATUS_ALIVE) { + gasket_log_info(gasket_dev, "Device is dead."); + return 0; + } + + /* Make sure that no wrong flags are set. */ + requested_permissions = + (vma->vm_flags & (VM_WRITE | VM_READ | VM_EXEC)); + if (requested_permissions & ~(bar_permissions)) { + gasket_log_info( + gasket_dev, + "Attempting to map a region with requested permissions " + "0x%x, but region has permissions 0x%x.", + requested_permissions, bar_permissions); + return 0; + } + + /* Do not allow a non-owner to write. */ + if ((vma->vm_flags & VM_WRITE) && + !gasket_owned_by_current_tgid(&gasket_dev->dev_info)) { + gasket_log_info( + gasket_dev, + "Attempting to mmap a region for write without owning " + "device."); + return 0; + } + + return 1; +} + +/* + * Checks if an address is within the region + * allocated for coherent buffer. + * @driver_desc: driver description. + * @address: offset of address to check. + * + * Verifies that the input address is within the region allocated to coherent + * buffer. + */ +static bool gasket_is_coherent_region( + const struct gasket_driver_desc *driver_desc, ulong address) +{ + struct gasket_coherent_buffer_desc coh_buff_desc = + driver_desc->coherent_buffer_description; + + if (coh_buff_desc.permissions != GASKET_NOMAP) { + if ((address >= coh_buff_desc.base) && + (address < coh_buff_desc.base + coh_buff_desc.size)) { + return true; + } + } + return false; +} + +static int gasket_get_bar_index( + const struct gasket_dev *gasket_dev, ulong phys_addr) +{ + int i; + const struct gasket_driver_desc *driver_desc; + + driver_desc = gasket_dev->internal_desc->driver_desc; + for (i = 0; i < GASKET_NUM_BARS; ++i) { + struct gasket_bar_desc bar_desc = + driver_desc->bar_descriptions[i]; + + if (bar_desc.permissions != GASKET_NOMAP) { + if (phys_addr >= bar_desc.base && + phys_addr < (bar_desc.base + bar_desc.size)) { + return i; + } + } + } + /* If we haven't found the address by now, it is invalid. */ + return -EINVAL; +} + +/* + * Sets the actual bounds to map, given the device's mappable region. + * + * Given the device's mappable region, along with the user-requested mapping + * start offset and length of the user region, determine how much of this + * mappable region can be mapped into the user's region (start/end offsets), + * and the physical offset (phys_offset) into the BAR where the mapping should + * begin (either the VMA's or region lower bound). + * + * In other words, this calculates the overlap between the VMA + * (bar_offset, requested_length) and the given gasket_mappable_region. + * + * Returns true if there's anything to map, and false otherwise. + */ +static bool gasket_mm_get_mapping_addrs( + const struct gasket_mappable_region *region, ulong bar_offset, + ulong requested_length, struct gasket_mappable_region *mappable_region, + ulong *virt_offset) +{ + ulong range_start = region->start; + ulong range_length = region->length_bytes; + ulong range_end = range_start + range_length; + + *virt_offset = 0; + if (bar_offset + requested_length < range_start) { + /* + * If the requested region is completely below the range, + * there is nothing to map. + */ + return false; + } else if (bar_offset <= range_start) { + /* If the bar offset is below this range's start + * but the requested length continues into it: + * 1) Only map starting from the beginning of this + * range's phys. offset, so we don't map unmappable + * memory. + * 2) The length of the virtual memory to not map is the + * delta between the bar offset and the + * mappable start (and since the mappable start is + * bigger, start - req.) + * 3) The map length is the minimum of the mappable + * requested length (requested_length - virt_offset) + * and the actual mappable length of the range. + */ + mappable_region->start = range_start; + *virt_offset = range_start - bar_offset; + mappable_region->length_bytes = + min(requested_length - *virt_offset, range_length); + return true; + } else if (bar_offset > range_start && + bar_offset < range_end) { + /* + * If the bar offset is within this range: + * 1) Map starting from the bar offset. + * 2) Because there is no forbidden memory between the + * bar offset and the range start, + * virt_offset is 0. + * 3) The map length is the minimum of the requested + * length and the remaining length in the buffer + * (range_end - bar_offset) + */ + mappable_region->start = bar_offset; + *virt_offset = 0; + mappable_region->length_bytes = min( + requested_length, range_end - bar_offset); + return true; + } + + /* + * If the requested [start] offset is above range_end, + * there's nothing to map. + */ + return false; +} + +int gasket_mm_unmap_region( + const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, + const struct gasket_mappable_region *map_region) +{ + ulong bar_offset; + ulong virt_offset; + struct gasket_mappable_region mappable_region; + int ret; + + if (map_region->length_bytes == 0) + return 0; + + ret = gasket_mm_vma_bar_offset(gasket_dev, vma, &bar_offset); + if (ret) + return ret; + + if (!gasket_mm_get_mapping_addrs( + map_region, bar_offset, vma->vm_end - vma->vm_start, + &mappable_region, &virt_offset)) + return 1; + + /* + * The length passed to zap_vma_ptes MUST BE A MULTIPLE OF + * PAGE_SIZE! Trust me. I have the scars. + * + * Next multiple of y: ceil_div(x, y) * y + */ + zap_vma_ptes( + vma, vma->vm_start + virt_offset, + DIV_ROUND_UP(mappable_region.length_bytes, PAGE_SIZE) * + PAGE_SIZE); + return 0; +} +EXPORT_SYMBOL(gasket_mm_unmap_region); + +/* Maps a virtual address + range to a physical offset of a BAR. */ +static enum do_map_region_status do_map_region( + const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, + struct gasket_mappable_region *mappable_region) +{ + /* Maximum size of a single call to io_remap_pfn_range. */ + /* I pulled this number out of thin air. */ + const ulong max_chunk_size = 64 * 1024 * 1024; + ulong chunk_size, mapped_bytes = 0; + + const struct gasket_driver_desc *driver_desc = + gasket_dev->internal_desc->driver_desc; + + ulong bar_offset, virt_offset; + struct gasket_mappable_region region_to_map; + ulong phys_offset, map_length; + ulong virt_base, phys_base; + int bar_index, ret; + + ret = gasket_mm_vma_bar_offset(gasket_dev, vma, &bar_offset); + if (ret) + return DO_MAP_REGION_INVALID; + + if (!gasket_mm_get_mapping_addrs(mappable_region, bar_offset, + vma->vm_end - vma->vm_start, + ®ion_to_map, &virt_offset)) + return DO_MAP_REGION_INVALID; + phys_offset = region_to_map.start; + map_length = region_to_map.length_bytes; + + virt_base = vma->vm_start + virt_offset; + bar_index = + gasket_get_bar_index( + gasket_dev, + (vma->vm_pgoff << PAGE_SHIFT) + + driver_desc->legacy_mmap_address_offset); + phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset; + while (mapped_bytes < map_length) { + /* + * io_remap_pfn_range can take a while, so we chunk its + * calls and call cond_resched between each. + */ + chunk_size = min(max_chunk_size, map_length - mapped_bytes); + + cond_resched(); + ret = io_remap_pfn_range( + vma, virt_base + mapped_bytes, + (phys_base + mapped_bytes) >> PAGE_SHIFT, + chunk_size, vma->vm_page_prot); + if (ret) { + gasket_log_error( + gasket_dev, "Error remapping PFN range."); + goto fail; + } + mapped_bytes += chunk_size; + } + + return DO_MAP_REGION_SUCCESS; + +fail: + /* Unmap the partial chunk we mapped. */ + mappable_region->length_bytes = mapped_bytes; + if (gasket_mm_unmap_region(gasket_dev, vma, mappable_region)) + gasket_log_error( + gasket_dev, + "Error unmapping partial region 0x%lx (0x%lx bytes)", + (ulong)virt_offset, + (ulong)mapped_bytes); + + return DO_MAP_REGION_FAILURE; +} + +/* + * Calculates the offset where the VMA range begins in its containing BAR. + * The offset is written into bar_offset on success. + * Returns zero on success, anything else on error. +*/ +static int gasket_mm_vma_bar_offset( + const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, + ulong *bar_offset) +{ + ulong raw_offset; + int bar_index; + const struct gasket_driver_desc *driver_desc = + gasket_dev->internal_desc->driver_desc; + + raw_offset = (vma->vm_pgoff << PAGE_SHIFT) + + driver_desc->legacy_mmap_address_offset; + bar_index = gasket_get_bar_index(gasket_dev, raw_offset); + if (bar_index < 0) { + gasket_log_error( + gasket_dev, + "Unable to find matching bar for address 0x%lx", + raw_offset); + trace_gasket_mmap_exit(bar_index); + return bar_index; + } + *bar_offset = + raw_offset - driver_desc->bar_descriptions[bar_index].base; + + return 0; +} + +/* + * Map a region of coherent memory. + * @gasket_dev: Gasket device handle. + * @vma: Virtual memory area descriptor with region to map. + */ +static int gasket_mmap_coherent( + struct gasket_dev *gasket_dev, struct vm_area_struct *vma) +{ + const struct gasket_driver_desc *driver_desc = + gasket_dev->internal_desc->driver_desc; + const ulong requested_length = vma->vm_end - vma->vm_start; + int ret; + ulong permissions; + + if (requested_length == 0 || requested_length > + gasket_dev->coherent_buffer.length_bytes) { + trace_gasket_mmap_exit(-EINVAL); + return -EINVAL; + } + + permissions = driver_desc->coherent_buffer_description.permissions; + if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) { + gasket_log_error(gasket_dev, "Permission checking failed."); + trace_gasket_mmap_exit(-EPERM); + return -EPERM; + } + + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + ret = remap_pfn_range( + vma, vma->vm_start, + (gasket_dev->coherent_buffer.phys_base) >> PAGE_SHIFT, + requested_length, vma->vm_page_prot); + if (ret) { + gasket_log_error( + gasket_dev, "Error remapping PFN range err=%d.", ret); + trace_gasket_mmap_exit(ret); + return ret; + } + + /* Record the user virtual to dma_address mapping that was + * created by the kernel. + */ + gasket_set_user_virt( + gasket_dev, requested_length, + gasket_dev->coherent_buffer.phys_base, vma->vm_start); + return 0; +} + +/* + * Maps a device's BARs into user space. + * @filp: File structure pointer describing this node usage session. + * @vma: Standard virtual memory area descriptor. + * + * Maps the entirety of each of the device's BAR ranges into the user memory + * range specified by vma. + * + * Returns 0 on success, a negative errno on error. + */ +static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) +{ + int i, ret; + int bar_index; + int has_mapped_anything = 0; + ulong permissions; + ulong raw_offset, vma_size; + bool is_coherent_region; + const struct gasket_driver_desc *driver_desc; + struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data; + struct gasket_bar_data *bar_data; + const struct gasket_bar_desc *bar_desc; + struct gasket_mappable_region *map_regions = NULL; + int num_map_regions = 0; + enum do_map_region_status map_status; + + if (!gasket_dev) { + gasket_nodev_error("Unable to retrieve device data"); + trace_gasket_mmap_exit(-EINVAL); + return -EINVAL; + } + driver_desc = gasket_dev->internal_desc->driver_desc; + + if (vma->vm_start & (PAGE_SIZE - 1)) { + gasket_log_error( + gasket_dev, "Base address not page-aligned: 0x%p\n", + (void *)vma->vm_start); + trace_gasket_mmap_exit(-EINVAL); + return -EINVAL; + } + + /* Calculate the offset of this range into physical mem. */ + raw_offset = (vma->vm_pgoff << PAGE_SHIFT) + + driver_desc->legacy_mmap_address_offset; + vma_size = vma->vm_end - vma->vm_start; + trace_gasket_mmap_entry( + gasket_dev->dev_info.name, raw_offset, vma_size); + + /* + * Check if the raw offset is within a bar region. If not, check if it + * is a coherent region. + */ + bar_index = gasket_get_bar_index(gasket_dev, raw_offset); + is_coherent_region = gasket_is_coherent_region(driver_desc, raw_offset); + if (bar_index < 0 && !is_coherent_region) { + gasket_log_error( + gasket_dev, + "Unable to find matching bar for address 0x%lx", + raw_offset); + trace_gasket_mmap_exit(bar_index); + return bar_index; + } + if (bar_index > 0 && is_coherent_region) { + gasket_log_error( + gasket_dev, + "double matching bar and coherent buffers for address " + "0x%lx", + raw_offset); + trace_gasket_mmap_exit(bar_index); + return bar_index; + } + + vma->vm_private_data = gasket_dev; + + if (is_coherent_region) + return gasket_mmap_coherent(gasket_dev, vma); + + /* Everything in the rest of this function is for normal BAR mapping. */ + + /* + * Subtract the base of the bar from the raw offset to get the + * memory location within the bar to map. + */ + bar_data = &gasket_dev->bar_data[bar_index]; + + bar_desc = &driver_desc->bar_descriptions[bar_index]; + permissions = bar_desc->permissions; + if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) { + gasket_log_error(gasket_dev, "Permission checking failed."); + trace_gasket_mmap_exit(-EPERM); + return -EPERM; + } + + if (driver_desc->get_mappable_regions_cb) { + ret = driver_desc->get_mappable_regions_cb( + gasket_dev, bar_index, &map_regions, &num_map_regions); + if (ret) + return ret; + } else { + if (!gasket_mmap_has_permissions(gasket_dev, vma, + bar_desc->permissions)) { + gasket_log_error( + gasket_dev, "Permission checking failed."); + trace_gasket_mmap_exit(-EPERM); + return -EPERM; + } + num_map_regions = bar_desc->num_mappable_regions; + map_regions = kzalloc( + num_map_regions * sizeof(*bar_desc->mappable_regions), + GFP_KERNEL); + if (map_regions) { + memcpy(map_regions, bar_desc->mappable_regions, + num_map_regions * + sizeof(*bar_desc->mappable_regions)); + } + } + + if (!map_regions || num_map_regions == 0) { + gasket_log_error(gasket_dev, "No mappable regions returned!"); + return -EINVAL; + } + + /* Marks the VMA's pages as uncacheable. */ + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + for (i = 0; i < num_map_regions; i++) { + map_status = do_map_region(gasket_dev, vma, &map_regions[i]); + /* Try the next region if this one was not mappable. */ + if (map_status == DO_MAP_REGION_INVALID) + continue; + if (map_status == DO_MAP_REGION_FAILURE) + goto fail; + + has_mapped_anything = 1; + } + + kfree(map_regions); + + /* If we could not map any memory, the request was invalid. */ + if (!has_mapped_anything) { + gasket_log_error( + gasket_dev, + "Map request did not contain a valid region."); + trace_gasket_mmap_exit(-EINVAL); + return -EINVAL; + } + + trace_gasket_mmap_exit(0); + return 0; + +fail: + /* Need to unmap any mapped ranges. */ + num_map_regions = i; + for (i = 0; i < num_map_regions; i++) + if (gasket_mm_unmap_region(gasket_dev, vma, + &bar_desc->mappable_regions[i])) + gasket_log_error( + gasket_dev, "Error unmapping range %d.", i); + kfree(map_regions); + + return ret; +} + +/* + * Determine the health of the Gasket device. + * @gasket_dev: Gasket device structure. + * + * Checks the underlying device health (via the device_status_cb) + * and the status of initialized Gasket code systems (currently + * only interrupts), then returns a gasket_status appropriately. + */ +static int gasket_get_hw_status(struct gasket_dev *gasket_dev) +{ + int status; + int i; + const struct gasket_driver_desc *driver_desc = + gasket_dev->internal_desc->driver_desc; + + status = gasket_check_and_invoke_callback_nolock( + gasket_dev, driver_desc->device_status_cb); + if (status != GASKET_STATUS_ALIVE) { + gasket_log_info(gasket_dev, "Hardware reported status %d.", + status); + return status; + } + + status = gasket_interrupt_system_status(gasket_dev); + if (status != GASKET_STATUS_ALIVE) { + gasket_log_info(gasket_dev, + "Interrupt system reported status %d.", status); + return status; + } + + for (i = 0; i < driver_desc->num_page_tables; ++i) { + status = gasket_page_table_system_status( + gasket_dev->page_table[i]); + if (status != GASKET_STATUS_ALIVE) { + gasket_log_info( + gasket_dev, "Page table %d reported status %d.", + i, status); + return status; + } + } + + return GASKET_STATUS_ALIVE; +} + +/* + * Gasket ioctl dispatch function. + * @filp: File structure pointer describing this node usage session. + * @cmd: ioctl number to handle. + * @arg: ioctl-specific data pointer. + * + * First, checks if the ioctl is a generic ioctl. If not, it passes + * the ioctl to the ioctl_handler_cb registered in the driver description. + * If the ioctl is a generic ioctl, the function passes it to the + * gasket_ioctl_handler in gasket_ioctl.c. + */ +static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) +{ + struct gasket_dev *gasket_dev; + const struct gasket_driver_desc *driver_desc; + char path[256]; + + if (!filp) + return -ENODEV; + + gasket_dev = (struct gasket_dev *)filp->private_data; + if (!gasket_dev) { + gasket_nodev_error( + "Unable to find Gasket structure for file %s", + d_path(&filp->f_path, path, 256)); + return -ENODEV; + } + + driver_desc = gasket_dev->internal_desc->driver_desc; + if (!driver_desc) { + gasket_log_error( + gasket_dev, + "Unable to find device descriptor for file %s", + d_path(&filp->f_path, path, 256)); + return -ENODEV; + } + + if (!gasket_is_supported_ioctl(cmd)) { + /* + * The ioctl handler is not a standard Gasket callback, since + * it requires different arguments. This means we can't use + * check_and_invoke_callback. + */ + if (driver_desc->ioctl_handler_cb) + return driver_desc->ioctl_handler_cb(filp, cmd, arg); + + gasket_log_error( + gasket_dev, "Received unknown ioctl 0x%x", cmd); + return -EINVAL; + } + + return gasket_handle_ioctl(filp, cmd, arg); +} + +int gasket_reset(struct gasket_dev *gasket_dev, uint reset_type) +{ + int ret; + + mutex_lock(&gasket_dev->mutex); + ret = gasket_reset_nolock(gasket_dev, reset_type); + mutex_unlock(&gasket_dev->mutex); + return ret; +} +EXPORT_SYMBOL(gasket_reset); + +int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) +{ + int ret; + int i; + const struct gasket_driver_desc *driver_desc; + + driver_desc = gasket_dev->internal_desc->driver_desc; + if (!driver_desc->device_reset_cb) { + gasket_log_error( + gasket_dev, "No device reset callback was registered."); + return -EINVAL; + } + + /* Perform a device reset of the requested type. */ + ret = driver_desc->device_reset_cb(gasket_dev, reset_type); + if (ret) + gasket_log_error( + gasket_dev, "Device reset cb returned %d.", ret); + + /* Reinitialize the page tables and interrupt framework. */ + for (i = 0; i < driver_desc->num_page_tables; ++i) + gasket_page_table_reset(gasket_dev->page_table[i]); + + ret = gasket_interrupt_reinit(gasket_dev); + if (ret) { + gasket_log_error( + gasket_dev, "Unable to reinit interrupts: %d.", ret); + return ret; + } + + /* Get current device health. */ + gasket_dev->status = gasket_get_hw_status(gasket_dev); + if (gasket_dev->status == GASKET_STATUS_DEAD) { + gasket_log_error(gasket_dev, "Device reported as dead."); + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL(gasket_reset_nolock); + +gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( + struct gasket_dev *gasket_dev) { + return gasket_dev->internal_desc->driver_desc->ioctl_permissions_cb; +} +EXPORT_SYMBOL(gasket_get_ioctl_permissions_cb); + +static ssize_t gasket_write_mappable_regions( + char *buf, const struct gasket_driver_desc *driver_desc, int bar_index) +{ + int i; + ssize_t written; + ssize_t total_written = 0; + ulong min_addr, max_addr; + struct gasket_bar_desc bar_desc = + driver_desc->bar_descriptions[bar_index]; + + if (bar_desc.permissions == GASKET_NOMAP) + return 0; + for (i = 0; + (i < bar_desc.num_mappable_regions) && (total_written < PAGE_SIZE); + i++) { + min_addr = bar_desc.mappable_regions[i].start - + driver_desc->legacy_mmap_address_offset; + max_addr = bar_desc.mappable_regions[i].start - + driver_desc->legacy_mmap_address_offset + + bar_desc.mappable_regions[i].length_bytes; + written = scnprintf(buf, PAGE_SIZE - total_written, + "0x%08lx-0x%08lx\n", min_addr, max_addr); + total_written += written; + buf += written; + } + return total_written; +} + +static ssize_t gasket_sysfs_data_show( + struct device *device, struct device_attribute *attr, char *buf) +{ + int i, ret = 0; + ssize_t current_written = 0; + const struct gasket_driver_desc *driver_desc; + struct gasket_dev *gasket_dev; + struct gasket_sysfs_attribute *gasket_attr; + const struct gasket_bar_desc *bar_desc; + enum gasket_sysfs_attribute_type sysfs_type; + + gasket_dev = gasket_sysfs_get_device_data(device); + if (!gasket_dev) { + gasket_nodev_error( + "No sysfs mapping found for device 0x%p", device); + return 0; + } + + gasket_attr = gasket_sysfs_get_attr(device, attr); + if (!gasket_attr) { + gasket_nodev_error( + "No sysfs attr found for device 0x%p", device); + gasket_sysfs_put_device_data(device, gasket_dev); + return 0; + } + + driver_desc = gasket_dev->internal_desc->driver_desc; + + sysfs_type = + (enum gasket_sysfs_attribute_type)gasket_attr->data.attr_type; + switch (sysfs_type) { + case ATTR_BAR_OFFSETS: + for (i = 0; i < GASKET_NUM_BARS; i++) { + bar_desc = &driver_desc->bar_descriptions[i]; + if (bar_desc->size == 0) + continue; + current_written = + snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i, + (ulong)bar_desc->base); + buf += current_written; + ret += current_written; + } + break; + case ATTR_BAR_SIZES: + for (i = 0; i < GASKET_NUM_BARS; i++) { + bar_desc = &driver_desc->bar_descriptions[i]; + if (bar_desc->size == 0) + continue; + current_written = + snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i, + (ulong)bar_desc->size); + buf += current_written; + ret += current_written; + } + break; + case ATTR_DRIVER_VERSION: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", + gasket_dev->internal_desc->driver_desc->driver_version); + break; + case ATTR_FRAMEWORK_VERSION: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", GASKET_FRAMEWORK_VERSION); + break; + case ATTR_DEVICE_TYPE: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", + gasket_dev->internal_desc->driver_desc->name); + break; + case ATTR_HARDWARE_REVISION: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", gasket_dev->hardware_revision); + break; + case ATTR_PCI_ADDRESS: + ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name); + break; + case ATTR_STATUS: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", + gasket_num_name_lookup( + gasket_dev->status, gasket_status_name_table)); + break; + case ATTR_IS_DEVICE_OWNED: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.is_owned); + break; + case ATTR_DEVICE_OWNER: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.owner); + break; + case ATTR_WRITE_OPEN_COUNT: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.write_open_count); + break; + case ATTR_RESET_COUNT: + ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count); + break; + case ATTR_USER_MEM_RANGES: + for (i = 0; i < GASKET_NUM_BARS; ++i) { + current_written = gasket_write_mappable_regions( + buf, driver_desc, i); + buf += current_written; + ret += current_written; + } + break; + default: + gasket_log_error( + gasket_dev, "Unknown attribute: %s", attr->attr.name); + ret = 0; + break; + } + + gasket_sysfs_put_attr(device, gasket_attr); + gasket_sysfs_put_device_data(device, gasket_dev); + return ret; +} + +/* Get the driver structure for a given gasket_dev. + * @dev: pointer to gasket_dev, implementing the requested driver. + */ +const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev) +{ + return dev->internal_desc->driver_desc; +} + +/* Get the device structure for a given gasket_dev. + * @dev: pointer to gasket_dev, implementing the requested driver. + */ +struct device *gasket_get_device(struct gasket_dev *dev) +{ + if (dev->pci_dev) + return &dev->pci_dev->dev; + return NULL; +} + +/** + * Synchronously waits on device. + * @gasket_dev: Device struct. + * @bar: Bar + * @offset: Register offset + * @mask: Register mask + * @val: Expected value + * @timeout_ns: Timeout in nanoseconds + * + * Description: Busy waits for a specific combination of bits to be set + * on a Gasket register. + **/ +int gasket_wait_sync( + struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, + u64 timeout_ns) +{ + u64 reg; + struct timespec start_time, cur_time; + u64 diff_nanosec; + int count = 0; + + reg = gasket_dev_read_64(gasket_dev, bar, offset); + start_time = current_kernel_time(); + while ((reg & mask) != val) { + count++; + cur_time = current_kernel_time(); + diff_nanosec = (u64)(cur_time.tv_sec - start_time.tv_sec) * + 1000000000LL + + (u64)(cur_time.tv_nsec) - + (u64)(start_time.tv_nsec); + if (diff_nanosec > timeout_ns) { + gasket_log_error( + gasket_dev, + "gasket_wait_sync timeout: reg %llx count %x " + "dma %lld ns\n", + offset, count, diff_nanosec); + return -1; + } + reg = gasket_dev_read_64(gasket_dev, bar, offset); + } + return 0; +} +EXPORT_SYMBOL(gasket_wait_sync); + +/** + * Asynchronously waits on device. + * @gasket_dev: Device struct. + * @bar: Bar + * @offset: Register offset + * @mask: Register mask + * @val: Expected value + * @max_retries: number of sleep periods + * @delay_ms: Timeout in milliseconds + * + * Description: Busy waits for a specific combination of bits to be set on a + * Gasket register. + **/ +int gasket_wait_with_reschedule( + struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, + u64 max_retries, u64 delay_ms) +{ + u64 retries = 0; + u64 tmp; + + while (retries < max_retries) { + tmp = gasket_dev_read_64(gasket_dev, bar, offset); + if ((tmp & mask) == val) + break; + schedule_timeout(msecs_to_jiffies(delay_ms)); + retries++; + } + if (retries == max_retries) { + gasket_log_error( + gasket_dev, + "gasket_wait_with_reschedule timeout: reg %llx timeout (%llu ms)", + offset, max_retries * delay_ms); + return -EINVAL; + } + return 0; +} +EXPORT_SYMBOL(gasket_wait_with_reschedule); diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h new file mode 100644 index 000000000000..203b9a31377b --- /dev/null +++ b/drivers/staging/gasket/gasket_core.h @@ -0,0 +1,719 @@ +/* Gasket generic driver. Defines the set of data types and functions necessary + * to define a driver using the Gasket generic driver framework. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __GASKET_CORE_H__ +#define __GASKET_CORE_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gasket_constants.h" + +/** + * struct gasket_num_name - Map numbers to names. + * @ein_num: Number. + * @ein_name: Name associated with the number, a char pointer. + * + * This structure maps numbers to names. It is used to provide printable enum + * names, e.g {0, "DEAD"} or {1, "ALIVE"}. + */ +struct gasket_num_name { + uint snn_num; + const char *snn_name; +}; + +/* + * Register location for packed interrupts. + * Each value indicates the location of an interrupt field (in units of + * gasket_driver_desc->interrupt_pack_width) within the containing register. + * In other words, this indicates the shift to use when creating a mask to + * extract/set bits within a register for a given interrupt. + */ +enum gasket_interrupt_packing { + PACK_0 = 0, + PACK_1 = 1, + PACK_2 = 2, + PACK_3 = 3, + UNPACKED = 4, +}; + +/* Type of the interrupt supported by the device. */ +enum gasket_interrupt_type { + PCI_MSIX = 0, + PCI_MSI = 1, + PLATFORM_WIRE = 2, +}; + +/* Used to describe a Gasket interrupt. Contains an interrupt index, a register, + * and packing data for that interrupt. The register and packing data + * fields is relevant only for PCI_MSIX interrupt type and can be + * set to 0 for everything else. + */ +struct gasket_interrupt_desc { + /* Device-wide interrupt index/number. */ + int index; + /* The register offset controlling this interrupt. */ + u64 reg; + /* The location of this interrupt inside register reg, if packed. */ + int packing; +}; + +/* Offsets to the wire interrupt handling registers */ +struct gasket_wire_interrupt_offsets { + u64 pending_bit_array; + u64 mask_array; +}; + +/* + * This enum is used to identify memory regions being part of the physical + * memory that belongs to a device. + */ +enum mappable_area_type { + PCI_BAR = 0, /* Default */ + BUS_REGION, /* For SYSBUS devices, i.e. AXI etc... */ + COHERENT_MEMORY +}; + +/* + * Metadata for each BAR mapping. + * This struct is used so as to track PCI memory, I/O space, AXI and coherent + * memory area... i.e. memory objects which can be referenced in the device's + * mmap function. + */ +struct gasket_bar_data { + /* Virtual base address. */ + u8 __iomem *virt_base; + + /* Physical base address. */ + ulong phys_base; + + /* Length of the mapping. */ + ulong length_bytes; + + /* Type of mappable area */ + enum mappable_area_type type; +}; + +/* Maintains device open ownership data. */ +struct gasket_ownership { + /* 1 if the device is owned, 0 otherwise. */ + int is_owned; + + /* TGID of the owner. */ + pid_t owner; + + /* Count of current device opens in write mode. */ + int write_open_count; +}; + +/* Page table modes of operation. */ +enum gasket_page_table_mode { + /* The page table is partitionable as normal, all simple by default. */ + GASKET_PAGE_TABLE_MODE_NORMAL, + + /* All entries are always simple. */ + GASKET_PAGE_TABLE_MODE_SIMPLE, + + /* All entries are always extended. No extended bit is used. */ + GASKET_PAGE_TABLE_MODE_EXTENDED, +}; + +/* Page table configuration. One per table. */ +struct gasket_page_table_config { + /* The identifier/index of this page table. */ + int id; + + /* The operation mode of this page table. */ + enum gasket_page_table_mode mode; + + /* Total (first-level) entries in this page table. */ + ulong total_entries; + + /* Base register for the page table. */ + int base_reg; + + /* + * Register containing the extended page table. This value is unused in + * GASKET_PAGE_TABLE_MODE_SIMPLE and GASKET_PAGE_TABLE_MODE_EXTENDED + * modes. + */ + int extended_reg; + + /* The bit index indicating whether a PT entry is extended. */ + int extended_bit; +}; + +/* Maintains information about a device node. */ +struct gasket_cdev_info { + /* The internal name of this device. */ + char name[GASKET_NAME_MAX]; + + /* Device number. */ + dev_t devt; + + /* Kernel-internal device structure. */ + struct device *device; + + /* Character device for real. */ + struct cdev cdev; + + /* Flag indicating if cdev_add has been called for the devices. */ + int cdev_added; + + /* Pointer to the overall gasket_dev struct for this device. */ + struct gasket_dev *gasket_dev_ptr; + + /* Ownership data for the device in question. */ + struct gasket_ownership ownership; +}; + +/* Describes the offset and length of mmapable device BAR regions. */ +struct gasket_mappable_region { + u64 start; + u64 length_bytes; +}; + +/* Describe the offset, size, and permissions for a device bar. */ +struct gasket_bar_desc { + /* + * The size of each PCI BAR range, in bytes. If a value is 0, that BAR + * will not be mapped into kernel space at all. + * For devices with 64 bit BARs, only elements 0, 2, and 4 should be + * populated, and 1, 3, and 5 should be set to 0. + * For example, for a device mapping 1M in each of the first two 64-bit + * BARs, this field would be set as { 0x100000, 0, 0x100000, 0, 0, 0 } + * (one number per bar_desc struct.) + */ + u64 size; + /* The permissions for this bar. (Should be VM_WRITE/VM_READ/VM_EXEC, + * and can be or'd.) If set to GASKET_NOMAP, the bar will + * not be used for mmapping. + */ + ulong permissions; + /* The memory address corresponding to the base of this bar, if used. */ + u64 base; + /* The number of mappable regions in this bar. */ + int num_mappable_regions; + + /* The mappable subregions of this bar. */ + const struct gasket_mappable_region *mappable_regions; + + /* Type of mappable area */ + enum mappable_area_type type; +}; + +/* Describes the offset, size, and permissions for a coherent buffer. */ +struct gasket_coherent_buffer_desc { + /* The size of the coherent buffer. */ + u64 size; + + /* The permissions for this bar. (Should be VM_WRITE/VM_READ/VM_EXEC, + * and can be or'd.) If set to GASKET_NOMAP, the bar will + * not be used for mmaping. + */ + ulong permissions; + + /* device side address. */ + u64 base; +}; + +/* Coherent buffer structure. */ +struct gasket_coherent_buffer { + /* Virtual base address. */ + u8 __iomem *virt_base; + + /* Physical base address. */ + ulong phys_base; + + /* Length of the mapping. */ + ulong length_bytes; +}; + +/* Description of Gasket-specific permissions in the mmap field. */ +enum gasket_mapping_options { GASKET_NOMAP = 0 }; + +/* This struct represents an undefined bar that should never be mapped. */ +#define GASKET_UNUSED_BAR \ + { \ + 0, GASKET_NOMAP, 0, 0, NULL, 0 \ + } + +/* Internal data for a Gasket device. See gasket_core.c for more information. */ +struct gasket_internal_desc; + +#define MAX_NUM_COHERENT_PAGES 16 + +/* + * Device data for Gasket device instances. + * + * This structure contains the data required to manage a Gasket device. + */ +struct gasket_dev { + /* Pointer to the internal driver description for this device. */ + struct gasket_internal_desc *internal_desc; + + /* PCI subsystem metadata. */ + struct pci_dev *pci_dev; + + /* This device's index into internal_desc->devs. */ + int dev_idx; + + /* The name of this device, as reported by the kernel. */ + char kobj_name[GASKET_NAME_MAX]; + + /* Virtual address of mapped BAR memory range. */ + struct gasket_bar_data bar_data[GASKET_NUM_BARS]; + + /* Coherent buffer. */ + struct gasket_coherent_buffer coherent_buffer; + + /* Number of page tables for this device. */ + int num_page_tables; + + /* Address translations. Page tables have a private implementation. */ + struct gasket_page_table *page_table[GASKET_MAX_NUM_PAGE_TABLES]; + + /* Interrupt data for this device. */ + struct gasket_interrupt_data *interrupt_data; + + /* Status for this device - GASKET_STATUS_ALIVE or _DEAD. */ + uint status; + + /* Number of times this device has been reset. */ + uint reset_count; + + /* Dev information for the cdev node. */ + struct gasket_cdev_info dev_info; + + /* Hardware revision value for this device. */ + int hardware_revision; + + /* + * Device-specific data; allocated in gasket_driver_desc.add_dev_cb() + * and freed in gasket_driver_desc.remove_dev_cb(). + */ + void *cb_data; + + /* Protects access to per-device data (i.e. this structure). */ + struct mutex mutex; + + /* cdev hash tracking/membership structure, Accel and legacy. */ + /* Unused until Accel is upstreamed. */ + struct hlist_node hlist_node; + struct hlist_node legacy_hlist_node; +}; + +/* Type of the ioctl permissions check callback. See below. */ +typedef int (*gasket_ioctl_permissions_cb_t)( + struct file *filp, uint cmd, ulong arg); + +/* + * Device type descriptor. + * + * This structure contains device-specific data needed to identify and address a + * type of device to be administered via the Gasket generic driver. + * + * Device IDs are per-driver. In other words, two drivers using the Gasket + * framework will each have a distinct device 0 (for example). + */ +struct gasket_driver_desc { + /* The name of this device type. */ + const char *name; + + /* The name of this specific device model. */ + const char *chip_model; + + /* The version of the chip specified in chip_model. */ + const char *chip_version; + + /* The version of this driver: "1.0.0", "2.1.3", etc. */ + const char *driver_version; + + /* + * Non-zero if we should create "legacy" (device and device-class- + * specific) character devices and sysfs nodes. + */ + /* Unused until Accel is upstreamed. */ + int legacy_support; + + /* Major and minor numbers identifying the device. */ + int major, minor; + + /* Module structure for this driver. */ + struct module *module; + + /* PCI ID table. */ + const struct pci_device_id *pci_id_table; + + /* The number of page tables handled by this driver. */ + int num_page_tables; + + /* The index of the bar containing the page tables. */ + int page_table_bar_index; + + /* Registers used to control each page table. */ + const struct gasket_page_table_config *page_table_configs; + + /* The bit index indicating whether a PT entry is extended. */ + int page_table_extended_bit; + + /* + * Legacy mmap address adjusment for legacy devices only. Should be 0 + * for any new device. + */ + ulong legacy_mmap_address_offset; + + /* Set of 6 bar descriptions that describe all PCIe bars. + * Note that BUS/AXI devices (i.e. non PCI devices) use those. + */ + struct gasket_bar_desc bar_descriptions[GASKET_NUM_BARS]; + + /* + * Coherent buffer description. + */ + struct gasket_coherent_buffer_desc coherent_buffer_description; + + /* Offset of wire interrupt registers. */ + const struct gasket_wire_interrupt_offsets *wire_interrupt_offsets; + + /* Interrupt type. (One of gasket_interrupt_type). */ + int interrupt_type; + + /* Index of the bar containing the interrupt registers to program. */ + int interrupt_bar_index; + + /* Number of interrupts in the gasket_interrupt_desc array */ + int num_interrupts; + + /* Description of the interrupts for this device. */ + const struct gasket_interrupt_desc *interrupts; + + /* + * If this device packs multiple interrupt->MSI-X mappings into a + * single register (i.e., "uses packed interrupts"), only a single bit + * width is supported for each interrupt mapping (unpacked/"full-width" + * interrupts are always supported). This value specifies that width. If + * packed interrupts are not used, this value is ignored. + */ + int interrupt_pack_width; + + /* Driver callback functions - all may be NULL */ + /* + * add_dev_cb: Callback when a device is found. + * @dev: The gasket_dev struct for this driver instance. + * + * This callback should initialize the device-specific cb_data. + * Called when a device is found by the driver, + * before any BAR ranges have been mapped. If this call fails (returns + * nonzero), remove_dev_cb will be called. + * + */ + int (*add_dev_cb)(struct gasket_dev *dev); + + /* + * remove_dev_cb: Callback for when a device is removed from the system. + * @dev: The gasket_dev struct for this driver instance. + * + * This callback should free data allocated in add_dev_cb. + * Called immediately before a device is unregistered by the driver. + * All framework-managed resources will have been cleaned up by the time + * this callback is invoked (PCI BARs, character devices, ...). + */ + int (*remove_dev_cb)(struct gasket_dev *dev); + + /* + * device_open_cb: Callback for when a device node is opened in write + * mode. + * @dev: The gasket_dev struct for this driver instance. + * + * This callback should perform device-specific setup that needs to + * occur only once when a device is first opened. + */ + int (*device_open_cb)(struct gasket_dev *dev); + + /* + * device_release_cb: Callback when a device is closed. + * @gasket_dev: The gasket_dev struct for this driver instance. + * + * This callback is called whenever a device node fd is closed, as + * opposed to device_close_cb, which is called when the _last_ + * descriptor for an open file is closed. This call is intended to + * handle any per-user or per-fd cleanup. + */ + int (*device_release_cb)( + struct gasket_dev *gasket_dev, struct file *file); + + /* + * device_close_cb: Callback for when a device node is closed for the + * last time. + * @dev: The gasket_dev struct for this driver instance. + * + * This callback should perform device-specific cleanup that only + * needs to occur when the last reference to a device node is closed. + * + * This call is intended to handle and device-wide cleanup, as opposed + * to per-fd cleanup (which should be handled by device_release_cb). + */ + int (*device_close_cb)(struct gasket_dev *dev); + + /* + * enable_dev_cb: Callback immediately before enabling the device. + * @dev: Pointer to the gasket_dev struct for this driver instance. + * + * This callback is invoked after the device has been added and all BAR + * spaces mapped, immediately before registering and enabling the + * [character] device via cdev_add. If this call fails (returns + * nonzero), disable_dev_cb will be called. + * + * Note that cdev are initialized but not active + * (cdev_add has not yet been called) when this callback is invoked. + */ + int (*enable_dev_cb)(struct gasket_dev *dev); + + /* + * disable_dev_cb: Callback immediately after disabling the device. + * @dev: Pointer to the gasket_dev struct for this driver instance. + * + * Called during device shutdown, immediately after disabling device + * operations via cdev_del. + */ + int (*disable_dev_cb)(struct gasket_dev *dev); + + /* + * sysfs_setup_cb: Callback to set up driver-specific sysfs nodes. + * @dev: Pointer to the gasket_dev struct for this device. + * + * Called just before enable_dev_cb. + * + */ + int (*sysfs_setup_cb)(struct gasket_dev *dev); + + /* + * sysfs_cleanup_cb: Callback to clean up driver-specific sysfs nodes. + * @dev: Pointer to the gasket_dev struct for this device. + * + * Called just before disable_dev_cb. + * + */ + int (*sysfs_cleanup_cb)(struct gasket_dev *dev); + + /* + * get_mappable_regions_cb: Get descriptors of mappable device memory. + * @gasket_dev: Pointer to the struct gasket_dev for this device. + * @bar_index: BAR for which to retrieve memory ranges. + * @mappable_regions: Out-pointer to the list of mappable regions on the + * device/BAR for this process. + * @num_mappable_regions: Out-pointer for the size of mappable_regions. + * + * Called when handling mmap(), this callback is used to determine which + * regions of device memory may be mapped by the current process. This + * information is then compared to mmap request to determine which + * regions to actually map. + */ + int (*get_mappable_regions_cb)( + struct gasket_dev *gasket_dev, int bar_index, + struct gasket_mappable_region **mappable_regions, + int *num_mappable_regions); + + /* + * ioctl_permissions_cb: Check permissions for generic ioctls. + * @filp: File structure pointer describing this node usage session. + * @cmd: ioctl number to handle. + * @arg: ioctl-specific data pointer. + * + * Returns 1 if the ioctl may be executed, 0 otherwise. If this callback + * isn't specified a default routine will be used, that only allows the + * original device opener (i.e, the "owner") to execute state-affecting + * ioctls. + */ + gasket_ioctl_permissions_cb_t ioctl_permissions_cb; + + /* + * ioctl_handler_cb: Callback to handle device-specific ioctls. + * @filp: File structure pointer describing this node usage session. + * @cmd: ioctl number to handle. + * @arg: ioctl-specific data pointer. + * + * Invoked whenever an ioctl is called that the generic Gasket + * framework doesn't support. If no cb is registered, unknown ioctls + * return -EINVAL. Should return an error status (either -EINVAL or + * the error result of the ioctl being handled). + */ + long (*ioctl_handler_cb)(struct file *filp, uint cmd, ulong arg); + + /* + * device_status_cb: Callback to determine device health. + * @dev: Pointer to the gasket_dev struct for this device. + * + * Called to determine if the device is healthy or not. Should return + * a member of the gasket_status_type enum. + * + */ + int (*device_status_cb)(struct gasket_dev *dev); + + /* + * hardware_revision_cb: Get the device's hardware revision. + * @dev: Pointer to the gasket_dev struct for this device. + * + * Called to determine the reported rev of the physical hardware. + * Revision should be >0. A negative return value is an error. + */ + int (*hardware_revision_cb)(struct gasket_dev *dev); + + /* + * device_reset_cb: Reset the hardware in question. + * @dev: Pointer to the gasket_dev structure for this device. + * @type: Integer representing reset type. (All + * Gasket resets have an integer representing their type + * defined in (device)_ioctl.h; the specific resets are + * device-dependent, but are handled in the device-specific + * callback anyways.) + * + * Called by reset ioctls. This function should not + * lock the gasket_dev mutex. It should return 0 on success + * and an error on failure. + */ + int (*device_reset_cb)(struct gasket_dev *dev, uint reset_type); +}; + +/* + * Register the specified device type with the framework. + * @desc: Populated/initialized device type descriptor. + * + * This function does _not_ take ownership of desc; the underlying struct must + * exist until the matching call to gasket_unregister_device. + * This function should be called from your driver's module_init function. + */ +int gasket_register_device(const struct gasket_driver_desc *desc); + +/* + * Remove the specified device type from the framework. + * @desc: Descriptor for the device type to unregister; it should have been + * passed to gasket_register_device in a previous call. + * + * This function should be called from your driver's module_exit function. + */ +void gasket_unregister_device(const struct gasket_driver_desc *desc); + +/* + * Reset the Gasket device. + * @gasket_dev: Gasket device struct. + * @reset_type: Uint representing requested reset type. Should be + * valid in the underlying callback. + * + * Calls device_reset_cb. Returns 0 on success and an error code othewrise. + * gasket_reset_nolock will not lock the mutex, gasket_reset will. + * + */ +int gasket_reset(struct gasket_dev *gasket_dev, uint reset_type); +int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type); + +/* + * Memory management functions. These will likely be spun off into their own + * file in the future. + */ + +/* Unmaps the specified mappable region from a VMA. */ +int gasket_mm_unmap_region( + const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, + const struct gasket_mappable_region *map_region); + +/* + * Get the ioctl permissions callback. + * @gasket_dev: Gasket device structure. + */ +gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( + struct gasket_dev *gasket_dev); + +/** + * Lookup a name by number in a num_name table. + * @num: Number to lookup. + * @table: Array of num_name structures, the table for the lookup. + * + */ +const char *gasket_num_name_lookup( + uint num, const struct gasket_num_name *table); + +/* Handy inlines */ +static inline ulong gasket_dev_read_64( + struct gasket_dev *gasket_dev, int bar, ulong location) +{ + return readq(&gasket_dev->bar_data[bar].virt_base[location]); +} + +static inline void gasket_dev_write_64( + struct gasket_dev *dev, u64 value, int bar, ulong location) +{ + writeq(value, &dev->bar_data[bar].virt_base[location]); +} + +static inline void gasket_dev_write_32( + struct gasket_dev *dev, u32 value, int bar, ulong location) +{ + writel(value, &dev->bar_data[bar].virt_base[location]); +} + +static inline u32 gasket_dev_read_32( + struct gasket_dev *dev, int bar, ulong location) +{ + return readl(&dev->bar_data[bar].virt_base[location]); +} + +static inline void gasket_read_modify_write_64( + struct gasket_dev *dev, int bar, ulong location, u64 value, + u64 mask_width, u64 mask_shift) +{ + u64 mask, tmp; + + tmp = gasket_dev_read_64(dev, bar, location); + mask = ((1 << mask_width) - 1) << mask_shift; + tmp = (tmp & ~mask) | (value << mask_shift); + gasket_dev_write_64(dev, tmp, bar, location); +} + +static inline void gasket_read_modify_write_32( + struct gasket_dev *dev, int bar, ulong location, u32 value, + u32 mask_width, u32 mask_shift) +{ + u32 mask, tmp; + + tmp = gasket_dev_read_32(dev, bar, location); + mask = ((1 << mask_width) - 1) << mask_shift; + tmp = (tmp & ~mask) | (value << mask_shift); + gasket_dev_write_32(dev, tmp, bar, location); +} + +/* Get the Gasket driver structure for a given device. */ +const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev); + +/* Get the device structure for a given device. */ +struct device *gasket_get_device(struct gasket_dev *dev); + +/* Helper function, Synchronous waits on a given set of bits. */ +int gasket_wait_sync( + struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, + u64 timeout_ns); + +/* Helper function, Asynchronous waits on a given set of bits. */ +int gasket_wait_with_reschedule( + struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, + u64 max_retries, u64 delay_ms); + +#endif /* __GASKET_CORE_H__ */ diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c new file mode 100644 index 000000000000..b74eefe41d72 --- /dev/null +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -0,0 +1,638 @@ +/* Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "gasket_interrupt.h" + +#include "gasket_constants.h" +#include "gasket_core.h" +#include "gasket_logging.h" +#include "gasket_sysfs.h" +#include +#include +#ifdef GASKET_KERNEL_TRACE_SUPPORT +#define CREATE_TRACE_POINTS +#include +#else +#define trace_gasket_interrupt_event(x, ...) +#endif +/* Retry attempts if the requested number of interrupts aren't available. */ +#define MSIX_RETRY_COUNT 3 + +/* Instance interrupt management data. */ +struct gasket_interrupt_data { + /* The name associated with this interrupt data. */ + const char *name; + + /* Interrupt type. See gasket_interrupt_type in gasket_core.h */ + int type; + + /* The PCI device [if any] associated with the owning device. */ + struct pci_dev *pci_dev; + + /* Set to 1 if MSI-X has successfully been configred, 0 otherwise. */ + int msix_configured; + + /* The number of interrupts requested by the owning device. */ + int num_interrupts; + + /* A pointer to the interrupt descriptor struct for this device. */ + const struct gasket_interrupt_desc *interrupts; + + /* The index of the bar into which interrupts should be mapped. */ + int interrupt_bar_index; + + /* The width of a single interrupt in a packed interrupt register. */ + int pack_width; + + /* offset of wire interrupt registers */ + const struct gasket_wire_interrupt_offsets *wire_interrupt_offsets; + + /* + * Design-wise, these elements should be bundled together, but + * pci_enable_msix's interface requires that they be managed + * individually (requires array of struct msix_entry). + */ + + /* The number of successfully configured interrupts. */ + int num_configured; + + /* The MSI-X data for each requested/configured interrupt. */ + struct msix_entry *msix_entries; + + /* The eventfd "callback" data for each interrupt. */ + struct eventfd_ctx **eventfd_ctxs; + + /* The number of times each interrupt has been called. */ + ulong *interrupt_counts; + + /* Linux IRQ number. */ + int irq; +}; + +/* Function definitions. */ +static ssize_t interrupt_sysfs_show( + struct device *device, struct device_attribute *attr, char *buf); + +static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id); + +/* Structures to display interrupt counts in sysfs. */ +enum interrupt_sysfs_attribute_type { + ATTR_INTERRUPT_COUNTS, +}; + +static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = { + GASKET_SYSFS_RO( + interrupt_counts, interrupt_sysfs_show, ATTR_INTERRUPT_COUNTS), + GASKET_END_OF_ATTR_ARRAY, +}; + +/* + * Set up device registers for interrupt handling. + * @gasket_dev: The Gasket information structure for this device. + * + * Sets up the device registers with the correct indices for the relevant + * interrupts. + */ +static void gasket_interrupt_setup(struct gasket_dev *gasket_dev); + +/* MSIX init and cleanup. */ +static int gasket_interrupt_msix_init( + struct gasket_interrupt_data *interrupt_data); +static void gasket_interrupt_msix_cleanup( + struct gasket_interrupt_data *interrupt_data); +static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev); + +int gasket_interrupt_init( + struct gasket_dev *gasket_dev, const char *name, int type, + const struct gasket_interrupt_desc *interrupts, + int num_interrupts, int pack_width, int bar_index, + const struct gasket_wire_interrupt_offsets *wire_int_offsets) +{ + int ret; + struct gasket_interrupt_data *interrupt_data; + + interrupt_data = kzalloc( + sizeof(struct gasket_interrupt_data), GFP_KERNEL); + if (!interrupt_data) + return -ENOMEM; + gasket_dev->interrupt_data = interrupt_data; + interrupt_data->name = name; + interrupt_data->type = type; + interrupt_data->pci_dev = gasket_dev->pci_dev; + interrupt_data->num_interrupts = num_interrupts; + interrupt_data->interrupts = interrupts; + interrupt_data->interrupt_bar_index = bar_index; + interrupt_data->pack_width = pack_width; + interrupt_data->num_configured = 0; + interrupt_data->wire_interrupt_offsets = wire_int_offsets; + + /* Allocate all dynamic structures. */ + interrupt_data->msix_entries = kzalloc( + sizeof(struct msix_entry) * num_interrupts, GFP_KERNEL); + if (!interrupt_data->msix_entries) { + kfree(interrupt_data); + return -ENOMEM; + } + + interrupt_data->eventfd_ctxs = kzalloc( + sizeof(struct eventfd_ctx *) * num_interrupts, GFP_KERNEL); + if (!interrupt_data->eventfd_ctxs) { + kfree(interrupt_data->msix_entries); + kfree(interrupt_data); + return -ENOMEM; + } + + interrupt_data->interrupt_counts = kzalloc( + sizeof(ulong) * num_interrupts, GFP_KERNEL); + if (!interrupt_data->interrupt_counts) { + kfree(interrupt_data->eventfd_ctxs); + kfree(interrupt_data->msix_entries); + kfree(interrupt_data); + return -ENOMEM; + } + + switch (interrupt_data->type) { + case PCI_MSIX: + ret = gasket_interrupt_msix_init(interrupt_data); + if (ret) + break; + force_msix_interrupt_unmasking(gasket_dev); + break; + + case PCI_MSI: + case PLATFORM_WIRE: + default: + gasket_nodev_error( + "Cannot handle unsupported interrupt type %d.", + interrupt_data->type); + ret = -EINVAL; + }; + + if (ret) { + /* Failing to setup interrupts will cause the device to report + * GASKET_STATUS_LAMED. But it is not fatal. + */ + gasket_log_warn( + gasket_dev, "Couldn't initialize interrupts: %d", ret); + return 0; + } + + gasket_interrupt_setup(gasket_dev); + gasket_sysfs_create_entries( + gasket_dev->dev_info.device, interrupt_sysfs_attrs); + + return 0; +} + +static int gasket_interrupt_msix_init( + struct gasket_interrupt_data *interrupt_data) +{ + int ret = 1; + int i; + + for (i = 0; i < interrupt_data->num_interrupts; i++) { + interrupt_data->msix_entries[i].entry = i; + interrupt_data->msix_entries[i].vector = 0; + interrupt_data->eventfd_ctxs[i] = NULL; + } + + /* Retry MSIX_RETRY_COUNT times if not enough IRQs are available. */ + for (i = 0; i < MSIX_RETRY_COUNT && ret > 0; i++) + ret = pci_enable_msix_exact(interrupt_data->pci_dev, + interrupt_data->msix_entries, + interrupt_data->num_interrupts); + + if (ret) + return ret > 0 ? -EBUSY : ret; + interrupt_data->msix_configured = 1; + + for (i = 0; i < interrupt_data->num_interrupts; i++) { + ret = request_irq( + interrupt_data->msix_entries[i].vector, + gasket_msix_interrupt_handler, 0, interrupt_data->name, + interrupt_data); + + if (ret) { + gasket_nodev_error( + "Cannot get IRQ for interrupt %d, vector %d; " + "%d\n", + i, interrupt_data->msix_entries[i].vector, ret); + return ret; + } + + interrupt_data->num_configured++; + } + + return 0; +} + +static void gasket_interrupt_msix_cleanup( + struct gasket_interrupt_data *interrupt_data) +{ + int i; + + for (i = 0; i < interrupt_data->num_configured; i++) + free_irq(interrupt_data->msix_entries[i].vector, + interrupt_data); + interrupt_data->num_configured = 0; + + if (interrupt_data->msix_configured) + pci_disable_msix(interrupt_data->pci_dev); + interrupt_data->msix_configured = 0; +} + +/* + * On QCM DragonBoard, we exit gasket_interrupt_msix_init() and kernel interrupt + * setup code with MSIX vectors masked. This is wrong because nothing else in + * the driver will normally touch the MSIX vectors. + * + * As a temporary hack, force unmasking there. + * + * TODO: Figure out why QCM kernel doesn't unmask the MSIX vectors, after + * gasket_interrupt_msix_init(), and remove this code. + */ +static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev) +{ + int i; +#define MSIX_VECTOR_SIZE 16 +#define MSIX_MASK_BIT_OFFSET 12 +#define APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE 0x46800 + for (i = 0; i < gasket_dev->interrupt_data->num_configured; i++) { + /* Check if the MSIX vector is unmasked */ + ulong location = APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE + + MSIX_MASK_BIT_OFFSET + i * MSIX_VECTOR_SIZE; + u32 mask = + gasket_dev_read_32( + gasket_dev, + gasket_dev->interrupt_data->interrupt_bar_index, + location); + if (!(mask & 1)) + continue; + /* Unmask the msix vector (clear 32 bits) */ + gasket_dev_write_32( + gasket_dev, 0, + gasket_dev->interrupt_data->interrupt_bar_index, + location); + } +#undef MSIX_VECTOR_SIZE +#undef MSIX_MASK_BIT_OFFSET +#undef APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE +} + +int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) +{ + int ret; + + if (!gasket_dev->interrupt_data) { + gasket_log_error( + gasket_dev, + "Attempted to reinit uninitialized interrupt data."); + return -EINVAL; + } + + switch (gasket_dev->interrupt_data->type) { + case PCI_MSIX: + gasket_interrupt_msix_cleanup(gasket_dev->interrupt_data); + ret = gasket_interrupt_msix_init(gasket_dev->interrupt_data); + if (ret) + break; + force_msix_interrupt_unmasking(gasket_dev); + break; + + case PCI_MSI: + case PLATFORM_WIRE: + default: + gasket_nodev_error( + "Cannot handle unsupported interrupt type %d.", + gasket_dev->interrupt_data->type); + ret = -EINVAL; + }; + + if (ret) { + /* Failing to setup MSIx will cause the device + * to report GASKET_STATUS_LAMED, but is not fatal. + */ + gasket_log_warn(gasket_dev, "Couldn't init msix: %d", ret); + return 0; + } + + gasket_interrupt_setup(gasket_dev); + + return 0; +} + +/* See gasket_interrupt.h for description. */ +int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev) +{ + gasket_log_debug(gasket_dev, "Clearing interrupt counts."); + memset(gasket_dev->interrupt_data->interrupt_counts, 0, + gasket_dev->interrupt_data->num_interrupts * + sizeof(*gasket_dev->interrupt_data->interrupt_counts)); + return 0; +} + +/* + * Set up device registers for interrupt handling. + * @gasket_dev: The Gasket information structure for this device. + * + * Sets up the device registers with the correct indices for the relevant + * interrupts. + */ +static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) +{ + int i; + int pack_shift; + ulong mask; + ulong value; + struct gasket_interrupt_data *interrupt_data = + gasket_dev->interrupt_data; + + if (!interrupt_data) { + gasket_log_error( + gasket_dev, "Interrupt data is not initialized."); + return; + } + + gasket_log_debug(gasket_dev, "Running interrupt setup."); + + if (interrupt_data->type == PLATFORM_WIRE || + interrupt_data->type == PCI_MSI) { + /* Nothing needs to be done for platform or PCI devices. */ + return; + } + + if (interrupt_data->type != PCI_MSIX) { + gasket_nodev_error( + "Cannot handle unsupported interrupt type %d.", + interrupt_data->type); + return; + } + + /* Setup the MSIX table. */ + + for (i = 0; i < interrupt_data->num_interrupts; i++) { + /* + * If the interrupt is not packed, we can write the index into + * the register directly. If not, we need to deal with a read- + * modify-write and shift based on the packing index. + */ + gasket_log_debug( + gasket_dev, + "Setting up interrupt index %d with index 0x%llx and " + "packing %d", + interrupt_data->interrupts[i].index, + interrupt_data->interrupts[i].reg, + interrupt_data->interrupts[i].packing); + if (interrupt_data->interrupts[i].packing == UNPACKED) { + value = interrupt_data->interrupts[i].index; + } else { + switch (interrupt_data->interrupts[i].packing) { + case PACK_0: + pack_shift = 0; + break; + case PACK_1: + pack_shift = interrupt_data->pack_width; + break; + case PACK_2: + pack_shift = 2 * interrupt_data->pack_width; + break; + case PACK_3: + pack_shift = 3 * interrupt_data->pack_width; + break; + default: + gasket_nodev_error( + "Found interrupt description with " + "unknown enum %d.", + interrupt_data->interrupts[i].packing); + return; + } + + mask = ~(0xFFFF << pack_shift); + value = gasket_dev_read_64( + gasket_dev, + interrupt_data->interrupt_bar_index, + interrupt_data->interrupts[i].reg) & + mask; + value |= interrupt_data->interrupts[i].index + << pack_shift; + } + gasket_dev_write_64(gasket_dev, value, + interrupt_data->interrupt_bar_index, + interrupt_data->interrupts[i].reg); + } +} + +/* See gasket_interrupt.h for description. */ +void gasket_interrupt_pause(struct gasket_dev *gasket_dev, int enable_pause) +{ + WARN_ON(!gasket_dev); + + if (!gasket_dev->interrupt_data) + return; /* nothing to do */ + + if (gasket_dev->interrupt_data->type == PCI_MSI || + gasket_dev->interrupt_data->type == PCI_MSIX) { + /* Nothing to be done for MSI/MSIX just yet. */ + } + + if (gasket_dev->interrupt_data->type == PLATFORM_WIRE) { + /* Nothing to be done for PLATFORM_WIRE */ + } +} +EXPORT_SYMBOL(gasket_interrupt_pause); + +void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) +{ + struct gasket_interrupt_data *interrupt_data = + gasket_dev->interrupt_data; + /* + * It is possible to get an error code from gasket_interrupt_init + * before interrupt_data has been allocated, so check it. + */ + if (!interrupt_data) + return; + + switch (interrupt_data->type) { + case PCI_MSIX: + gasket_interrupt_msix_cleanup(interrupt_data); + break; + + case PCI_MSI: + case PLATFORM_WIRE: + default: + gasket_nodev_error( + "Cannot handle unsupported interrupt type %d.", + interrupt_data->type); + }; + + kfree(interrupt_data->interrupt_counts); + kfree(interrupt_data->eventfd_ctxs); + kfree(interrupt_data->msix_entries); + kfree(interrupt_data); + gasket_dev->interrupt_data = NULL; +} + +int gasket_interrupt_system_status(struct gasket_dev *gasket_dev) +{ + if (!gasket_dev->interrupt_data) { + gasket_nodev_info("Interrupt data is null."); + return GASKET_STATUS_DEAD; + } + + if (!gasket_dev->interrupt_data->msix_configured) { + gasket_nodev_info("Interrupt not initialized."); + return GASKET_STATUS_LAMED; + } + + if (gasket_dev->interrupt_data->num_configured != + gasket_dev->interrupt_data->num_interrupts) { + gasket_nodev_info("Not all interrupts were configured."); + return GASKET_STATUS_LAMED; + } + + return GASKET_STATUS_ALIVE; +} + +int gasket_interrupt_set_eventfd( + struct gasket_interrupt_data *interrupt_data, int interrupt, + int event_fd) +{ + struct eventfd_ctx *ctx = eventfd_ctx_fdget(event_fd); + + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + if (interrupt < 0 || interrupt > interrupt_data->num_interrupts) + return -EINVAL; + + interrupt_data->eventfd_ctxs[interrupt] = ctx; + return 0; +} + +int gasket_interrupt_clear_eventfd( + struct gasket_interrupt_data *interrupt_data, int interrupt) +{ + if (interrupt < 0 || interrupt > interrupt_data->num_interrupts) + return -EINVAL; + + interrupt_data->eventfd_ctxs[interrupt] = NULL; + return 0; +} + +int gasket_interrupt_trigger_eventfd( + struct gasket_interrupt_data *interrupt_data, int interrupt) +{ + struct eventfd_ctx *ctx = interrupt_data->eventfd_ctxs[interrupt]; + + if (!ctx) + return -EINVAL; + + eventfd_signal(ctx, 1); + return 0; +} + +struct msix_entry *gasket_interrupt_get_msix_entries( + struct gasket_interrupt_data *interrupt_data) +{ + return interrupt_data->msix_entries; +} + +struct eventfd_ctx **gasket_interrupt_get_eventfd_ctxs( + struct gasket_interrupt_data *interrupt_data) +{ + return interrupt_data->eventfd_ctxs; +} +EXPORT_SYMBOL(gasket_interrupt_get_eventfd_ctxs); + +static ssize_t interrupt_sysfs_show( + struct device *device, struct device_attribute *attr, char *buf) +{ + int i, ret; + ssize_t written = 0, total_written = 0; + struct gasket_interrupt_data *interrupt_data; + struct gasket_dev *gasket_dev; + struct gasket_sysfs_attribute *gasket_attr; + enum interrupt_sysfs_attribute_type sysfs_type; + + gasket_dev = gasket_sysfs_get_device_data(device); + if (!gasket_dev) { + gasket_nodev_error( + "No sysfs mapping found for device 0x%p", device); + return 0; + } + + gasket_attr = gasket_sysfs_get_attr(device, attr); + if (!gasket_attr) { + gasket_nodev_error( + "No sysfs attr data found for device 0x%p", device); + gasket_sysfs_put_device_data(device, gasket_dev); + return 0; + } + + sysfs_type = (enum interrupt_sysfs_attribute_type) + gasket_attr->data.attr_type; + interrupt_data = gasket_dev->interrupt_data; + switch (sysfs_type) { + case ATTR_INTERRUPT_COUNTS: + for (i = 0; i < interrupt_data->num_interrupts; ++i) { + written = + scnprintf(buf, PAGE_SIZE - total_written, + "0x%02x: %ld\n", i, + interrupt_data->interrupt_counts[i]); + total_written += written; + buf += written; + } + ret = total_written; + break; + default: + gasket_log_error( + gasket_dev, "Unknown attribute: %s", attr->attr.name); + ret = 0; + break; + } + + gasket_sysfs_put_attr(device, gasket_attr); + gasket_sysfs_put_device_data(device, gasket_dev); + return ret; +} + +/* + * MSIX interrupt handler, used with PCI driver. + */ +static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id) +{ + struct eventfd_ctx *ctx; + struct gasket_interrupt_data *interrupt_data = dev_id; + int interrupt = -1; + int i; + + /* If this linear lookup is a problem, we can maintain a map/hash. */ + for (i = 0; i < interrupt_data->num_interrupts; i++) { + if (interrupt_data->msix_entries[i].vector == irq) { + interrupt = interrupt_data->msix_entries[i].entry; + break; + } + } + if (interrupt == -1) { + gasket_nodev_error("Received unknown irq %d", irq); + return IRQ_HANDLED; + } + trace_gasket_interrupt_event(interrupt_data->name, interrupt); + + ctx = interrupt_data->eventfd_ctxs[interrupt]; + if (ctx) + eventfd_signal(ctx, 1); + + ++(interrupt_data->interrupt_counts[interrupt]); + + return IRQ_HANDLED; +} diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h new file mode 100644 index 000000000000..3a8afae6487a --- /dev/null +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -0,0 +1,172 @@ +/* + * Gasket common interrupt module. Defines functions for enabling + * eventfd-triggered interrupts between a Gasket device and a host process. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __GASKET_INTERRUPT_H__ +#define __GASKET_INTERRUPT_H__ + +#include +#include + +#include "gasket_core.h" + +/* Note that this currently assumes that device interrupts are a dense set, + * numbered from 0 - (num_interrupts - 1). Should this have to change, these + * APIs will have to be updated. + */ + +/* Opaque type used to hold interrupt subsystem data. */ +struct gasket_interrupt_data; + +/* + * Initialize the interrupt module. + * @gasket_dev: The Gasket device structure for the device to be initted. + * @type: Type of the interrupt. (See gasket_interrupt_type). + * @name: The name to associate with these interrupts. + * @interrupts: An array of all interrupt descriptions for this device. + * @num_interrupts: The length of the @interrupts array. + * @pack_width: The width, in bits, of a single field in a packed interrupt reg. + * @bar_index: The bar containing all interrupt registers. + * + * Allocates and initializes data to track interrupt state for a device. + * After this call, no interrupts will be configured/delivered; call + * gasket_interrupt_set_vector[_packed] to associate each interrupt with an + * __iomem location, then gasket_interrupt_set_eventfd to associate an eventfd + * with an interrupt. + * + * If num_interrupts interrupts are not available, this call will return a + * negative error code. In that case, gasket_interrupt_cleanup should still be + * called. Returns 0 on success (which can include a device where interrupts + * are not possible to set up, but is otherwise OK; that device will report + * status LAMED.) + */ +int gasket_interrupt_init( + struct gasket_dev *gasket_dev, const char *name, int type, + const struct gasket_interrupt_desc *interrupts, + int num_interrupts, int pack_width, int bar_index, + const struct gasket_wire_interrupt_offsets *wire_int_offsets); + +/* + * Clean up a device's interrupt structure. + * @gasket_dev: The Gasket information structure for this device. + * + * Cleans up the device's interrupts and deallocates data. + */ +void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev); + +/* + * Clean up and re-initialize the MSI-x subsystem. + * @gasket_dev: The Gasket information structure for this device. + * + * Performs a teardown of the MSI-x subsystem and re-initializes it. Does not + * free the underlying data structures. Returns 0 on success and an error code + * on error. + */ +int gasket_interrupt_reinit(struct gasket_dev *gasket_dev); + +/* + * Reset the counts stored in the interrupt subsystem. + * @gasket_dev: The Gasket information structure for this device. + * + * Sets the counts of all interrupts in the subsystem to 0. + */ +int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev); + +/* + * Associates an eventfd with a device interrupt. + * @data: Pointer to device interrupt data. + * @interrupt: The device interrupt to configure. + * @event_fd: The eventfd to associate with the interrupt. + * + * Prepares the host to receive notification of device interrupts by associating + * event_fd with interrupt. Upon receipt of a device interrupt, event_fd will be + * signaled, after successful configuration. + * + * Returns 0 on success, a negative error code otherwise. + */ +int gasket_interrupt_set_eventfd( + struct gasket_interrupt_data *interrupt_data, int interrupt, + int event_fd); + +/* + * Removes an interrupt-eventfd association. + * @data: Pointer to device interrupt data. + * @interrupt: The device interrupt to de-associate. + * + * Removes any eventfd associated with the specified interrupt, if any. + */ +int gasket_interrupt_clear_eventfd( + struct gasket_interrupt_data *interrupt_data, int interrupt); + +/* + * Signals the eventfd associated with interrupt. + * @data: Pointer to device interrupt data. + * @interrupt: The device interrupt to signal for. + * + * Simulates a device interrupt by signaling the eventfd associated with + * interrupt, if any. + * Returns 0 if the eventfd was successfully triggered, a negative error code + * otherwise (if, for example, no eventfd was associated with interrupt). + */ +int gasket_interrupt_trigger_eventfd( + struct gasket_interrupt_data *interrupt_data, int interrupt); + +/* + * The below functions exist for backwards compatibility. + * No new uses should be written. + */ +/* + * Retrieve a pointer to data's MSI-X + * entries. + * @data: The interrupt data from which to extract. + * + * Returns the internal pointer to data's MSI-X entries. + */ +struct msix_entry *gasket_interrupt_get_msix_entries( + struct gasket_interrupt_data *interrupt_data); + +/* + * Get a pointer to data's eventfd contexts. + * @data: The interrupt data from which to extract. + * + * Returns the internal pointer to data's eventfd contexts. + * + * This function exists for backwards compatibility with older drivers. + * No new uses should be written. + */ +struct eventfd_ctx **gasket_interrupt_get_eventfd_ctxs( + struct gasket_interrupt_data *interrupt_data); + +/* + * Get the health of the interrupt subsystem. + * @gasket_dev: The Gasket device struct. + * + * Returns DEAD if not set up, LAMED if initialization failed, and ALIVE + * otherwise. + */ + +int gasket_interrupt_system_status(struct gasket_dev *gasket_dev); + +/* + * Masks interrupts and de-register the handler. + * After an interrupt pause it is not guaranteed that the chip registers will + * be accessible anymore, since the chip may be in a power save mode, + * which means that the interrupt handler (if it were to happen) may not + * have a way to clear the interrupt condition. + * @gasket_dev: The Gasket device struct + * @enable_pause: Whether to pause or unpause the interrupts. + */ +void gasket_interrupt_pause(struct gasket_dev *gasket_dev, int enable_pause); + +#endif diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c new file mode 100644 index 000000000000..4758083fb19b --- /dev/null +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -0,0 +1,449 @@ +/* Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include "gasket.h" +#include "gasket_ioctl.h" +#include "gasket_constants.h" +#include "gasket_core.h" +#include "gasket_interrupt.h" +#include "gasket_logging.h" +#include "gasket_page_table.h" +#include +#include + +#ifdef GASKET_KERNEL_TRACE_SUPPORT +#define CREATE_TRACE_POINTS +#include +#else +#define trace_gasket_ioctl_entry(x, ...) +#define trace_gasket_ioctl_exit(x) +#define trace_gasket_ioctl_integer_data(x) +#define trace_gasket_ioctl_eventfd_data(x, ...) +#define trace_gasket_ioctl_page_table_data(x, ...) +#define trace_gasket_ioctl_config_coherent_allocator(x, ...) +#endif + +static uint gasket_ioctl_check_permissions(struct file *filp, uint cmd); +static int gasket_set_event_fd(struct gasket_dev *dev, ulong arg); +static int gasket_read_page_table_size( + struct gasket_dev *gasket_dev, ulong arg); +static int gasket_read_simple_page_table_size( + struct gasket_dev *gasket_dev, ulong arg); +static int gasket_partition_page_table( + struct gasket_dev *gasket_dev, ulong arg); +static int gasket_map_buffers(struct gasket_dev *gasket_dev, ulong arg); +static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, ulong arg); +static int gasket_config_coherent_allocator( + struct gasket_dev *gasket_dev, ulong arg); + +/* + * standard ioctl dispatch function. + * @filp: File structure pointer describing this node usage session. + * @cmd: ioctl number to handle. + * @arg: ioctl-specific data pointer. + * + * Standard ioctl dispatcher; forwards operations to individual handlers. + */ +long gasket_handle_ioctl(struct file *filp, uint cmd, ulong arg) +{ + struct gasket_dev *gasket_dev; + int retval; + + gasket_dev = (struct gasket_dev *)filp->private_data; + trace_gasket_ioctl_entry(gasket_dev->dev_info.name, cmd); + + if (gasket_get_ioctl_permissions_cb(gasket_dev)) { + retval = gasket_get_ioctl_permissions_cb(gasket_dev)( + filp, cmd, arg); + if (retval < 0) { + trace_gasket_ioctl_exit(-EPERM); + return retval; + } else if (retval == 0) { + trace_gasket_ioctl_exit(-EPERM); + return -EPERM; + } + } else if (!gasket_ioctl_check_permissions(filp, cmd)) { + trace_gasket_ioctl_exit(-EPERM); + gasket_log_error(gasket_dev, "ioctl cmd=%x noperm.", cmd); + return -EPERM; + } + + /* Tracing happens in this switch statement for all ioctls with + * an integer argrument, but ioctls with a struct argument + * that needs copying and decoding, that tracing is done within + * the handler call. + */ + switch (cmd) { + case GASKET_IOCTL_RESET: + trace_gasket_ioctl_integer_data(arg); + retval = gasket_reset(gasket_dev, arg); + break; + case GASKET_IOCTL_SET_EVENTFD: + retval = gasket_set_event_fd(gasket_dev, arg); + break; + case GASKET_IOCTL_CLEAR_EVENTFD: + trace_gasket_ioctl_integer_data(arg); + retval = gasket_interrupt_clear_eventfd( + gasket_dev->interrupt_data, (int)arg); + break; + case GASKET_IOCTL_PARTITION_PAGE_TABLE: + trace_gasket_ioctl_integer_data(arg); + retval = gasket_partition_page_table(gasket_dev, arg); + break; + case GASKET_IOCTL_NUMBER_PAGE_TABLES: + trace_gasket_ioctl_integer_data(gasket_dev->num_page_tables); + if (copy_to_user((void __user *)arg, + &gasket_dev->num_page_tables, + sizeof(uint64_t))) + retval = -EFAULT; + else + retval = 0; + break; + case GASKET_IOCTL_PAGE_TABLE_SIZE: + retval = gasket_read_page_table_size(gasket_dev, arg); + break; + case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: + retval = gasket_read_simple_page_table_size(gasket_dev, arg); + break; + case GASKET_IOCTL_MAP_BUFFER: + retval = gasket_map_buffers(gasket_dev, arg); + break; + case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: + retval = gasket_config_coherent_allocator(gasket_dev, arg); + break; + case GASKET_IOCTL_UNMAP_BUFFER: + retval = gasket_unmap_buffers(gasket_dev, arg); + break; + case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: + /* Clear interrupt counts doesn't take an arg, so use 0. */ + trace_gasket_ioctl_integer_data(0); + retval = gasket_interrupt_reset_counts(gasket_dev); + break; + default: + /* If we don't understand the ioctl, the best we can do is trace + * the arg. + */ + trace_gasket_ioctl_integer_data(arg); + gasket_log_warn( + gasket_dev, + "Unknown ioctl cmd=0x%x not caught by " + "gasket_is_supported_ioctl", + cmd); + retval = -EINVAL; + break; + } + + trace_gasket_ioctl_exit(retval); + return retval; +} + +/* + * Determines if an ioctl is part of the standard Gasket framework. + * @cmd: The ioctl number to handle. + * + * Returns 1 if the ioctl is supported and 0 otherwise. + */ +long gasket_is_supported_ioctl(uint cmd) +{ + switch (cmd) { + case GASKET_IOCTL_RESET: + case GASKET_IOCTL_SET_EVENTFD: + case GASKET_IOCTL_CLEAR_EVENTFD: + case GASKET_IOCTL_PARTITION_PAGE_TABLE: + case GASKET_IOCTL_NUMBER_PAGE_TABLES: + case GASKET_IOCTL_PAGE_TABLE_SIZE: + case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: + case GASKET_IOCTL_MAP_BUFFER: + case GASKET_IOCTL_UNMAP_BUFFER: + case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: + case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: + return 1; + default: + return 0; + } +} + +/* + * Permission checker for Gasket ioctls. + * @filp: File structure pointer describing this node usage session. + * @cmd: ioctl number to handle. + * + * Standard permissions checker. + */ +static uint gasket_ioctl_check_permissions(struct file *filp, uint cmd) +{ + uint alive, root, device_owner; + fmode_t read, write; + struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data; + + alive = (gasket_dev->status == GASKET_STATUS_ALIVE); + if (!alive) { + gasket_nodev_error( + "gasket_ioctl_check_permissions alive %d status %d.", + alive, gasket_dev->status); + } + + root = capable(CAP_SYS_ADMIN); + read = filp->f_mode & FMODE_READ; + write = filp->f_mode & FMODE_WRITE; + device_owner = (gasket_dev->dev_info.ownership.is_owned && + current->tgid == gasket_dev->dev_info.ownership.owner); + + switch (cmd) { + case GASKET_IOCTL_RESET: + case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: + return root || (write && device_owner); + + case GASKET_IOCTL_PAGE_TABLE_SIZE: + case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: + case GASKET_IOCTL_NUMBER_PAGE_TABLES: + return root || read; + + case GASKET_IOCTL_PARTITION_PAGE_TABLE: + case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: + return alive && (root || (write && device_owner)); + + case GASKET_IOCTL_MAP_BUFFER: + case GASKET_IOCTL_UNMAP_BUFFER: + return alive && (root || (write && device_owner)); + + case GASKET_IOCTL_CLEAR_EVENTFD: + case GASKET_IOCTL_SET_EVENTFD: + return alive && (root || (write && device_owner)); + } + + return 0; /* unknown permissions */ +} + +/* + * Associate an eventfd with an interrupt. + * @gasket_dev: Pointer to the current gasket_dev we're using. + * @arg: Pointer to gasket_interrupt_eventfd struct in userspace. + */ +static int gasket_set_event_fd(struct gasket_dev *gasket_dev, ulong arg) +{ + struct gasket_interrupt_eventfd die; + + if (copy_from_user(&die, (void __user *)arg, + sizeof(struct gasket_interrupt_eventfd))) { + return -EFAULT; + } + + trace_gasket_ioctl_eventfd_data(die.interrupt, die.event_fd); + + return gasket_interrupt_set_eventfd( + gasket_dev->interrupt_data, die.interrupt, die.event_fd); +} + +/* + * Reads the size of the page table. + * @gasket_dev: Pointer to the current gasket_dev we're using. + * @arg: Pointer to gasket_page_table_ioctl struct in userspace. + */ +static int gasket_read_page_table_size(struct gasket_dev *gasket_dev, ulong arg) +{ + int ret = 0; + struct gasket_page_table_ioctl ibuf; + + if (copy_from_user(&ibuf, (void __user *)arg, + sizeof(struct gasket_page_table_ioctl))) + return -EFAULT; + + if (ibuf.page_table_index >= gasket_dev->num_page_tables) + return -EFAULT; + + ibuf.size = gasket_page_table_num_entries( + gasket_dev->page_table[ibuf.page_table_index]); + + trace_gasket_ioctl_page_table_data( + ibuf.page_table_index, ibuf.size, ibuf.host_address, + ibuf.device_address); + + if (copy_to_user((void __user *)arg, &ibuf, sizeof(ibuf))) + return -EFAULT; + + return ret; +} + +/* + * Reads the size of the simple page table. + * @gasket_dev: Pointer to the current gasket_dev we're using. + * @arg: Pointer to gasket_page_table_ioctl struct in userspace. + */ +static int gasket_read_simple_page_table_size( + struct gasket_dev *gasket_dev, ulong arg) +{ + int ret = 0; + struct gasket_page_table_ioctl ibuf; + + if (copy_from_user(&ibuf, (void __user *)arg, + sizeof(struct gasket_page_table_ioctl))) + return -EFAULT; + + if (ibuf.page_table_index >= gasket_dev->num_page_tables) + return -EFAULT; + + ibuf.size = gasket_page_table_num_simple_entries( + gasket_dev->page_table[ibuf.page_table_index]); + + trace_gasket_ioctl_page_table_data( + ibuf.page_table_index, ibuf.size, ibuf.host_address, + ibuf.device_address); + + if (copy_to_user((void __user *)arg, &ibuf, sizeof(ibuf))) + return -EFAULT; + + return ret; +} + +/* + * Sets the boundary between the simple and extended page tables. + * @gasket_dev: Pointer to the current gasket_dev we're using. + * @arg: Pointer to gasket_page_table_ioctl struct in userspace. + */ +static int gasket_partition_page_table(struct gasket_dev *gasket_dev, ulong arg) +{ + int ret; + struct gasket_page_table_ioctl ibuf; + uint max_page_table_size; + + if (copy_from_user(&ibuf, (void __user *)arg, + sizeof(struct gasket_page_table_ioctl))) + return -EFAULT; + + trace_gasket_ioctl_page_table_data( + ibuf.page_table_index, ibuf.size, ibuf.host_address, + ibuf.device_address); + + if (ibuf.page_table_index >= gasket_dev->num_page_tables) + return -EFAULT; + max_page_table_size = gasket_page_table_max_size( + gasket_dev->page_table[ibuf.page_table_index]); + + if (ibuf.size > max_page_table_size) { + gasket_log_error( + gasket_dev, + "Partition request 0x%llx too large, max is 0x%x.", + ibuf.size, max_page_table_size); + return -EINVAL; + } + + mutex_lock(&gasket_dev->mutex); + + ret = gasket_page_table_partition( + gasket_dev->page_table[ibuf.page_table_index], ibuf.size); + mutex_unlock(&gasket_dev->mutex); + + return ret; +} + +/* + * Maps a userspace buffer to a device virtual address. + * @gasket_dev: Pointer to the current gasket_dev we're using. + * @arg: Pointer to a gasket_page_table_ioctl struct in userspace. + */ +static int gasket_map_buffers(struct gasket_dev *gasket_dev, ulong arg) +{ + struct gasket_page_table_ioctl ibuf; + + if (copy_from_user(&ibuf, (void __user *)arg, + sizeof(struct gasket_page_table_ioctl))) + return -EFAULT; + + trace_gasket_ioctl_page_table_data( + ibuf.page_table_index, ibuf.size, ibuf.host_address, + ibuf.device_address); + + if (ibuf.page_table_index >= gasket_dev->num_page_tables) + return -EFAULT; + + if (gasket_page_table_are_addrs_bad( + gasket_dev->page_table[ibuf.page_table_index], + ibuf.host_address, ibuf.device_address, ibuf.size)) + return -EINVAL; + + return gasket_page_table_map( + gasket_dev->page_table[ibuf.page_table_index], + ibuf.host_address, ibuf.device_address, ibuf.size / PAGE_SIZE); +} + +/* + * Unmaps a userspace buffer from a device virtual address. + * @gasket_dev: Pointer to the current gasket_dev we're using. + * @arg: Pointer to a gasket_page_table_ioctl struct in userspace. + */ +static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, ulong arg) +{ + struct gasket_page_table_ioctl ibuf; + + if (copy_from_user(&ibuf, (void __user *)arg, + sizeof(struct gasket_page_table_ioctl))) + return -EFAULT; + + trace_gasket_ioctl_page_table_data( + ibuf.page_table_index, ibuf.size, ibuf.host_address, + ibuf.device_address); + + if (ibuf.page_table_index >= gasket_dev->num_page_tables) + return -EFAULT; + + if (gasket_page_table_is_dev_addr_bad( + gasket_dev->page_table[ibuf.page_table_index], + ibuf.device_address, ibuf.size)) + return -EINVAL; + + gasket_page_table_unmap(gasket_dev->page_table[ibuf.page_table_index], + ibuf.device_address, ibuf.size / PAGE_SIZE); + + return 0; +} + +/* + * Tell the driver to reserve structures for coherent allocation, and allocate + * or free the corresponding memory. + * @dev: Pointer to the current gasket_dev we're using. + * @arg: Pointer to a gasket_coherent_alloc_config_ioctl struct in userspace. + */ +static int gasket_config_coherent_allocator( + struct gasket_dev *gasket_dev, ulong arg) +{ + int ret; + struct gasket_coherent_alloc_config_ioctl ibuf; + + if (copy_from_user(&ibuf, (void __user *)arg, + sizeof(struct gasket_coherent_alloc_config_ioctl))) + return -EFAULT; + + trace_gasket_ioctl_config_coherent_allocator( + ibuf.enable, ibuf.size, ibuf.dma_address); + + if (ibuf.page_table_index >= gasket_dev->num_page_tables) + return -EFAULT; + + if (ibuf.size > PAGE_SIZE * MAX_NUM_COHERENT_PAGES) { + ibuf.size = PAGE_SIZE * MAX_NUM_COHERENT_PAGES; + return -ENOMEM; + } + + if (ibuf.enable == 0) { + ret = gasket_free_coherent_memory( + gasket_dev, ibuf.size, ibuf.dma_address, + ibuf.page_table_index); + } else { + ret = gasket_alloc_coherent_memory( + gasket_dev, ibuf.size, &ibuf.dma_address, + ibuf.page_table_index); + } + if (copy_to_user((void __user *)arg, &ibuf, sizeof(ibuf))) + return -EFAULT; + + return ret; +} diff --git a/drivers/staging/gasket/gasket_ioctl.h b/drivers/staging/gasket/gasket_ioctl.h new file mode 100644 index 000000000000..df868000c803 --- /dev/null +++ b/drivers/staging/gasket/gasket_ioctl.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __GASKET_IOCTL_H__ +#define __GASKET_IOCTL_H__ + +#include "gasket_core.h" + +/* + * Handle Gasket common ioctls. + * @filp: Pointer to the ioctl's file. + * @cmd: Ioctl command. + * @arg: Ioctl argument pointer. + * + * Returns 0 on success and nonzero on failure. + */ +long gasket_handle_ioctl(struct file *filp, uint cmd, ulong arg); + +/* + * Determines if an ioctl is part of the standard Gasket framework. + * @cmd: The ioctl number to handle. + * + * Returns 1 if the ioctl is supported and 0 otherwise. + */ +long gasket_is_supported_ioctl(uint cmd); + +#endif diff --git a/drivers/staging/gasket/gasket_logging.h b/drivers/staging/gasket/gasket_logging.h new file mode 100644 index 000000000000..fa17b4ae455a --- /dev/null +++ b/drivers/staging/gasket/gasket_logging.h @@ -0,0 +1,71 @@ +/* Common logging utilities for the Gasket driver framework. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +#ifndef _GASKET_LOGGING_H_ +#define _GASKET_LOGGING_H_ + +/* Base macro; other logging can/should be built on top of this. */ +#define gasket_dev_log(level, device, pci_dev, format, arg...) \ + if (false) { \ + if (pci_dev) { \ + dev_##level(&(pci_dev)->dev, "%s: " format "\n", \ + __func__, ##arg); \ + } else { \ + gasket_nodev_log(level, format, ##arg); \ + } \ + } + +/* "No-device" logging macros. */ +#define gasket_nodev_log(level, format, arg...) \ + if (false) pr_##level("gasket: %s: " format "\n", __func__, ##arg) + +#define gasket_nodev_debug(format, arg...) \ + if (false) gasket_nodev_log(debug, format, ##arg) + +#define gasket_nodev_info(format, arg...) \ + if (false) gasket_nodev_log(info, format, ##arg) + +#define gasket_nodev_warn(format, arg...) \ + if (false) gasket_nodev_log(warn, format, ##arg) + +#define gasket_nodev_error(format, arg...) \ + if (false) gasket_nodev_log(err, format, ##arg) + +/* gasket_dev logging macros */ +#define gasket_log_info(gasket_dev, format, arg...) \ + if (false) gasket_dev_log(info, (gasket_dev)->dev_info.device, \ + (gasket_dev)->pci_dev, format, ##arg) + +#define gasket_log_warn(gasket_dev, format, arg...) \ + if (false) gasket_dev_log(warn, (gasket_dev)->dev_info.device, \ + (gasket_dev)->pci_dev, format, ##arg) + +#define gasket_log_error(gasket_dev, format, arg...) \ + if (false) gasket_dev_log(err, (gasket_dev)->dev_info.device, \ + (gasket_dev)->pci_dev, format, ##arg) + +#define gasket_log_debug(gasket_dev, format, arg...) \ + if (false){ \ + if ((gasket_dev)->pci_dev) { \ + dev_dbg(&((gasket_dev)->pci_dev)->dev, "%s: " format \ + "\n", __func__, ##arg); \ + } else { \ + gasket_nodev_log(debug, format, ##arg); \ + } \ + } + +#endif diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c new file mode 100644 index 000000000000..6dc10508b15e --- /dev/null +++ b/drivers/staging/gasket/gasket_page_table.c @@ -0,0 +1,1771 @@ +/* Implementation of Gasket page table support. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * Implementation of Gasket page table support. + * + * This file assumes 4kB pages throughout; can be factored out when necessary. + * + * Address format is as follows: + * Simple addresses - those whose containing pages are directly placed in the + * device's address translation registers - are laid out as: + * [ 63 - 40: Unused | 39 - 28: 0 | 27 - 12: page index | 11 - 0: page offset ] + * page index: The index of the containing page in the device's address + * translation registers. + * page offset: The index of the address into the containing page. + * + * Extended address - those whose containing pages are contained in a second- + * level page table whose address is present in the device's address translation + * registers - are laid out as: + * [ 63 - 40: Unused | 39: flag | 38 - 37: 0 | 36 - 21: dev/level 0 index | + * 20 - 12: host/level 1 index | 11 - 0: page offset ] + * flag: Marker indicating that this is an extended address. Always 1. + * dev index: The index of the first-level page in the device's extended + * address translation registers. + * host index: The index of the containing page in the [host-resident] second- + * level page table. + * page offset: The index of the address into the containing [second-level] + * page. + */ +#include "gasket_page_table.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "gasket_constants.h" +#include "gasket_core.h" +#include "gasket_logging.h" + +/* Constants & utility macros */ +/* The number of pages that can be mapped into each second-level page table. */ +#define GASKET_PAGES_PER_SUBTABLE 512 + +/* The starting position of the page index in a simple virtual address. */ +#define GASKET_SIMPLE_PAGE_SHIFT 12 + +/* Flag indicating that a [device] slot is valid for use. */ +#define GASKET_VALID_SLOT_FLAG 1 + +/* + * The starting position of the level 0 page index (i.e., the entry in the + * device's extended address registers) in an extended address. + * Also can be thought of as (log2(PAGE_SIZE) + log2(PAGES_PER_SUBTABLE)), + * or (12 + 9). + */ +#define GASKET_EXTENDED_LVL0_SHIFT 21 + +/* + * Number of first level pages that Gasket chips support. Equivalent to + * log2(NUM_LVL0_PAGE_TABLES) + * + * At a maximum, allowing for a 34 bits address space (or 16GB) + * = GASKET_EXTENDED_LVL0_WIDTH + (log2(PAGE_SIZE) + log2(PAGES_PER_SUBTABLE) + * or, = 13 + 9 + 12 + */ +#define GASKET_EXTENDED_LVL0_WIDTH 13 + +/* + * The starting position of the level 1 page index (i.e., the entry in the + * host second-level/sub- table) in an extended address. + */ +#define GASKET_EXTENDED_LVL1_SHIFT 12 + +/* Page-table specific error logging. */ +#define gasket_pg_tbl_error(pg_tbl, format, arg...) \ + gasket_dev_log(err, (pg_tbl)->device, (struct pci_dev *)NULL, format, \ + ##arg) + +/* Type declarations */ +/* Valid states for a struct gasket_page_table_entry. */ +enum pte_status { + PTE_FREE, + PTE_INUSE, +}; + +/* + * Mapping metadata for a single page. + * + * In this file, host-side page table entries are referred to as that (or PTEs). + * Where device vs. host entries are differentiated, device-side or -visible + * entries are called "slots". A slot may be either an entry in the device's + * address translation table registers or an entry in a second-level page + * table ("subtable"). + * + * The full data in this structure is visible on the host [of course]. Only + * the address contained in dma_addr is communicated to the device; that points + * to the actual page mapped and described by this structure. + */ +struct gasket_page_table_entry { + /* The status of this entry/slot: free or in use. */ + enum pte_status status; + + /* Address of the page in DMA space. */ + dma_addr_t dma_addr; + + /* Linux page descriptor for the page described by this structure. */ + struct page *page; + + /* + * Index for alignment into host vaddrs. + * When a user specifies a host address for a mapping, that address may + * not be page-aligned. Offset is the index into the containing page of + * the host address (i.e., host_vaddr & (PAGE_SIZE - 1)). + * This is necessary for translating between user-specified addresses + * and page-aligned addresses. + */ + int offset; + + /* + * If this is an extended and first-level entry, sublevel points + * to the second-level entries underneath this entry. + */ + struct gasket_page_table_entry *sublevel; +}; + +/* + * Maintains virtual to physical address mapping for a coherent page that is + * allocated by this module for a given device. + * Note that coherent pages mappings virt mapping cannot be tracked by the + * Linux kernel, and coherent pages don't have a struct page associated, + * hence Linux kernel cannot perform a get_user_page_xx() on a phys address + * that was allocated coherent. + * This structure trivially implements this mechanism. + */ +struct gasket_coherent_page_entry { + /* Phys address, dma'able by the owner device */ + dma_addr_t paddr; + + /* Kernel virtual address */ + u64 user_virt; + + /* User virtual address that was mapped by the mmap kernel subsystem */ + u64 kernel_virt; + + /* + * Whether this page has been mapped into a user land process virtual + * space + */ + u32 in_use; +}; + +/* + * [Host-side] page table descriptor. + * + * This structure tracks the metadata necessary to manage both simple and + * extended page tables. + */ +struct gasket_page_table { + /* The config used to create this page table. */ + struct gasket_page_table_config config; + + /* The number of simple (single-level) entries in the page table. */ + uint num_simple_entries; + + /* The number of extended (two-level) entries in the page table. */ + uint num_extended_entries; + + /* Array of [host-side] page table entries. */ + struct gasket_page_table_entry *entries; + + /* Number of actively mapped kernel pages in this table. */ + uint num_active_pages; + + /* Device register: base of/first slot in the page table. */ + u64 __iomem *base_slot; + + /* Device register: holds the offset indicating the start of the + * extended address region of the device's address translation table. + */ + u64 __iomem *extended_offset_reg; + + /* Device structure for the underlying device. Only used for logging. */ + struct device *device; + + /* PCI system descriptor for the underlying device. */ + struct pci_dev *pci_dev; + + /* Location of the extended address bit for this Gasket device. */ + u64 extended_flag; + + /* Mutex to protect page table internals. */ + struct mutex mutex; + + /* Number of coherent pages accessible thru by this page table */ + int num_coherent_pages; + + /* + * List of coherent memory (physical) allocated for a device. + * + * This structure also remembers the user virtual mapping, this is + * hacky, but we need to do this because the kernel doesn't keep track + * of the user coherent pages (pfn pages), and virt to coherent page + * mapping. + * TODO: use find_vma() APIs to convert host address to vm_area, to + * dma_addr_t instead of storing user virtu address in + * gasket_coherent_page_entry + * + * Note that the user virtual mapping is created by the driver, in + * gasket_mmap function, so user_virt belongs in the driver anyhow. + */ + struct gasket_coherent_page_entry *coherent_pages; + + /* + * Whether the page table uses arch specific dma_ops or + * whether the driver is supplying its own. + */ + bool dma_ops; +}; + +/* Mapping declarations */ +static int gasket_map_simple_pages( + struct gasket_page_table *pg_tbl, ulong host_addr, + ulong dev_addr, uint num_pages); +static int gasket_map_extended_pages( + struct gasket_page_table *pg_tbl, ulong host_addr, + ulong dev_addr, uint num_pages); +static int gasket_perform_mapping( + struct gasket_page_table *pg_tbl, + struct gasket_page_table_entry *pte_base, u64 __iomem *att_base, + ulong host_addr, uint num_pages, int is_simple_mapping); + +static int gasket_alloc_simple_entries( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); +static int gasket_alloc_extended_entries( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries); +static int gasket_alloc_extended_subtable( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, + u64 __iomem *att_reg); + +/* Unmapping declarations */ +static void gasket_page_table_unmap_nolock( + struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages); +static void gasket_page_table_unmap_all_nolock( + struct gasket_page_table *pg_tbl); +static void gasket_unmap_simple_pages( + struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages); +static void gasket_unmap_extended_pages( + struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages); +static void gasket_perform_unmapping( + struct gasket_page_table *pg_tbl, + struct gasket_page_table_entry *pte_base, u64 __iomem *att_base, + uint num_pages, int is_simple_mapping); + +static void gasket_free_extended_subtable( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, + u64 __iomem *att_reg); +static int gasket_release_page(struct page *page); + +/* Other/utility declarations */ +static inline int gasket_addr_is_simple( + struct gasket_page_table *pg_tbl, ulong addr); +static int gasket_is_simple_dev_addr_bad( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); +static int gasket_is_extended_dev_addr_bad( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); +static int gasket_is_pte_range_free( + struct gasket_page_table_entry *pte, uint num_entries); +static void gasket_page_table_garbage_collect_nolock( + struct gasket_page_table *pg_tbl); + +/* Address format declarations */ +static ulong gasket_components_to_dev_address( + struct gasket_page_table *pg_tbl, int is_simple, uint page_index, + uint offset); +static int gasket_simple_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr); +static ulong gasket_extended_lvl0_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr); +static ulong gasket_extended_lvl1_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr); + +static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr); + +/* Public/exported functions */ +/* See gasket_page_table.h for description. */ +int gasket_page_table_init( + struct gasket_page_table **ppg_tbl, + const struct gasket_bar_data *bar_data, + const struct gasket_page_table_config *page_table_config, + struct device *device, struct pci_dev *pci_dev, bool has_dma_ops) +{ + ulong bytes; + struct gasket_page_table *pg_tbl; + ulong total_entries = page_table_config->total_entries; + + /* + * TODO: Verify config->total_entries against value read from the + * hardware register that contains the page table size. + */ + if (total_entries == ULONG_MAX) { + gasket_nodev_error( + "Error reading page table size. " + "Initializing page table with size 0."); + total_entries = 0; + } + + gasket_nodev_debug( + "Attempting to initialize page table of size 0x%lx.", + total_entries); + + gasket_nodev_debug( + "Table has base reg 0x%x, extended offset reg 0x%x.", + page_table_config->base_reg, + page_table_config->extended_reg); + + *ppg_tbl = kzalloc(sizeof(**ppg_tbl), GFP_KERNEL); + if (!*ppg_tbl) { + gasket_nodev_error("No memory for page table."); + return -ENOMEM; + } + + pg_tbl = *ppg_tbl; + bytes = total_entries * sizeof(struct gasket_page_table_entry); + if (bytes != 0) { + pg_tbl->entries = vmalloc(bytes); + if (!pg_tbl->entries) { + gasket_nodev_error( + "No memory for address translation metadata."); + kfree(pg_tbl); + *ppg_tbl = NULL; + return -ENOMEM; + } + memset(pg_tbl->entries, 0, bytes); + } + + mutex_init(&pg_tbl->mutex); + memcpy(&pg_tbl->config, page_table_config, sizeof(*page_table_config)); + if (pg_tbl->config.mode == GASKET_PAGE_TABLE_MODE_NORMAL || + pg_tbl->config.mode == GASKET_PAGE_TABLE_MODE_SIMPLE) { + pg_tbl->num_simple_entries = total_entries; + pg_tbl->num_extended_entries = 0; + pg_tbl->extended_flag = 1ull << page_table_config->extended_bit; + } else { + pg_tbl->num_simple_entries = 0; + pg_tbl->num_extended_entries = total_entries; + pg_tbl->extended_flag = 0; + } + pg_tbl->num_active_pages = 0; + pg_tbl->base_slot = (u64 __iomem *)&( + bar_data->virt_base[page_table_config->base_reg]); + pg_tbl->extended_offset_reg = (u64 __iomem *)&( + bar_data->virt_base[page_table_config->extended_reg]); + pg_tbl->device = device; + pg_tbl->pci_dev = pci_dev; + pg_tbl->dma_ops = has_dma_ops; + + gasket_nodev_debug("Page table initialized successfully."); + + return 0; +} + +/* See gasket_page_table.h for description. */ +void gasket_page_table_cleanup(struct gasket_page_table *pg_tbl) +{ + /* Deallocate free second-level tables. */ + gasket_page_table_garbage_collect(pg_tbl); + + /* TODO: Check that all PTEs have been freed? */ + + vfree(pg_tbl->entries); + pg_tbl->entries = NULL; + + kfree(pg_tbl); +} + +/* See gasket_page_table.h for description. */ +int gasket_page_table_partition( + struct gasket_page_table *pg_tbl, uint num_simple_entries) +{ + int i, start; + + mutex_lock(&pg_tbl->mutex); + if (num_simple_entries > pg_tbl->config.total_entries) { + mutex_unlock(&pg_tbl->mutex); + return -EINVAL; + } + + gasket_page_table_garbage_collect_nolock(pg_tbl); + + start = min(pg_tbl->num_simple_entries, num_simple_entries); + + for (i = start; i < pg_tbl->config.total_entries; i++) { + if (pg_tbl->entries[i].status != PTE_FREE) { + gasket_pg_tbl_error(pg_tbl, "entry %d is not free", i); + mutex_unlock(&pg_tbl->mutex); + return -EBUSY; + } + } + + pg_tbl->num_simple_entries = num_simple_entries; + pg_tbl->num_extended_entries = + pg_tbl->config.total_entries - num_simple_entries; + writeq(num_simple_entries, pg_tbl->extended_offset_reg); + + mutex_unlock(&pg_tbl->mutex); + return 0; +} +EXPORT_SYMBOL(gasket_page_table_partition); + +/* + * See gasket_page_table.h for general description. + * + * gasket_page_table_map calls either gasket_map_simple_pages() or + * gasket_map_extended_pages() to actually perform the mapping. + * + * The page table mutex is held for the entire operation. + */ +int gasket_page_table_map( + struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, + uint num_pages) +{ + int ret; + + if (!num_pages) + return 0; + + mutex_lock(&pg_tbl->mutex); + + if (gasket_addr_is_simple(pg_tbl, dev_addr)) { + ret = gasket_map_simple_pages( + pg_tbl, host_addr, dev_addr, num_pages); + } else { + ret = gasket_map_extended_pages( + pg_tbl, host_addr, dev_addr, num_pages); + } + + mutex_unlock(&pg_tbl->mutex); + + gasket_nodev_debug( + "gasket_page_table_map done: ha %llx daddr %llx num %d, " + "ret %d\n", + (unsigned long long)host_addr, + (unsigned long long)dev_addr, num_pages, ret); + return ret; +} +EXPORT_SYMBOL(gasket_page_table_map); + +/* + * See gasket_page_table.h for general description. + * + * gasket_page_table_unmap takes the page table lock and calls either + * gasket_unmap_simple_pages() or gasket_unmap_extended_pages() to + * actually unmap the pages from device space. + * + * The page table mutex is held for the entire operation. + */ +void gasket_page_table_unmap( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + if (!num_pages) + return; + + mutex_lock(&pg_tbl->mutex); + gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages); + mutex_unlock(&pg_tbl->mutex); +} +EXPORT_SYMBOL(gasket_page_table_unmap); + +static void gasket_page_table_unmap_all_nolock(struct gasket_page_table *pg_tbl) +{ + gasket_unmap_simple_pages( + pg_tbl, gasket_components_to_dev_address(pg_tbl, 1, 0, 0), + pg_tbl->num_simple_entries); + gasket_unmap_extended_pages( + pg_tbl, gasket_components_to_dev_address(pg_tbl, 0, 0, 0), + pg_tbl->num_extended_entries * GASKET_PAGES_PER_SUBTABLE); +} + +/* See gasket_page_table.h for description. */ +void gasket_page_table_unmap_all(struct gasket_page_table *pg_tbl) +{ + mutex_lock(&pg_tbl->mutex); + gasket_page_table_unmap_all_nolock(pg_tbl); + mutex_unlock(&pg_tbl->mutex); +} +EXPORT_SYMBOL(gasket_page_table_unmap_all); + +/* See gasket_page_table.h for description. */ +void gasket_page_table_reset(struct gasket_page_table *pg_tbl) +{ + mutex_lock(&pg_tbl->mutex); + gasket_page_table_unmap_all_nolock(pg_tbl); + writeq(pg_tbl->config.total_entries, pg_tbl->extended_offset_reg); + mutex_unlock(&pg_tbl->mutex); +} + +/* See gasket_page_table.h for description. */ +void gasket_page_table_garbage_collect(struct gasket_page_table *pg_tbl) +{ + mutex_lock(&pg_tbl->mutex); + gasket_page_table_garbage_collect_nolock(pg_tbl); + mutex_unlock(&pg_tbl->mutex); +} + +/* See gasket_page_table.h for description. */ +int gasket_page_table_lookup_page( + struct gasket_page_table *pg_tbl, ulong dev_addr, struct page **ppage, + ulong *poffset) +{ + uint page_num; + struct gasket_page_table_entry *pte; + + mutex_lock(&pg_tbl->mutex); + if (gasket_addr_is_simple(pg_tbl, dev_addr)) { + page_num = gasket_simple_page_idx(pg_tbl, dev_addr); + if (page_num >= pg_tbl->num_simple_entries) + goto fail; + + pte = pg_tbl->entries + page_num; + if (pte->status != PTE_INUSE) + goto fail; + } else { + /* Find the level 0 entry, */ + page_num = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + if (page_num >= pg_tbl->num_extended_entries) + goto fail; + + pte = pg_tbl->entries + pg_tbl->num_simple_entries + page_num; + if (pte->status != PTE_INUSE) + goto fail; + + /* and its contained level 1 entry. */ + page_num = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); + pte = pte->sublevel + page_num; + if (pte->status != PTE_INUSE) + goto fail; + } + + *ppage = pte->page; + *poffset = pte->offset; + mutex_unlock(&pg_tbl->mutex); + return 0; + +fail: + *ppage = NULL; + *poffset = 0; + mutex_unlock(&pg_tbl->mutex); + return -1; +} + +/* See gasket_page_table.h for description. */ +int gasket_page_table_are_addrs_bad( + struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, + ulong bytes) +{ + if (host_addr & (PAGE_SIZE - 1)) { + gasket_pg_tbl_error( + pg_tbl, + "host mapping address 0x%lx must be page aligned", + host_addr); + return 1; + } + + return gasket_page_table_is_dev_addr_bad(pg_tbl, dev_addr, bytes); +} +EXPORT_SYMBOL(gasket_page_table_are_addrs_bad); + +/* See gasket_page_table.h for description. */ +int gasket_page_table_is_dev_addr_bad( + struct gasket_page_table *pg_tbl, ulong dev_addr, ulong bytes) +{ + uint num_pages = bytes / PAGE_SIZE; + + if (bytes & (PAGE_SIZE - 1)) { + gasket_pg_tbl_error( + pg_tbl, + "mapping size 0x%lX must be page aligned", bytes); + return 1; + } + + if (num_pages == 0) { + gasket_pg_tbl_error( + pg_tbl, + "requested mapping is less than one page: %lu / %lu", + bytes, PAGE_SIZE); + return 1; + } + + if (gasket_addr_is_simple(pg_tbl, dev_addr)) + return gasket_is_simple_dev_addr_bad( + pg_tbl, dev_addr, num_pages); + else + return gasket_is_extended_dev_addr_bad( + pg_tbl, dev_addr, num_pages); +} +EXPORT_SYMBOL(gasket_page_table_is_dev_addr_bad); + +/* See gasket_page_table.h for description. */ +uint gasket_page_table_max_size(struct gasket_page_table *page_table) +{ + if (!page_table) { + gasket_nodev_error("Passed a null page table."); + return 0; + } + return page_table->config.total_entries; +} +EXPORT_SYMBOL(gasket_page_table_max_size); + +/* See gasket_page_table.h for description. */ +uint gasket_page_table_num_entries(struct gasket_page_table *pg_tbl) +{ + if (!pg_tbl) { + gasket_nodev_error("Passed a null page table."); + return 0; + } + + return pg_tbl->num_simple_entries + pg_tbl->num_extended_entries; +} +EXPORT_SYMBOL(gasket_page_table_num_entries); + +/* See gasket_page_table.h for description. */ +uint gasket_page_table_num_simple_entries(struct gasket_page_table *pg_tbl) +{ + if (!pg_tbl) { + gasket_nodev_error("Passed a null page table."); + return 0; + } + + return pg_tbl->num_simple_entries; +} +EXPORT_SYMBOL(gasket_page_table_num_simple_entries); + +/* See gasket_page_table.h for description. */ +uint gasket_page_table_num_extended_entries(struct gasket_page_table *pg_tbl) +{ + if (!pg_tbl) { + gasket_nodev_error("Passed a null page table."); + return 0; + } + + return pg_tbl->num_extended_entries; +} +EXPORT_SYMBOL(gasket_page_table_num_extended_entries); + +uint gasket_page_table_num_active_pages(struct gasket_page_table *pg_tbl) +{ + if (!pg_tbl) { + gasket_nodev_error("Passed a null page table."); + return 0; + } + + return pg_tbl->num_active_pages; +} +EXPORT_SYMBOL(gasket_page_table_num_active_pages); + +/* See gasket_page_table.h */ +int gasket_page_table_system_status(struct gasket_page_table *page_table) +{ + if (!page_table) { + gasket_nodev_error("Passed a null page table."); + return GASKET_STATUS_LAMED; + } + + if (gasket_page_table_num_entries(page_table) == 0) { + gasket_nodev_error("Page table size is 0."); + return GASKET_STATUS_LAMED; + } + + return GASKET_STATUS_ALIVE; +} + +/* Internal functions */ + +/* Mapping functions */ +/* + * Allocate and map pages to simple addresses. + * @pg_tbl: Gasket page table pointer. + * @host_addr: Starting host virtual memory address of the pages. + * @dev_addr: Starting device address of the pages. + * @cnt: Count of the number of device pages to map. + * + * Description: gasket_map_simple_pages calls gasket_simple_alloc_pages() to + * allocate the page table slots, then calls + * gasket_perform_mapping() to actually do the work of mapping the + * pages into the the simple page table (device translation table + * registers). + * + * The sd_mutex must be held when gasket_map_simple_pages() is + * called. + * + * Returns 0 if successful or a non-zero error number otherwise. + * If there is an error, no pages are mapped. + */ +static int gasket_map_simple_pages( + struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, + uint num_pages) +{ + int ret; + uint slot_idx = gasket_simple_page_idx(pg_tbl, dev_addr); + + ret = gasket_alloc_simple_entries(pg_tbl, dev_addr, num_pages); + if (ret) { + gasket_pg_tbl_error( + pg_tbl, + "page table slots %u (@ 0x%lx) to %u are not available", + slot_idx, dev_addr, slot_idx + num_pages - 1); + return ret; + } + + ret = gasket_perform_mapping( + pg_tbl, pg_tbl->entries + slot_idx, + pg_tbl->base_slot + slot_idx, host_addr, num_pages, 1); + + if (ret) { + gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages); + gasket_pg_tbl_error(pg_tbl, "gasket_perform_mapping %d.", ret); + } + return ret; +} + +/* + * gasket_map_extended_pages - Get and map buffers to extended addresses. + * @pg_tbl: Gasket page table pointer. + * @host_addr: Starting host virtual memory address of the pages. + * @dev_addr: Starting device address of the pages. + * @num_pages: The number of device pages to map. + * + * Description: gasket_map_extended_buffers calls + * gasket_alloc_extended_entries() to allocate the page table + * slots, then loops over the level 0 page table entries, and for + * each calls gasket_perform_mapping() to map the buffers into the + * level 1 page table for that level 0 entry. + * + * The page table mutex must be held when + * gasket_map_extended_pages() is called. + * + * Returns 0 if successful or a non-zero error number otherwise. + * If there is an error, no pages are mapped. + */ +static int gasket_map_extended_pages( + struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, + uint num_pages) +{ + int ret; + ulong dev_addr_end; + uint slot_idx, remain, len; + struct gasket_page_table_entry *pte; + u64 __iomem *slot_base; + + ret = gasket_alloc_extended_entries(pg_tbl, dev_addr, num_pages); + if (ret) { + dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1; + gasket_pg_tbl_error( + pg_tbl, + "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are " + "not available", + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr), + dev_addr, + gasket_extended_lvl1_page_idx(pg_tbl, dev_addr), + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr_end), + gasket_extended_lvl1_page_idx(pg_tbl, dev_addr_end)); + return ret; + } + + remain = num_pages; + slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); + pte = pg_tbl->entries + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + while (remain > 0) { + len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx); + + slot_base = + (u64 __iomem *)(page_address(pte->page) + pte->offset); + ret = gasket_perform_mapping( + pg_tbl, pte->sublevel + slot_idx, slot_base + slot_idx, + host_addr, len, 0); + if (ret) { + gasket_page_table_unmap_nolock( + pg_tbl, dev_addr, num_pages); + return ret; + } + + remain -= len; + slot_idx = 0; + pte++; + host_addr += len * PAGE_SIZE; + } + + return 0; +} + +/* + * TODO: dma_map_page() is not plugged properly when running under qemu. i.e. + * dma_ops are not set properly, which causes the kernel to assert. + * + * This temporary hack allows the driver to work on qemu, but need to be fixed: + * - either manually set the dma_ops for the architecture (which incidentally + * can't be done in an out-of-tree module) - or get qemu to fill the device tree + * properly so as linux plug the proper dma_ops or so as the driver can detect + * that it is runnig on qemu + */ +static inline dma_addr_t _no_op_dma_map_page( + struct device *dev, struct page *page, size_t offset, size_t size, + enum dma_data_direction dir) +{ + /* + * struct dma_map_ops *ops = get_dma_ops(dev); + * dma_addr_t addr; + * + * kmemcheck_mark_initialized(page_address(page) + offset, size); + * BUG_ON(!valid_dma_direction(dir)); + * addr = ops->map_page(dev, page, offset, size, dir, NULL); + * debug_dma_map_page(dev, page, offset, size, dir, addr, false); + */ + + return page_to_phys(page); +} + +/* + * Get and map last level page table buffers. + * @pg_tbl: Gasket page table pointer. + * @ptes: Array of page table entries to describe this mapping, one per + * page to map. + * @slots: Location(s) to write device-mapped page address. If this is a simple + * mapping, these will be address translation registers. If this is + * an extended mapping, these will be within a second-level page table + * allocated by the host and so must have their __iomem attribute + * casted away. + * @host_addr: Starting [host] virtual memory address of the buffers. + * @num_pages: The number of device pages to map. + * @is_simple_mapping: 1 if this is a simple mapping, 0 otherwise. + * + * Description: gasket_perform_mapping calls get_user_pages() to get pages + * of user memory and pin them. It then calls dma_map_page() to + * map them for DMA. Finally, the mapped DMA addresses are written + * into the page table. + * + * This function expects that the page table entries are + * already allocated. The level argument determines how the + * final page table entries are written: either into PCIe memory + * mapped space for a level 0 page table or into kernel memory + * for a level 1 page table. + * + * The page pointers are saved for later releasing the pages. + * + * Returns 0 if successful or a non-zero error number otherwise. + */ +static int gasket_perform_mapping( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, + u64 __iomem *slots, ulong host_addr, uint num_pages, + int is_simple_mapping) +{ + int ret; + ulong offset; + struct page *page; + dma_addr_t dma_addr; + ulong page_addr; + int i; + + for (i = 0; i < num_pages; i++) { + page_addr = host_addr + i * PAGE_SIZE; + offset = page_addr & (PAGE_SIZE - 1); + gasket_nodev_debug("gasket_perform_mapping i %d\n", i); + if (is_coherent(pg_tbl, host_addr)) { + u64 off = + (u64)host_addr - + (u64)pg_tbl->coherent_pages[0].user_virt; + ptes[i].page = 0; + ptes[i].offset = offset; + ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + + off + i * PAGE_SIZE; + } else { + ret = get_user_pages_fast( + page_addr - offset, 1, 1, &page); + + if (ret <= 0) { + gasket_pg_tbl_error( + pg_tbl, + "get user pages failed for addr=0x%lx, " + "offset=0x%lx [ret=%d]", + page_addr, offset, ret); + return ret ? ret : -ENOMEM; + } + ++pg_tbl->num_active_pages; + + ptes[i].page = page; + ptes[i].offset = offset; + + /* Map the page into DMA space. */ + if (pg_tbl->dma_ops) { + /* hook in to kernel map functions */ + ptes[i].dma_addr = dma_map_page(pg_tbl->device, + page, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); + } else { + ptes[i].dma_addr = _no_op_dma_map_page( + pg_tbl->device, page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); + } + + gasket_nodev_debug( + " gasket_perform_mapping dev %p " + "i %d pte %p pfn %p -> mapped %llx\n", + pg_tbl->device, i, &ptes[i], + (void *)page_to_pfn(page), + (unsigned long long)ptes[i].dma_addr); + + if (ptes[i].dma_addr == -1) { + gasket_nodev_error( + "gasket_perform_mapping i %d" + " -> fail to map page %llx " + "[pfn %p ohys %p]\n", + i, + (unsigned long long)ptes[i].dma_addr, + (void *)page_to_pfn(page), + (void *)page_to_phys(page)); + return -1; + } + /* Wait until the page is mapped. */ + mb(); + } + + /* Make the DMA-space address available to the device. */ + dma_addr = (ptes[i].dma_addr + offset) | GASKET_VALID_SLOT_FLAG; + + if (is_simple_mapping) { + writeq(dma_addr, &slots[i]); + } else { + ((u64 __force *)slots)[i] = dma_addr; + /* Extended page table vectors are in DRAM, + * and so need to be synced each time they are updated. + */ + dma_map_single(pg_tbl->device, + (void *)&((u64 __force *)slots)[i], + sizeof(u64), DMA_TO_DEVICE); + } + ptes[i].status = PTE_INUSE; + } + return 0; +} + +/** + * Allocate page table entries in a simple table. + * @pg_tbl: Gasket page table pointer. + * @dev_addr: Starting device address for the (eventual) mappings. + * @num_pages: Count of pages to be mapped. + * + * Description: gasket_alloc_simple_entries checks to see if a range of page + * table slots are available. As long as the sd_mutex is + * held, the slots will be available. + * + * The page table mutex must be held when + * gasket_alloc_simple entries() is called. + * + * Returns 0 if successful, or non-zero if the requested device + * addresses are not available. + */ +static int gasket_alloc_simple_entries( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + if (!gasket_is_pte_range_free( + pg_tbl->entries + gasket_simple_page_idx(pg_tbl, dev_addr), + num_pages)) + return -EBUSY; + + return 0; +} + +/** + * Allocate slots in an extended page table. + * @pg_tbl: Gasket page table pointer. + * @dev_addr: Starting device address for the (eventual) mappings. + * @num_pages: Count of pages to be mapped. + * + * Description: gasket_alloc_extended_entries checks to see if a range of page + * table slots are available. If necessary, memory is allocated for + * second level page tables. + * + * Note that memory for second level page tables is allocated + * as needed, but that memory is only freed on the final close + * of the device file, when the page tables are repartitioned, + * or the the device is removed. If there is an error or if + * the full range of slots is not available, any memory + * allocated for second level page tables remains allocated + * until final close, repartition, or device removal. + * + * The page table mutex must be held when + * gasket_alloc_extended_entries() is called. + * + * Returns 0 if successful, or non-zero if the slots are + * not available. + */ +static int gasket_alloc_extended_entries( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries) +{ + int ret = 0; + uint remain, subtable_slot_idx, len; + struct gasket_page_table_entry *pte; + u64 __iomem *slot; + + remain = num_entries; + subtable_slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); + pte = pg_tbl->entries + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + slot = pg_tbl->base_slot + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + while (remain > 0) { + len = min(remain, + GASKET_PAGES_PER_SUBTABLE - subtable_slot_idx); + + if (pte->status == PTE_FREE) { + ret = gasket_alloc_extended_subtable(pg_tbl, pte, slot); + if (ret) { + gasket_pg_tbl_error( + pg_tbl, + "no memory for extended addr subtable"); + return ret; + } + } else { + if (!gasket_is_pte_range_free( + pte->sublevel + subtable_slot_idx, len)) + return -EBUSY; + } + + remain -= len; + subtable_slot_idx = 0; + pte++; + slot++; + } + + return 0; +} + +/** + * Allocate a second level page table. + * @pg_tbl: Gasket page table pointer. + * @pte: Extended page table entry under/for which to allocate a second level. + * @slot: [Device] slot corresponding to pte. + * + * Description: Allocate the memory for a second level page table (subtable) at + * the given level 0 entry. Then call dma_map_page() to map the + * second level page table for DMA. Finally, write the + * mapped DMA address into the device page table. + * + * The page table mutex must be held when + * gasket_alloc_extended_subtable() is called. + * + * Returns 0 if successful, or a non-zero error otherwise. + */ +static int gasket_alloc_extended_subtable( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, + u64 __iomem *slot) +{ + ulong page_addr, subtable_bytes; + dma_addr_t dma_addr; + + /* XXX FIX ME XXX this is inefficient for non-4K page sizes */ + + /* GFP_DMA flag must be passed to architectures for which + * part of the memory range is not considered DMA'able. + * This seems to be the case for Juno board with 4.5.0 Linaro kernel + */ + page_addr = get_zeroed_page(GFP_KERNEL | GFP_DMA); + if (!page_addr) + return -ENOMEM; + pte->page = virt_to_page((void *)page_addr); + pte->offset = 0; + + subtable_bytes = sizeof(struct gasket_page_table_entry) * + GASKET_PAGES_PER_SUBTABLE; + pte->sublevel = vmalloc(subtable_bytes); + if (!pte->sublevel) { + free_page(page_addr); + memset(pte, 0, sizeof(struct gasket_page_table_entry)); + return -ENOMEM; + } + memset(pte->sublevel, 0, subtable_bytes); + + /* Map the page into DMA space. */ + if (pg_tbl->dma_ops) { + pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, + PAGE_SIZE, DMA_BIDIRECTIONAL); + } else { + pte->dma_addr = _no_op_dma_map_page(pg_tbl->device, pte->page, + 0, PAGE_SIZE, DMA_BIDIRECTIONAL); + } + /* Wait until the page is mapped. */ + mb(); + + /* make the addresses available to the device */ + dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG; + writeq(dma_addr, slot); + + pte->status = PTE_INUSE; + + return 0; +} + +/* Unmapping functions */ +/* + * Non-locking entry to unmapping routines. + * @pg_tbl: Gasket page table structure. + * @dev_addr: Starting device address of the pages to unmap. + * @num_pages: The number of device pages to unmap. + * + * Description: Version of gasket_unmap_pages that assumes the page table lock + * is held. + */ +static void gasket_page_table_unmap_nolock( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + if (!num_pages) + return; + + if (gasket_addr_is_simple(pg_tbl, dev_addr)) + gasket_unmap_simple_pages(pg_tbl, dev_addr, num_pages); + else + gasket_unmap_extended_pages(pg_tbl, dev_addr, num_pages); +} + +/* + * Unmap and release pages mapped to simple addresses. + * @pg_tbl: Gasket page table pointer. + * @dev_addr: Starting device address of the buffers. + * @num_pages: The number of device pages to unmap. + * + * Description: gasket_simple_unmap_pages calls gasket_perform_unmapping() to + * unmap and release the buffers in the level 0 page table. + * + * The sd_mutex must be held when gasket_unmap_simple_pages() is called. + */ +static void gasket_unmap_simple_pages( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + uint slot = gasket_simple_page_idx(pg_tbl, dev_addr); + + gasket_perform_unmapping(pg_tbl, pg_tbl->entries + slot, + pg_tbl->base_slot + slot, num_pages, 1); +} + +/** + * Unmap and release buffers to extended addresses. + * @pg_tbl: Gasket page table pointer. + * @dev_addr: Starting device address of the pages to unmap. + * @addr: Starting device address of the buffers. + * @num_pages: The number of device pages to unmap. + * + * Description: gasket_extended_unmap_pages loops over the level 0 page table + * entries, and for each calls gasket_perform_unmapping() to unmap + * the buffers from the level 1 page [sub]table for that level 0 + * entry. + * + * The page table mutex must be held when + * gasket_unmap_extended_pages() is called. + */ +static void gasket_unmap_extended_pages( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + uint slot_idx, remain, len; + struct gasket_page_table_entry *pte; + u64 __iomem *slot_base; + + remain = num_pages; + slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); + pte = pg_tbl->entries + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + while (remain > 0) { + /* TODO: Add check to ensure pte remains valid? */ + len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx); + + if (pte->status == PTE_INUSE) { + slot_base = (u64 __iomem *)(page_address(pte->page) + + pte->offset); + gasket_perform_unmapping( + pg_tbl, pte->sublevel + slot_idx, + slot_base + slot_idx, len, 0); + } + + remain -= len; + slot_idx = 0; + pte++; + } +} + +/* + * Unmap and release mapped pages. + * @pg_tbl: Gasket page table pointer. + * @ptes: Array of page table entries to describe the mapped range, one per + * page to unmap. + * @slots: Device slots corresponding to the mappings described by "ptes". + * As with ptes, one element per page to unmap. + * If these are simple mappings, these will be address translation + * registers. If these are extended mappings, these will be witin a + * second-level page table allocated on the host, and so must have + * their __iomem attribute casted away. + * @num_pages: Number of pages to unmap. + * @is_simple_mapping: 1 if this is a simple mapping, 0 otherwise. + * + * Description: gasket_perform_unmapping() loops through the metadata entries + * in a last level page table (simple table or extended subtable), + * and for each page: + * - Unmaps the page from DMA space (dma_unmap_page), + * - Returns the page to the OS (gasket_release_page), + * The entry in the page table is written to 0. The metadata + * type is set to PTE_FREE and the metadata is all reset + * to 0. + * + * The page table mutex must be held when this function is called. + */ +static void gasket_perform_unmapping( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, + u64 __iomem *slots, uint num_pages, int is_simple_mapping) +{ + int i; + /* + * For each page table entry and corresponding entry in the device's + * address translation table: + */ + for (i = 0; i < num_pages; i++) { + /* release the address from the device, */ + if (is_simple_mapping || ptes[i].status == PTE_INUSE) + writeq(0, &slots[i]); + else + ((u64 __force *)slots)[i] = 0; + /* Force sync around the address release. */ + mb(); + + /* release the address from the driver, */ + if (ptes[i].status == PTE_INUSE) { + if (ptes[i].dma_addr) { + dma_unmap_page(pg_tbl->device, ptes[i].dma_addr, + PAGE_SIZE, DMA_FROM_DEVICE); + } + if (gasket_release_page(ptes[i].page)) + --pg_tbl->num_active_pages; + } + ptes[i].status = PTE_FREE; + + /* and clear the PTE. */ + memset(&ptes[i], 0, sizeof(struct gasket_page_table_entry)); + } +} + +/* + * Free a second level page [sub]table. + * @pg_tbl: Gasket page table pointer. + * @pte: Page table entry _pointing_to_ the subtable to free. + * @slot: Device slot holding a pointer to the sublevel's contents. + * + * Description: Safely deallocates a second-level [sub]table by: + * - Marking the containing first-level PTE as free + * - Setting the corresponding [extended] device slot as NULL + * - Unmapping the PTE from DMA space. + * - Freeing the subtable's memory. + * - Deallocating the page and clearing out the PTE. + * + * The page table mutex must be held before this call. + */ +static void gasket_free_extended_subtable( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, + u64 __iomem *slot) +{ + /* Release the page table from the driver */ + pte->status = PTE_FREE; + + /* Release the page table from the device */ + writeq(0, slot); + /* Force sync around the address release. */ + mb(); + + if (pte->dma_addr) + dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE, + DMA_BIDIRECTIONAL); + + vfree(pte->sublevel); + + if (pte->page) + free_page((ulong)page_address(pte->page)); + + memset(pte, 0, sizeof(struct gasket_page_table_entry)); +} + +/* + * Safely return a page to the OS. + * @page: The page to return to the OS. + * Returns 1 if the page was released, 0 if it was + * ignored. + */ +static int gasket_release_page(struct page *page) +{ + if (!page) + return 0; + + if (!PageReserved(page)) + SetPageDirty(page); + put_page(page); + + return 1; +} + +/* Evaluates to nonzero if the specified virtual address is simple. */ +static inline int gasket_addr_is_simple( + struct gasket_page_table *pg_tbl, ulong addr) +{ + return !((addr) & (pg_tbl)->extended_flag); +} + +/* + * Validity checking for simple addresses. + * @pg_tbl: Gasket page table pointer. + * @dev_addr: The device address to which the pages will be mapped. + * @num_pages: The number of pages in the range to consider. + * + * Description: This call verifies that address translation commutes (from + * address to/from page + offset) and that the requested page range starts and + * ends within the set of currently-partitioned simple pages. + */ +static int gasket_is_simple_dev_addr_bad( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + ulong page_offset = dev_addr & (PAGE_SIZE - 1); + ulong page_index = + (dev_addr / PAGE_SIZE) & (pg_tbl->config.total_entries - 1); + + if (gasket_components_to_dev_address( + pg_tbl, 1, page_index, page_offset) != dev_addr) { + gasket_pg_tbl_error( + pg_tbl, "address is invalid, 0x%lX", dev_addr); + return 1; + } + + if (page_index >= pg_tbl->num_simple_entries) { + gasket_pg_tbl_error( + pg_tbl, + "starting slot at %lu is too large, max is < %u", + page_index, pg_tbl->num_simple_entries); + return 1; + } + + if (page_index + num_pages > pg_tbl->num_simple_entries) { + gasket_pg_tbl_error( + pg_tbl, + "ending slot at %lu is too large, max is <= %u", + page_index + num_pages, pg_tbl->num_simple_entries); + return 1; + } + + return 0; +} + +/* + * Verifies that address translation commutes (from address to/from page + + * offset) and that the requested page range starts and ends within the set of + * currently-partitioned simple pages. + * + * @pg_tbl: Gasket page table pointer. + * @dev_addr: The device address to which the pages will be mapped. + * @num_pages: The number of second-level/sub pages in the range to consider. + */ +static int gasket_is_extended_dev_addr_bad( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + /* Starting byte index of dev_addr into the first mapped page */ + ulong page_offset = dev_addr & (PAGE_SIZE - 1); + ulong page_global_idx, page_lvl0_idx; + ulong num_lvl0_pages; + ulong addr; + + /* check if the device address is out of bound */ + addr = dev_addr & ~((pg_tbl)->extended_flag); + if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) { + gasket_pg_tbl_error(pg_tbl, "device address out of bound, 0x%p", + (void *)dev_addr); + return 1; + } + + /* Find the starting sub-page index in the space of all sub-pages. */ + page_global_idx = (dev_addr / PAGE_SIZE) & + (pg_tbl->config.total_entries * GASKET_PAGES_PER_SUBTABLE - 1); + + /* Find the starting level 0 index. */ + page_lvl0_idx = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + /* Get the count of affected level 0 pages. */ + num_lvl0_pages = (num_pages + GASKET_PAGES_PER_SUBTABLE - 1) / + GASKET_PAGES_PER_SUBTABLE; + + if (gasket_components_to_dev_address( + pg_tbl, 0, page_global_idx, page_offset) != dev_addr) { + gasket_pg_tbl_error( + pg_tbl, "address is invalid, 0x%p", (void *)dev_addr); + return 1; + } + + if (page_lvl0_idx >= pg_tbl->num_extended_entries) { + gasket_pg_tbl_error( + pg_tbl, + "starting level 0 slot at %lu is too large, max is < " + "%u", page_lvl0_idx, pg_tbl->num_extended_entries); + return 1; + } + + if (page_lvl0_idx + num_lvl0_pages > pg_tbl->num_extended_entries) { + gasket_pg_tbl_error( + pg_tbl, + "ending level 0 slot at %lu is too large, max is <= %u", + page_lvl0_idx + num_lvl0_pages, + pg_tbl->num_extended_entries); + return 1; + } + + return 0; +} + +/* + * Checks if a range of PTEs is free. + * @ptes: The set of PTEs to check. + * @num_entries: The number of PTEs to check. + * + * Description: Iterates over the input PTEs to determine if all have been + * marked as FREE or if any are INUSE. In the former case, 1/true is returned. + * Otherwise, 0/false is returned. + * + * The page table mutex must be held before this call. + */ +static int gasket_is_pte_range_free( + struct gasket_page_table_entry *ptes, uint num_entries) +{ + int i; + + for (i = 0; i < num_entries; i++) { + if (ptes[i].status != PTE_FREE) + return 0; + } + + return 1; +} + +/* + * Actually perform collection. + * @pg_tbl: Gasket page table structure. + * + * Description: Version of gasket_page_table_garbage_collect that assumes the + * page table lock is held. + */ +static void gasket_page_table_garbage_collect_nolock( + struct gasket_page_table *pg_tbl) +{ + struct gasket_page_table_entry *pte; + u64 __iomem *slot; + + /* XXX FIX ME XXX -- more efficient to keep a usage count */ + /* rather than scanning the second level page tables */ + + for (pte = pg_tbl->entries + pg_tbl->num_simple_entries, + slot = pg_tbl->base_slot + pg_tbl->num_simple_entries; + pte < pg_tbl->entries + pg_tbl->config.total_entries; + pte++, slot++) { + if (pte->status == PTE_INUSE) { + if (gasket_is_pte_range_free( + pte->sublevel, GASKET_PAGES_PER_SUBTABLE)) + gasket_free_extended_subtable( + pg_tbl, pte, slot); + } + } +} + +/* + * Converts components to a device address. + * @pg_tbl: Gasket page table structure. + * @is_simple: nonzero if this should be a simple entry, zero otherwise. + * @page_index: The page index into the respective table. + * @offset: The offset within the requested page. + * + * Simple utility function to convert (simple, page, offset) into a device + * address. + * Examples: + * Simple page 0, offset 32: + * Input (0, 0, 32), Output 0x20 + * Simple page 1000, offset 511: + * Input (0, 1000, 512), Output 0x3E81FF + * Extended page 0, offset 32: + * Input (0, 0, 32), Output 0x8000000020 + * Extended page 1000, offset 511: + * Input (1, 1000, 512), Output 0x8003E81FF + */ +static ulong gasket_components_to_dev_address( + struct gasket_page_table *pg_tbl, int is_simple, uint page_index, + uint offset) +{ + ulong lvl0_index, lvl1_index; + + if (is_simple) { + /* Return simple addresses directly. */ + lvl0_index = page_index & (pg_tbl->config.total_entries - 1); + return (lvl0_index << GASKET_SIMPLE_PAGE_SHIFT) | offset; + } + + /* + * This could be compressed into fewer statements, but + * A) the compiler should optimize it + * B) this is not slow + * C) this is an uncommon operation + * D) this is actually readable this way. + */ + lvl0_index = page_index / GASKET_PAGES_PER_SUBTABLE; + lvl1_index = page_index & (GASKET_PAGES_PER_SUBTABLE - 1); + return (pg_tbl)->extended_flag | + (lvl0_index << GASKET_EXTENDED_LVL0_SHIFT) | + (lvl1_index << GASKET_EXTENDED_LVL1_SHIFT) | offset; +} + +/* + * Gets the index of the address' page in the simple table. + * @pg_tbl: Gasket page table structure. + * @dev_addr: The address whose page index to retrieve. + * + * Description: Treats the input address as a simple address and determines the + * index of its underlying page in the simple page table (i.e., device address + * translation registers. + * + * Does not perform validity checking. + */ +static int gasket_simple_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr) +{ + return (dev_addr >> GASKET_SIMPLE_PAGE_SHIFT) & + (pg_tbl->config.total_entries - 1); +} + +/* + * Gets the level 0 page index for the given address. + * @pg_tbl: Gasket page table structure. + * @dev_addr: The address whose page index to retrieve. + * + * Description: Treats the input address as an extended address and determines + * the index of its underlying page in the first-level extended page table + * (i.e., device extended address translation registers). + * + * Does not perform validity checking. + */ +static ulong gasket_extended_lvl0_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr) +{ + return (dev_addr >> GASKET_EXTENDED_LVL0_SHIFT) & + ((1 << GASKET_EXTENDED_LVL0_WIDTH) - 1); +} + +/* + * Gets the level 1 page index for the given address. + * @pg_tbl: Gasket page table structure. + * @dev_addr: The address whose page index to retrieve. + * + * Description: Treats the input address as an extended address and determines + * the index of its underlying page in the second-level extended page table + * (i.e., host memory pointed to by a first-level page table entry). + * + * Does not perform validity checking. + */ +static ulong gasket_extended_lvl1_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr) +{ + return (dev_addr >> GASKET_EXTENDED_LVL1_SHIFT) & + (GASKET_PAGES_PER_SUBTABLE - 1); +} + +/* + * Determines whether a host buffer was mapped as coherent memory. + * @pg_tbl: gasket_page_table structure tracking the host buffer mapping + * @host_addr: user virtual address within a host buffer + * + * Description: A Gasket page_table currently support one contiguous + * dma range, mapped to one contiguous virtual memory range. Check if the + * host_addr is within start of page 0, and end of last page, for that range. + */ +static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr) +{ + u64 min, max; + + /* whether the host address is within user virt range */ + if (!pg_tbl->coherent_pages) + return 0; + + min = (u64)pg_tbl->coherent_pages[0].user_virt; + max = min + PAGE_SIZE * pg_tbl->num_coherent_pages; + + return min <= host_addr && host_addr < max; +} + +/* + * Records the host_addr to coherent dma memory mapping. + * @gasket_dev: Gasket Device. + * @size: Size of the virtual address range to map. + * @dma_address: Dma address within the coherent memory range. + * @vma: Virtual address we wish to map to coherent memory. + * + * Description: For each page in the virtual address range, record the + * coherent page mgasket_pretapping. + */ +int gasket_set_user_virt( + struct gasket_dev *gasket_dev, u64 size, dma_addr_t dma_address, + ulong vma) +{ + int j; + struct gasket_page_table *pg_tbl; + + unsigned int num_pages = size / PAGE_SIZE; + + /* + * TODO: for future chipset, better handling of the case where multiple + * page tables are supported on a given device + */ + pg_tbl = gasket_dev->page_table[0]; + if (!pg_tbl) { + gasket_nodev_error( + "gasket_set_user_virt: invalid page table index"); + return 0; + } + for (j = 0; j < num_pages; j++) { + pg_tbl->coherent_pages[j].user_virt = + (u64)vma + j * PAGE_SIZE; + } + return 0; +} + +/* + * Allocate a block of coherent memory. + * @gasket_dev: Gasket Device. + * @size: Size of the memory block. + * @dma_address: Dma address allocated by the kernel. + * @index: Index of the gasket_page_table within this Gasket device + * + * Description: Allocate a contiguous coherent memory block, DMA'ble + * by this device. + */ +int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, + dma_addr_t *dma_address, u64 index) +{ + dma_addr_t handle; + void *mem; + int j; + unsigned int num_pages = (size + PAGE_SIZE - 1) / (PAGE_SIZE); + const struct gasket_driver_desc *driver_desc = + gasket_get_driver_desc(gasket_dev); + + if (!gasket_dev->page_table[index]) + return -EFAULT; + + if (num_pages == 0) + return -EINVAL; + + mem = dma_alloc_coherent(gasket_get_device(gasket_dev), + num_pages * PAGE_SIZE, &handle, 0); + if (!mem) + goto nomem; + + gasket_dev->page_table[index]->num_coherent_pages = num_pages; + + /* allocate the physical memory block */ + gasket_dev->page_table[index]->coherent_pages = kzalloc( + num_pages * sizeof(struct gasket_coherent_page_entry), + GFP_KERNEL); + if (!gasket_dev->page_table[index]->coherent_pages) + goto nomem; + *dma_address = 0; + + gasket_dev->coherent_buffer.length_bytes = + PAGE_SIZE * (num_pages); + gasket_dev->coherent_buffer.phys_base = handle; + gasket_dev->coherent_buffer.virt_base = mem; + + *dma_address = driver_desc->coherent_buffer_description.base; + for (j = 0; j < num_pages; j++) { + gasket_dev->page_table[index]->coherent_pages[j].paddr = + handle + j * PAGE_SIZE; + gasket_dev->page_table[index]->coherent_pages[j].kernel_virt = + (u64)mem + j * PAGE_SIZE; + } + + if (*dma_address == 0) + goto nomem; + return 0; + +nomem: + if (mem) { + dma_free_coherent(gasket_get_device(gasket_dev), + num_pages * PAGE_SIZE, mem, handle); + } + + if (gasket_dev->page_table[index]->coherent_pages) { + kfree(gasket_dev->page_table[index]->coherent_pages); + gasket_dev->page_table[index]->coherent_pages = 0; + } + gasket_dev->page_table[index]->num_coherent_pages = 0; + return -ENOMEM; +} + +/* + * Free a block of coherent memory. + * @gasket_dev: Gasket Device. + * @size: Size of the memory block. + * @dma_address: Dma address allocated by the kernel. + * @index: Index of the gasket_page_table within this Gasket device + * + * Description: Release memory allocated thru gasket_alloc_coherent_memory. + */ +int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size, + dma_addr_t dma_address, u64 index) +{ + const struct gasket_driver_desc *driver_desc; + + if (!gasket_dev->page_table[index]) + return -EFAULT; + + driver_desc = gasket_get_driver_desc(gasket_dev); + + if (driver_desc->coherent_buffer_description.base != dma_address) + return -EADDRNOTAVAIL; + + if (gasket_dev->coherent_buffer.length_bytes) { + dma_free_coherent(gasket_get_device(gasket_dev), + gasket_dev->coherent_buffer.length_bytes, + gasket_dev->coherent_buffer.virt_base, + gasket_dev->coherent_buffer.phys_base); + gasket_dev->coherent_buffer.length_bytes = 0; + gasket_dev->coherent_buffer.virt_base = 0; + gasket_dev->coherent_buffer.phys_base = 0; + } + return 0; +} + +/* + * Release all coherent memory. + * @gasket_dev: Gasket Device. + * @index: Index of the gasket_page_table within this Gasket device + * + * Description: Release all memory allocated thru gasket_alloc_coherent_memory. + */ +void gasket_free_coherent_memory_all( + struct gasket_dev *gasket_dev, u64 index) +{ + if (!gasket_dev->page_table[index]) + return; + + if (gasket_dev->coherent_buffer.length_bytes) { + dma_free_coherent(gasket_get_device(gasket_dev), + gasket_dev->coherent_buffer.length_bytes, + gasket_dev->coherent_buffer.virt_base, + gasket_dev->coherent_buffer.phys_base); + gasket_dev->coherent_buffer.length_bytes = 0; + gasket_dev->coherent_buffer.virt_base = 0; + gasket_dev->coherent_buffer.phys_base = 0; + } +} diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h new file mode 100644 index 000000000000..f2f519a3022d --- /dev/null +++ b/drivers/staging/gasket/gasket_page_table.h @@ -0,0 +1,265 @@ +/* Gasket Page Table functionality. This file describes the address + * translation/paging functionality supported by the Gasket driver framework. + * As much as possible, internal details are hidden to simplify use - + * all calls are thread-safe (protected by an internal mutex) except where + * indicated otherwise. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __GASKET_ADDR_TRNSL_H__ +#define __GASKET_ADDR_TRNSL_H__ + +#include +#include + +#include "gasket_constants.h" +#include "gasket_core.h" + +/* + * Structure used for managing address translation on a device. All details are + * internal to the implementation. + */ +struct gasket_page_table; + +/* + * Allocate and init address translation data. + * @ppage_table: Pointer to Gasket page table pointer. Set by this call. + * @att_base_reg: [Mapped] pointer to the first entry in the device's address + * translation table. + * @extended_offset_reg: [Mapped] pointer to the device's register containing + * the starting index of the extended translation table. + * @extended_bit_location: The index of the bit indicating whether an address + * is extended. + * @total_entries: The total number of entries in the device's address + * translation table. + * @device: Device structure for the underlying device. Only used for logging. + * @pci_dev: PCI system descriptor for the underlying device. + * @bool has_dma_ops: Whether the page table uses arch specific dma_ops or + * whether the driver will supply its own. + * + * Description: Allocates and initializes data to track address translation - + * simple and extended page table metadata. Initially, the page table is + * partitioned such that all addresses are "simple" (single-level lookup). + * gasket_partition_page_table can be called to change this paritioning. + * + * Returns 0 on success, a negative error code otherwise. + */ +int gasket_page_table_init( + struct gasket_page_table **ppg_tbl, + const struct gasket_bar_data *bar_data, + const struct gasket_page_table_config *page_table_config, + struct device *device, struct pci_dev *pci_dev, bool dma_ops); + +/* + * Deallocate and cleanup page table data. + * @page_table: Gasket page table pointer. + * + * Description: The inverse of gasket_init; frees page_table and its contained + * elements. + * + * Because this call destroys the page table, it cannot be + * thread-safe (mutex-protected)! + */ +void gasket_page_table_cleanup(struct gasket_page_table *page_table); + +/* + * Sets the size of the simple page table. + * @page_table: Gasket page table pointer. + * @num_simple_entries: Desired size of the simple page table (in entries). + * + * Description: gasket_partition_page_table checks to see if the simple page + * size can be changed (i.e., if there are no active extended + * mappings in the new simple size range), and, if so, + * sets the new simple and extended page table sizes. + * + * Returns 0 if successful, or non-zero if the page table entries + * are not free. + */ +int gasket_page_table_partition( + struct gasket_page_table *page_table, uint num_simple_entries); + +/* + * Get and map [host] user space pages into device memory. + * @page_table: Gasket page table pointer. + * @host_addr: Starting host virtual memory address of the pages. + * @dev_addr: Starting device address of the pages. + * @num_pages: Number of [4kB] pages to map. + * + * Description: Maps the "num_pages" pages of host memory pointed to by + * host_addr to the address "dev_addr" in device memory. + * + * The caller is responsible for checking the addresses ranges. + * + * Returns 0 if successful or a non-zero error number otherwise. + * If there is an error, no pages are mapped. + */ +int gasket_page_table_map(struct gasket_page_table *page_table, ulong host_addr, + ulong dev_addr, uint num_pages); + +/* + * Un-map host pages from device memory. + * @page_table: Gasket page table pointer. + * @dev_addr: Starting device address of the pages to unmap. + * @num_pages: The number of [4kB] pages to unmap. + * + * Description: The inverse of gasket_map_pages. Unmaps pages from the device. + */ +void gasket_page_table_unmap( + struct gasket_page_table *page_table, ulong dev_addr, uint num_pages); + +/* + * Unmap ALL host pages from device memory. + * @page_table: Gasket page table pointer. + */ +void gasket_page_table_unmap_all(struct gasket_page_table *page_table); + +/* + * Unmap all host pages from device memory and reset the table to fully simple + * addressing. + * @page_table: Gasket page table pointer. + */ +void gasket_page_table_reset(struct gasket_page_table *page_table); + +/* + * Reclaims unused page table memory. + * @page_table: Gasket page table pointer. + * + * Description: Examines the page table and frees any currently-unused + * allocations. Called internally on gasket_cleanup(). + */ +void gasket_page_table_garbage_collect(struct gasket_page_table *page_table); + +/* + * Retrieve the backing page for a device address. + * @page_table: Gasket page table pointer. + * @dev_addr: Gasket device address. + * @ppage: Pointer to a page pointer for the returned page. + * @poffset: Pointer to an unsigned long for the returned offset. + * + * Description: Interprets the address and looks up the corresponding page + * in the page table and the offset in that page. (We need an + * offset because the host page may be larger than the Gasket chip + * page it contains.) + * + * Returns 0 if successful, -1 for an error. The page pointer + * and offset are returned through the pointers, if successful. + */ +int gasket_page_table_lookup_page( + struct gasket_page_table *page_table, ulong dev_addr, + struct page **page, ulong *poffset); + +/* + * Checks validity for input addrs and size. + * @page_table: Gasket page table pointer. + * @host_addr: Host address to check. + * @dev_addr: Gasket device address. + * @bytes: Size of the range to check (in bytes). + * + * Description: This call performs a number of checks to verify that the ranges + * specified by both addresses and the size are valid for mapping pages into + * device memory. + * + * Returns 1 if true - if the mapping is bad, 0 otherwise. + */ +int gasket_page_table_are_addrs_bad( + struct gasket_page_table *page_table, ulong host_addr, ulong dev_addr, + ulong bytes); + +/* + * Checks validity for input dev addr and size. + * @page_table: Gasket page table pointer. + * @dev_addr: Gasket device address. + * @bytes: Size of the range to check (in bytes). + * + * Description: This call performs a number of checks to verify that the range + * specified by the device address and the size is valid for mapping pages into + * device memory. + * + * Returns 1 if true - if the address is bad, 0 otherwise. + */ +int gasket_page_table_is_dev_addr_bad( + struct gasket_page_table *page_table, ulong dev_addr, ulong bytes); + +/* + * Gets maximum size for the given page table. + * @page_table: Gasket page table pointer. + */ +uint gasket_page_table_max_size(struct gasket_page_table *page_table); + +/* + * Gets the total number of entries in the arg. + * @page_table: Gasket page table pointer. + */ +uint gasket_page_table_num_entries(struct gasket_page_table *page_table); + +/* + * Gets the number of simple entries. + * @page_table: Gasket page table pointer. + */ +uint gasket_page_table_num_simple_entries(struct gasket_page_table *page_table); + +/* + * Gets the number of extended entries. + * @page_table: Gasket page table pointer. + */ +uint gasket_page_table_num_extended_entries( + struct gasket_page_table *page_table); + +/* + * Gets the number of actively pinned pages. + * @page_table: Gasket page table pointer. + */ +uint gasket_page_table_num_active_pages(struct gasket_page_table *page_table); + +/* + * Get status of page table managed by @page_table. + * @page_table: Gasket page table pointer. + */ +int gasket_page_table_system_status(struct gasket_page_table *page_table); + +/* + * Allocate a block of coherent memory. + * @gasket_dev: Gasket Device. + * @size: Size of the memory block. + * @dma_address: Dma address allocated by the kernel. + * @index: Index of the gasket_page_table within this Gasket device + * + * Description: Allocate a contiguous coherent memory block, DMA'ble + * by this device. + */ +int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, uint64_t size, + dma_addr_t *dma_address, uint64_t index); +/* Release a block of contiguous coherent memory, in use by a device. */ +int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, uint64_t size, + dma_addr_t dma_address, uint64_t index); + +/* Release all coherent memory. */ +void gasket_free_coherent_memory_all(struct gasket_dev *gasket_dev, + uint64_t index); + +/* + * Records the host_addr to coherent dma memory mapping. + * @gasket_dev: Gasket Device. + * @size: Size of the virtual address range to map. + * @dma_address: Dma address within the coherent memory range. + * @vma: Virtual address we wish to map to coherent memory. + * + * Description: For each page in the virtual address range, record the + * coherent page mapping. + * + * Does not perform validity checking. + */ +int gasket_set_user_virt(struct gasket_dev *gasket_dev, uint64_t size, + dma_addr_t dma_address, ulong vma); + +#endif diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c new file mode 100644 index 000000000000..d45098c90b4b --- /dev/null +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -0,0 +1,497 @@ +/* Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include "gasket_sysfs.h" + +#include "gasket_core.h" +#include "gasket_logging.h" + +/* + * Pair of kernel device and user-specified pointer. Used in lookups in sysfs + * "show" functions to return user data. + */ + +struct gasket_sysfs_mapping { + /* + * The device bound to this mapping. If this is NULL, then this mapping + * is free. + */ + struct device *device; + + /* Legacy device struct, if used by this mapping's driver. */ + struct device *legacy_device; + + /* The Gasket descriptor for this device. */ + struct gasket_dev *gasket_dev; + + /* This device's set of sysfs attributes/nodes. */ + struct gasket_sysfs_attribute *attributes; + + /* The number of live elements in "attributes". */ + int attribute_count; + + /* Protects structure from simultaneous access. */ + struct mutex mutex; + + /* Tracks active users of this mapping. */ + struct kref refcount; +}; + +/* + * Data needed to manage users of this sysfs utility. + * Currently has a fixed size; if space is a concern, this can be dynamically + * allocated. + */ +/* + * 'Global' (file-scoped) list of mappings between devices and gasket_data + * pointers. This removes the requirement to have a gasket_sysfs_data + * handle in all files. + */ +static struct gasket_sysfs_mapping dev_mappings[GASKET_SYSFS_NUM_MAPPINGS]; + +/* + * Callback when a mapping's refcount goes to zero. + * @ref: The reference count of the containing sysfs mapping. + */ +static void release_entry(struct kref *ref) +{ + /* All work is done after the return from kref_put. */ +} + +/* + * Looks up mapping information for the given device. + * @device: The device whose mapping to look for. + * + * Looks up the requested device and takes a reference and returns it if found, + * and returns NULL otherwise. + */ +static struct gasket_sysfs_mapping *get_mapping(struct device *device) +{ + int i; + + if (!device) { + gasket_nodev_error("Received NULL device!"); + return NULL; + } + + for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) { + mutex_lock(&dev_mappings[i].mutex); + if (dev_mappings[i].device == device || + dev_mappings[i].legacy_device == device) { + kref_get(&dev_mappings[i].refcount); + mutex_unlock(&dev_mappings[i].mutex); + return &dev_mappings[i]; + } + mutex_unlock(&dev_mappings[i].mutex); + } + + gasket_nodev_info("Mapping to device %s not found.", device->kobj.name); + return NULL; +} + +/* + * Returns a reference to a mapping. + * @mapping: The mapping we're returning. + * + * Decrements the refcount for the given mapping (if valid). If the refcount is + * zero, then it cleans up the mapping - in this function as opposed to the + * kref_put callback, due to a potential deadlock. + * + * Although put_mapping_n exists, this function is left here (as an implicit + * put_mapping_n(..., 1) for convenience. + */ +static void put_mapping(struct gasket_sysfs_mapping *mapping) +{ + int i; + int num_files_to_remove = 0; + struct device_attribute *files_to_remove; + struct device *device; + struct device *legacy_device; + + if (!mapping) { + gasket_nodev_info("Mapping should not be NULL."); + return; + } + + mutex_lock(&mapping->mutex); + if (mapping->refcount.refcount.refs.counter == 0) + gasket_nodev_error("Refcount is already 0!"); + if (kref_put(&mapping->refcount, release_entry)) { + gasket_nodev_info("Removing Gasket sysfs mapping, device %s", + mapping->device->kobj.name); + /* + * We can't remove the sysfs nodes in the kref callback, since + * device_remove_file() blocks until the node is free. + * Readers/writers of sysfs nodes, though, will be blocked on + * the mapping mutex, resulting in deadlock. To fix this, the + * sysfs nodes are removed outside the lock. + */ + device = mapping->device; + legacy_device = mapping->legacy_device; + num_files_to_remove = mapping->attribute_count; + files_to_remove = kzalloc( + num_files_to_remove * sizeof(*files_to_remove), + GFP_KERNEL); + for (i = 0; i < num_files_to_remove; i++) + files_to_remove[i] = mapping->attributes[i].attr; + + kfree(mapping->attributes); + mapping->attributes = NULL; + mapping->attribute_count = 0; + mapping->device = NULL; + mapping->gasket_dev = NULL; + } + mutex_unlock(&mapping->mutex); + + if (num_files_to_remove != 0) { + for (i = 0; i < num_files_to_remove; ++i) { + device_remove_file(device, &files_to_remove[i]); + if (legacy_device) + device_remove_file( + legacy_device, &files_to_remove[i]); + } + kfree(files_to_remove); + } +} + +/* + * Returns a reference N times. + * @mapping: The mapping to return. + * + * In higher-level resource acquire/release function pairs, the release function + * will need to release a mapping 2x - once for the refcount taken in the + * release function itself, and once for the count taken in the acquire call. + */ +static void put_mapping_n(struct gasket_sysfs_mapping *mapping, int times) +{ + int i; + + for (i = 0; i < times; i++) + put_mapping(mapping); +} + +void gasket_sysfs_init(void) +{ + int i; + + for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) { + dev_mappings[i].device = NULL; + mutex_init(&dev_mappings[i].mutex); + } +} + +int gasket_sysfs_create_mapping( + struct device *device, struct gasket_dev *gasket_dev) +{ + struct gasket_sysfs_mapping *mapping; + int map_idx = -1; + + /* + * We need a function-level mutex to protect against the same device + * being added [multiple times] simultaneously. + */ + static DEFINE_MUTEX(function_mutex); + + mutex_lock(&function_mutex); + + gasket_nodev_info( + "Creating sysfs entries for device pointer 0x%p.", device); + + /* Check that the device we're adding hasn't already been added. */ + mapping = get_mapping(device); + if (mapping) { + gasket_nodev_error( + "Attempting to re-initialize sysfs mapping for device " + "0x%p.", device); + put_mapping(mapping); + mutex_unlock(&function_mutex); + return -EINVAL; + } + + /* Find the first empty entry in the array. */ + for (map_idx = 0; map_idx < GASKET_SYSFS_NUM_MAPPINGS; ++map_idx) { + mutex_lock(&dev_mappings[map_idx].mutex); + if (!dev_mappings[map_idx].device) + /* Break with the mutex held! */ + break; + mutex_unlock(&dev_mappings[map_idx].mutex); + } + + if (map_idx == GASKET_SYSFS_NUM_MAPPINGS) { + gasket_nodev_error("All mappings have been exhausted!"); + mutex_unlock(&function_mutex); + return -ENOMEM; + } + + gasket_nodev_info( + "Creating sysfs mapping for device %s.", device->kobj.name); + + mapping = &dev_mappings[map_idx]; + kref_init(&mapping->refcount); + mapping->device = device; + mapping->gasket_dev = gasket_dev; + mapping->attributes = kzalloc( + GASKET_SYSFS_MAX_NODES * sizeof(*mapping->attributes), + GFP_KERNEL); + mapping->attribute_count = 0; + if (!mapping->attributes) { + gasket_nodev_error("Unable to allocate sysfs attribute array."); + mutex_unlock(&mapping->mutex); + mutex_unlock(&function_mutex); + return -ENOMEM; + } + + mutex_unlock(&mapping->mutex); + mutex_unlock(&function_mutex); + + /* Don't decrement the refcount here! One open count keeps it alive! */ + return 0; +} + +int gasket_sysfs_create_entries( + struct device *device, const struct gasket_sysfs_attribute *attrs) +{ + int i; + int ret; + struct gasket_sysfs_mapping *mapping = get_mapping(device); + + if (!mapping) { + gasket_nodev_error( + "Creating entries for device 0x%p without first " + "initializing mapping.", + device); + return -EINVAL; + } + + mutex_lock(&mapping->mutex); + for (i = 0; strcmp(attrs[i].attr.attr.name, GASKET_ARRAY_END_MARKER); + i++) { + if (mapping->attribute_count == GASKET_SYSFS_MAX_NODES) { + gasket_nodev_error( + "Maximum number of sysfs nodes reached for " + "device."); + mutex_unlock(&mapping->mutex); + put_mapping(mapping); + return -ENOMEM; + } + + ret = device_create_file(device, &attrs[i].attr); + if (ret) { + gasket_nodev_error("Unable to create device entries"); + mutex_unlock(&mapping->mutex); + put_mapping(mapping); + return ret; + } + + if (mapping->legacy_device) { + ret = device_create_file(mapping->legacy_device, + &attrs[i].attr); + if (ret) { + gasket_log_error( + mapping->gasket_dev, + "Unable to create legacy sysfs entries;" + " rc: %d", + ret); + mutex_unlock(&mapping->mutex); + put_mapping(mapping); + return ret; + } + } + + mapping->attributes[mapping->attribute_count] = attrs[i]; + ++mapping->attribute_count; + } + + mutex_unlock(&mapping->mutex); + put_mapping(mapping); + return 0; +} +EXPORT_SYMBOL(gasket_sysfs_create_entries); + +void gasket_sysfs_remove_mapping(struct device *device) +{ + struct gasket_sysfs_mapping *mapping = get_mapping(device); + + if (!mapping) { + gasket_nodev_error( + "Attempted to remove non-existent sysfs mapping to " + "device 0x%p", + device); + return; + } + + put_mapping_n(mapping, 2); +} + +struct gasket_dev *gasket_sysfs_get_device_data(struct device *device) +{ + struct gasket_sysfs_mapping *mapping = get_mapping(device); + + if (!mapping) { + gasket_nodev_error("device %p not registered.", device); + return NULL; + } + + return mapping->gasket_dev; +} +EXPORT_SYMBOL(gasket_sysfs_get_device_data); + +void gasket_sysfs_put_device_data(struct device *device, struct gasket_dev *dev) +{ + struct gasket_sysfs_mapping *mapping = get_mapping(device); + + if (!mapping) + return; + + /* See comment of put_mapping_n() for why the '2' is necessary. */ + put_mapping_n(mapping, 2); +} +EXPORT_SYMBOL(gasket_sysfs_put_device_data); + +struct gasket_sysfs_attribute *gasket_sysfs_get_attr( + struct device *device, struct device_attribute *attr) +{ + int i; + int num_attrs; + struct gasket_sysfs_mapping *mapping = get_mapping(device); + struct gasket_sysfs_attribute *attrs = NULL; + + if (!mapping) + return NULL; + + attrs = mapping->attributes; + num_attrs = mapping->attribute_count; + for (i = 0; i < num_attrs; ++i) { + if (!strcmp(attrs[i].attr.attr.name, attr->attr.name)) + return &attrs[i]; + } + + gasket_nodev_error("Unable to find match for device_attribute %s", + attr->attr.name); + return NULL; +} +EXPORT_SYMBOL(gasket_sysfs_get_attr); + +void gasket_sysfs_put_attr( + struct device *device, struct gasket_sysfs_attribute *attr) +{ + int i; + int num_attrs; + struct gasket_sysfs_mapping *mapping = get_mapping(device); + struct gasket_sysfs_attribute *attrs = NULL; + + if (!mapping) + return; + + attrs = mapping->attributes; + num_attrs = mapping->attribute_count; + for (i = 0; i < num_attrs; ++i) { + if (&attrs[i] == attr) { + put_mapping_n(mapping, 2); + return; + } + } + + gasket_nodev_error( + "Unable to put unknown attribute: %s", attr->attr.attr.name); +} +EXPORT_SYMBOL(gasket_sysfs_put_attr); + +ssize_t gasket_sysfs_register_show( + struct device *device, struct device_attribute *attr, char *buf) +{ + ulong reg_address, reg_bar, reg_value; + struct gasket_sysfs_mapping *mapping; + struct gasket_dev *gasket_dev; + struct gasket_sysfs_attribute *gasket_attr; + + mapping = get_mapping(device); + if (!mapping) { + gasket_nodev_info("Device driver may have been removed."); + return 0; + } + + gasket_dev = mapping->gasket_dev; + if (!gasket_dev) { + gasket_nodev_error( + "No sysfs mapping found for device 0x%p", device); + put_mapping(mapping); + return 0; + } + + gasket_attr = gasket_sysfs_get_attr(device, attr); + if (!gasket_attr) { + put_mapping(mapping); + return 0; + } + + reg_address = gasket_attr->data.bar_address.offset; + reg_bar = gasket_attr->data.bar_address.bar; + reg_value = gasket_dev_read_64(gasket_dev, reg_bar, reg_address); + + gasket_sysfs_put_attr(device, gasket_attr); + put_mapping(mapping); + return snprintf(buf, PAGE_SIZE, "0x%lX\n", reg_value); +} +EXPORT_SYMBOL(gasket_sysfs_register_show); + +ssize_t gasket_sysfs_register_store( + struct device *device, struct device_attribute *attr, const char *buf, + size_t count) +{ + ulong parsed_value = 0; + struct gasket_sysfs_mapping *mapping; + struct gasket_dev *gasket_dev; + struct gasket_sysfs_attribute *gasket_attr; + + if (count < 3 || buf[0] != '0' || buf[1] != 'x') { + gasket_nodev_error( + "sysfs register write format: \"0x\"."); + return -EINVAL; + } + + if (kstrtoul(buf, 16, &parsed_value) != 0) { + gasket_nodev_error( + "Unable to parse input as 64-bit hex value: %s.", buf); + return -EINVAL; + } + + mapping = get_mapping(device); + if (!mapping) { + gasket_nodev_info("Device driver may have been removed."); + return 0; + } + + gasket_dev = mapping->gasket_dev; + if (!gasket_dev) { + gasket_nodev_info("Device driver may have been removed."); + return 0; + } + + gasket_attr = gasket_sysfs_get_attr(device, attr); + if (!gasket_attr) { + put_mapping(mapping); + return count; + } + + gasket_dev_write_64(gasket_dev, parsed_value, + gasket_attr->data.bar_address.bar, + gasket_attr->data.bar_address.offset); + + if (gasket_attr->write_callback) + gasket_attr->write_callback( + gasket_dev, gasket_attr, parsed_value); + + gasket_sysfs_put_attr(device, gasket_attr); + put_mapping(mapping); + return count; +} +EXPORT_SYMBOL(gasket_sysfs_register_store); diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h new file mode 100644 index 000000000000..df9360ecab31 --- /dev/null +++ b/drivers/staging/gasket/gasket_sysfs.h @@ -0,0 +1,199 @@ +/* Set of common sysfs utilities. + * + * Copyright (C) 2018 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* The functions described here are a set of utilities to allow each file in the + * Gasket driver framework to manage their own set of sysfs entries, instead of + * centralizing all that work in one file. + * + * The goal of these utilities is to allow for sysfs entries to be easily + * created without causing a proliferation of sysfs "show" functions. This + * requires O(N) string lookups during show function execution, but as reading + * sysfs entries is rarely performance-critical, this is likely acceptible. + */ +#ifndef __GASKET_SYSFS_H__ +#define __GASKET_SYSFS_H__ + +#include "gasket_constants.h" +#include "gasket_core.h" +#include +#include +#include + +/* The maximum number of mappings/devices a driver needs to support. */ +#define GASKET_SYSFS_NUM_MAPPINGS (GASKET_FRAMEWORK_DESC_MAX * GASKET_DEV_MAX) + +/* The maximum number of sysfs nodes in a directory. + */ +#define GASKET_SYSFS_MAX_NODES 196 + +/* End markers for sysfs struct arrays. */ +#define GASKET_ARRAY_END_TOKEN GASKET_RESERVED_ARRAY_END +#define GASKET_ARRAY_END_MARKER __stringify(GASKET_ARRAY_END_TOKEN) + +/* + * Terminator struct for a gasket_sysfs_attr array. Must be at the end of + * all gasket_sysfs_attribute arrays. + */ +#define GASKET_END_OF_ATTR_ARRAY \ + { \ + .attr = __ATTR(GASKET_ARRAY_END_TOKEN, S_IRUGO, NULL, NULL), \ + .data.attr_type = 0, \ + } + +/* + * Pairing of sysfs attribute and user data. + * Used in lookups in sysfs "show" functions to return attribute metadata. + */ +struct gasket_sysfs_attribute { + /* The underlying sysfs device attribute associated with this data. */ + struct device_attribute attr; + + /* User-specified data to associate with the attribute. */ + union { + struct bar_address_ { + ulong bar; + ulong offset; + } bar_address; + uint attr_type; + } data; + + /* + * Function pointer to a callback to be invoked when this attribute is + * written (if so configured). The arguments are to the Gasket device + * pointer, the enclosing gasket_attr structure, and the value written. + * The callback should perform any logging necessary, as errors cannot + * be returned from the callback. + */ + void (*write_callback)( + struct gasket_dev *dev, struct gasket_sysfs_attribute *attr, + ulong value); +}; + +#define GASKET_SYSFS_RO(_name, _show_function, _attr_type) \ + { \ + .attr = __ATTR(_name, S_IRUGO, _show_function, NULL), \ + .data.attr_type = _attr_type \ + } +#define GASKET_SYSFS_REG(_name, _offset, _bar) \ + { \ + .attr = __ATTR(_name, S_IRUGO, gasket_sysfs_register_show, \ + NULL), \ + .data.bar_address = { \ + .bar = _bar, \ + .offset = _offset \ + } \ + } + +/* Initializes the Gasket sysfs subsystem. + * + * Description: Performs one-time initialization. Must be called before usage + * at [Gasket] module load time. + */ +void gasket_sysfs_init(void); + +/* + * Create an entry in mapping_data between a device and a Gasket device. + * @device: Device struct to map to. + * @gasket_dev: The dev struct associated with the driver controlling @device. + * + * Description: This function maps a gasket_dev* to a device*. This mapping can + * be used in sysfs_show functions to get a handle to the gasket_dev struct + * controlling the device node. + * + * If this function is not called before gasket_sysfs_create_entries, a warning + * will be logged. + */ +int gasket_sysfs_create_mapping( + struct device *device, struct gasket_dev *gasket_dev); + +/* + * Creates bulk entries in sysfs. + * @device: Kernel device structure. + * @attrs: List of attributes/sysfs entries to create. + * + * Description: Creates each sysfs entry described in "attrs". Can be called + * multiple times for a given @device. If the gasket_dev specified in + * gasket_sysfs_create_mapping had a legacy device, the entries will be created + * for it, as well. + */ +int gasket_sysfs_create_entries( + struct device *device, const struct gasket_sysfs_attribute *attrs); + +/* + * Removes a device mapping from the global table. + * @device: Device to unmap. + * + * Description: Removes the device->Gasket device mapping from the internal + * table. + */ +void gasket_sysfs_remove_mapping(struct device *device); + +/* + * User data lookup based on kernel device structure. + * @device: Kernel device structure. + * + * Description: Returns the user data associated with "device" in a prior call + * to gasket_sysfs_create_entries. Returns NULL if no mapping can be found. + * Upon success, this call take a reference to internal sysfs data that must be + * released with gasket_sysfs_put_device_data. While this reference is held, the + * underlying device sysfs information/structure will remain valid/will not be + * deleted. + */ +struct gasket_dev *gasket_sysfs_get_device_data(struct device *device); + +/* + * Releases a references to internal data. + * @device: Kernel device structure. + * @dev: Gasket device descriptor (returned by gasket_sysfs_get_device_data). + */ +void gasket_sysfs_put_device_data( + struct device *device, struct gasket_dev *gasket_dev); + +/* + * Gasket-specific attribute lookup. + * @device: Kernel device structure. + * @attr: Device attribute to look up. + * + * Returns the Gasket sysfs attribute associated with the kernel device + * attribute and device structure itself. Upon success, this call will take a + * reference to internal sysfs data that must be released with a call to + * gasket_sysfs_get_device_data. While this reference is held, the underlying + * device sysfs information/structure will remain valid/will not be deleted. + */ +struct gasket_sysfs_attribute *gasket_sysfs_get_attr( + struct device *device, struct device_attribute *attr); + +/* + * Releases a references to internal data. + * @device: Kernel device structure. + * @attr: Gasket sysfs attribute descriptor (returned by + * gasket_sysfs_get_attr). + */ +void gasket_sysfs_put_attr( + struct device *device, struct gasket_sysfs_attribute *attr); + +/* Display a register as a sysfs node. */ +ssize_t gasket_sysfs_register_show( + struct device *device, struct device_attribute *attr, char *buf); + +/* + * Write to a register sysfs node. + * @buf: NULL-terminated data being written. + * @count: number of bytes in the "buf" argument. + */ +ssize_t gasket_sysfs_register_store( + struct device *device, struct device_attribute *attr, const char *buf, + size_t count); + +#endif /* __GASKET_SYSFS_H__ */ From fd29edc7232bc19f969e8f463138afc5472b3d5f Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sun, 1 Jul 2018 13:57:24 -0700 Subject: [PATCH 211/903] staging: speakup: Replace strncpy with memcpy gcc 8.1.0 generates the following warnings. drivers/staging/speakup/kobjects.c: In function 'punc_store': drivers/staging/speakup/kobjects.c:522:2: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length drivers/staging/speakup/kobjects.c:504:6: note: length computed here drivers/staging/speakup/kobjects.c: In function 'synth_store': drivers/staging/speakup/kobjects.c:391:2: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length drivers/staging/speakup/kobjects.c:388:8: note: length computed here Using strncpy() is indeed less than perfect since the length of data to be copied has already been determined with strlen(). Replace strncpy() with memcpy() to address the warning and optimize the code a little. Signed-off-by: Guenter Roeck Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/kobjects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index f1f90222186b..08f11cc17371 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -388,7 +388,7 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, len = strlen(buf); if (len < 2 || len > 9) return -EINVAL; - strncpy(new_synth_name, buf, len); + memcpy(new_synth_name, buf, len); if (new_synth_name[len - 1] == '\n') len--; new_synth_name[len] = '\0'; @@ -519,7 +519,7 @@ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, return -EINVAL; } - strncpy(punc_buf, buf, x); + memcpy(punc_buf, buf, x); while (x && punc_buf[x - 1] == '\n') x--; From 699ed92dce9444f1d5e6713e648b4a76c435183c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 30 Jun 2018 16:59:41 +0200 Subject: [PATCH 212/903] staging: rtl8188eu: remove rtw_ioctl_rtl.h The header rtw_ioctl_rtl.h is not used anywhere. Running 'grep -r rtw_ioctl_rtl *' from kernel root directory returns nothing, remove the file. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/include/rtw_ioctl_rtl.h | 66 ------------------- 1 file changed, 66 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h deleted file mode 100644 index e29ebfd40a58..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h +++ /dev/null @@ -1,66 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_IOCTL_RTL_H_ -#define _RTW_IOCTL_RTL_H_ - -#include -#include - -/* oid_rtl_seg_01_01 ************** */ -int oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv);/* 84 */ -int oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_tx_retry_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_rx_retry_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_tx_beacon_ok_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_tx_beacon_err_hdl(struct oid_par_priv *poid_par_priv); - -int oid_rt_pro_set_fw_dig_state_hdl(struct oid_par_priv *poid_par_priv);/* 8a */ -int oid_rt_pro_set_fw_ra_state_hdl(struct oid_par_priv *poid_par_priv); /* 8b */ - -int oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv);/* 93 */ -int oid_rt_set_encryption_algorithm_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_set_channelplan_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_set_preamble_mode_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_set_bcn_intvl_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_dedicate_probe_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_current_tx_power_level_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_enc_key_mismatch_count_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_enc_key_match_count_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_hardware_radio_off_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_key_mismatch_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_supported_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_channel_list_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_scan_in_progress_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_forced_data_rate_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_wireless_mode_for_scan_list_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_bss_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_scan_with_magic_packet_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_01_03 section start ************** */ -int oid_rt_ap_get_associated_station_list_hdl(struct oid_par_priv *priv); -int oid_rt_ap_switch_into_ap_mode_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_ap_supported_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_ap_set_passphrase_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_01_11 */ -int oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_03_00 section start ************** */ -int oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_set_default_key_id_hdl(struct oid_par_priv *poid_par_priv); - -#endif From 24e66e98683859e930cb08837d2077e9c47461c7 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 30 Jun 2018 10:24:52 +0200 Subject: [PATCH 213/903] staging: rtl8723bs: fix line over 80 characters Fix line over 80 characters by replacing tab with space. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 3e7c1f07b8b4..edb678190b4b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -36,7 +36,7 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) INIT_LIST_HEAD(&psta_xmitpriv->apsd); } -s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) +s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) { int i; struct xmit_buf *pxmitbuf; From 3b41f9bc8076f0b6c323b3af2f2b05152ef54c0f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 29 Jun 2018 20:59:44 +0200 Subject: [PATCH 214/903] staging: rtl8188eu: remove unnecessary parentheses Remove unnecessary parentheses as reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 53c6ca85d69f..53e518148ae5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -81,7 +81,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) for (i = 0; i < NUM_STA; i++) { _rtw_init_stainfo(psta); - INIT_LIST_HEAD(&(pstapriv->sta_hash[i])); + INIT_LIST_HEAD(&pstapriv->sta_hash[i]); list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); @@ -138,7 +138,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) /* delete all reordering_ctrl_timer */ spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { - phead = &(pstapriv->sta_hash[index]); + phead = &pstapriv->sta_hash[index]; plist = phead->next; while (phead != plist) { @@ -266,19 +266,19 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); - list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + list_del_init(&pstaxmitpriv->vo_q.tx_pending); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); - list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + list_del_init(&pstaxmitpriv->vi_q.tx_pending); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); - list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + list_del_init(&pstaxmitpriv->bk_q.tx_pending); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); spin_unlock_bh(&pxmitpriv->lock); @@ -319,7 +319,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) plist = plist->next; - list_del_init(&(prframe->list)); + list_del_init(&prframe->list); rtw_free_recvframe(prframe, pfree_recv_queue); } @@ -363,7 +363,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) #endif /* CONFIG_88EU_AP_MODE */ - spin_lock_bh(&(pfree_sta_queue->lock)); + spin_lock_bh(&pfree_sta_queue->lock); list_add_tail(&psta->list, get_list_head(pfree_sta_queue)); spin_unlock_bh(&pfree_sta_queue->lock); @@ -387,7 +387,7 @@ void rtw_free_all_stainfo(struct adapter *padapter) spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { - phead = &(pstapriv->sta_hash[index]); + phead = &pstapriv->sta_hash[index]; plist = phead->next; while (phead != plist) { @@ -423,7 +423,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_lock_bh(&pstapriv->sta_hash_lock); - phead = &(pstapriv->sta_hash[index]); + phead = &pstapriv->sta_hash[index]; plist = phead->next; while (phead != plist) { @@ -481,7 +481,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct __queue *pacl_node_q = &pacl_list->acl_node_q; - spin_lock_bh(&(pacl_node_q->lock)); + spin_lock_bh(&pacl_node_q->lock); phead = get_list_head(pacl_node_q); plist = phead->next; while (phead != plist) { From 0a561b0f91d2820c6054eb620af755b9dd39b35e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 28 Jun 2018 19:02:52 +0200 Subject: [PATCH 215/903] staging: rtl8723bs: remove pointless if else in rtw_sdio_resume() Whether any of the conditions is true or not, the return variable is always set to rtw_resume_process(padapter). Replace the if else construct with a single call to rtw_resume_process(). Also remove the now unused local variable pwrpriv. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index 22191c9584ad..6d02904de63f 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -605,7 +605,6 @@ static int rtw_sdio_resume(struct device *dev) { struct sdio_func *func =dev_to_sdio_func(dev); struct dvobj_priv *psdpriv = sdio_get_drvdata(func); - struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(psdpriv); struct adapter *padapter = psdpriv->if1; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; int ret = 0; @@ -615,25 +614,11 @@ static int rtw_sdio_resume(struct device *dev) pdbgpriv->dbg_resume_cnt++; - if (pwrpriv->bInternalAutoSuspend) - { - ret = rtw_resume_process(padapter); - } - else - { - if (pwrpriv->wowlan_mode || pwrpriv->wowlan_ap_mode) - { - ret = rtw_resume_process(padapter); - } - else - { - ret = rtw_resume_process(padapter); - } - } + ret = rtw_resume_process(padapter); + pmlmeext->last_scan_time = jiffies; DBG_871X("<======== %s return %d\n", __func__, ret); return ret; - } static int __init rtw_drv_entry(void) From 698b47cb2204e7ee24a02a58fdf414f1d9139e02 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sat, 30 Jun 2018 20:25:29 +0300 Subject: [PATCH 216/903] staging:r8188eu: Use lib80211 to encrypt (WEP) tx frames Put data to skb, decrypt with lib80211_crypt_wep, and place back to tx buffer. Signed-off-by: Ivan Safonov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 80 +++++++++++-------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 5b8d7288a4e7..a01290467c64 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -131,60 +131,72 @@ static __le32 getcrc32(u8 *buf, int len) Need to consider the fragment situation */ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) -{ /* exclude ICV */ - - unsigned char crc[4]; - struct arc4context mycontext; - +{ int curfragnum, length; - u32 keylength; - - u8 *pframe, *payload, *iv; /* wepkey */ - u8 wepkey[16]; - u8 hw_hdr_offset = 0; + u8 *pframe; + u8 hw_hdr_offset = 0; struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - + const int keyindex = psecuritypriv->dot11PrivacyKeyIndex; + void *crypto_private; + struct sk_buff *skb; + struct lib80211_crypto_ops *crypto_ops; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return; + if ((pattrib->encrypt != _WEP40_) && (pattrib->encrypt != _WEP104_)) + return; + hw_hdr_offset = TXDESC_SIZE + (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; - /* start to encrypt each fragment */ - if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) { - keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex]; + crypto_ops = try_then_request_module(lib80211_get_crypto_ops("WEP"), "lib80211_crypt_wep"); - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; - memcpy(&wepkey[0], iv, 3); - memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); - payload = pframe+pattrib->iv_len+pattrib->hdrlen; + if (!crypto_ops) + return; - if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + crypto_private = crypto_ops->init(keyindex); + if (!crypto_private) + return; - *((__le32 *)crc) = getcrc32(payload, length); + if (crypto_ops->set_key(psecuritypriv->dot11DefKey[keyindex].skey, + psecuritypriv->dot11DefKeylen[keyindex], NULL, crypto_private) < 0) + goto free_crypto_private; - arcfour_init(&mycontext, wepkey, 3+keylength); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); - } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = getcrc32(payload, length); - arcfour_init(&mycontext, wepkey, 3+keylength); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + if (curfragnum + 1 == pattrib->nr_frags) + length = pattrib->last_txcmdsz; + else + length = pxmitpriv->frag_len; + skb = dev_alloc_skb(length); + if (!skb) + goto free_crypto_private; - pframe += pxmitpriv->frag_len; - pframe = (u8 *)round_up((size_t)(pframe), 4); - } + skb_put_data(skb, pframe, length); + + memmove(skb->data + 4, skb->data, pattrib->hdrlen); + skb_pull(skb, 4); + skb_trim(skb, skb->len - 4); + + if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, crypto_private)) { + kfree_skb(skb); + goto free_crypto_private; } + + memcpy(pframe, skb->data, skb->len); + + pframe += skb->len; + pframe = (u8 *)round_up((size_t)(pframe), 4); + + kfree_skb(skb); } + +free_crypto_private: + crypto_ops->deinit(crypto_private); } int rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) From 790d5d2a7e9b494272dcf8ddc44f12aec4d36b35 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 29 Jun 2018 19:10:06 +0100 Subject: [PATCH 217/903] staging: rtl8192u Remove redundant #include directive The file includes the file rtl819x_HT.h, which has already been included by the previously included file ieee80211.h Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 1dd4c6ae7319..98d74d87bf11 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -5,7 +5,7 @@ * little changed. If any confusion caused, tell me. Created by WB. 2008.05.08 */ #include "ieee80211.h" -#include "rtl819x_HT.h" + u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; From d2ab9916f0122c77cc9bbb8b74c6a6dde458b4a2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 30 Jun 2018 13:36:27 +0200 Subject: [PATCH 218/903] staging: rtl8723bs: fix comparsion to true/false and brace issues Use if(x) and if(!x) instead of comparsion to true/false. Reported by checkpatch. Remove unrequired braces from single if else statement. Add missing space after else: else{ -> else { Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 8 ++++---- drivers/staging/rtl8723bs/core/rtw_efuse.c | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index adac915a2153..e56502e301ec 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -77,14 +77,14 @@ void rtw_btcoex_SuspendNotify(struct adapter *padapter, u8 state) void rtw_btcoex_HaltNotify(struct adapter *padapter) { - if (false == padapter->bup) { + if (!padapter->bup) { DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n", FUNC_ADPT_ARG(padapter), padapter->bup); return; } - if (true == padapter->bSurpriseRemoved) { + if (padapter->bSurpriseRemoved) { DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n", FUNC_ADPT_ARG(padapter), padapter->bSurpriseRemoved); @@ -198,11 +198,11 @@ void rtw_btcoex_RejectApAggregatedPacket(struct adapter *padapter, u8 enable) pmlmeinfo = &padapter->mlmeextpriv.mlmext_info; psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); - if (true == enable) { + if (enable) { pmlmeinfo->accept_addba_req = false; if (psta) send_delba(padapter, 0, psta->hwaddr); - } else{ + } else { pmlmeinfo->accept_addba_req = true; } } diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c index c306ad7e395c..b3247c9642ea 100644 --- a/drivers/staging/rtl8723bs/core/rtw_efuse.c +++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c @@ -580,11 +580,10 @@ void EFUSE_ShadowMapUpdate( EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, bPseudoTest); - if (pEEPROM->bautoload_fail_flag == true) { + if (pEEPROM->bautoload_fail_flag) memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen); - } else{ + else Efuse_ReadAllMap(padapter, efuseType, pEEPROM->efuse_eeprom_data, bPseudoTest); - } /* PlatformMoveMemory((void *)&pHalData->EfuseMap[EFUSE_MODIFY_MAP][0], */ /* void *)&pHalData->EfuseMap[EFUSE_INIT_MAP][0], mapLen); */ From 9d4bedcbf2ad15e9090b8f56a40c77d1c23986b0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 30 Jun 2018 13:36:28 +0200 Subject: [PATCH 219/903] staging: rtl8723bs: simplify if else statement Simplify if else statement to a single function call by passing the variable. Suggested-by: Andreas Schwab Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index e56502e301ec..35310e8e0806 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -115,11 +115,7 @@ s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) void rtw_btcoex_SetManualControl(struct adapter *padapter, u8 manual) { - if (true == manual) { - hal_btcoex_SetManualControl(padapter, true); - } else{ - hal_btcoex_SetManualControl(padapter, false); - } + hal_btcoex_SetManualControl(padapter, manual); } u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter) From 3a26036ff91a2a5ec2b639e9cd3c0241a7c50682 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 30 Jun 2018 20:14:38 +0200 Subject: [PATCH 220/903] staging: rtl8188eu: reorder switch cases and remove default break Reorder the cases of a switch statement to be in ascending order. Remove unrequired break from default case. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_com.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index b91902cdb34c..b2ea3d435af0 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -264,18 +264,17 @@ bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe) bool result = true; switch (numoutpipe) { + case 1: + one_out_pipe(adapter); + break; case 2: two_out_pipe(adapter, wifi_cfg); break; case 3: three_out_pipe(adapter, wifi_cfg); break; - case 1: - one_out_pipe(adapter); - break; default: result = false; - break; } return result; } From f33f23048f638c078a83007e7678872756174d42 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 30 Jun 2018 20:14:39 +0200 Subject: [PATCH 221/903] staging: rtl8188eu: move return type to functions definition line The return type of a function should be on the same line as the definition. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_com.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index b2ea3d435af0..ca26a4f4dd86 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -44,10 +44,10 @@ void dump_chip_info(struct HAL_VERSION chip_vers) #define CHAN_PLAN_HW 0x80 -u8 /* return the final channel plan decision */ -hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan, - u8 sw_channel_plan, u8 def_channel_plan, - bool load_fail) +/* return the final channel plan decision */ +u8 hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan, + u8 sw_channel_plan, u8 def_channel_plan, + bool load_fail) { u8 sw_cfg; u8 chnlplan; From 7651f3abf88e310579afaa56535438df5a1e7cd9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 30 Jun 2018 20:14:40 +0200 Subject: [PATCH 222/903] staging: rtl8188eu: fix block comments - coding style Write multiple single line comments as block comments to follow kernel coding style and improve readability. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_com.c | 50 ++++++++++++++----------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index ca26a4f4dd86..7202e1767fc0 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -189,11 +189,13 @@ static void two_out_pipe(struct adapter *adapter, bool wifi_cfg) { struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - if (wifi_cfg) { /* WMM */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:L */ - + if (wifi_cfg) { + /* + * WMM + * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA + * 0, 1, 0, 1, 0, 0, 0, 0, 0 + * 0:H, 1:L + */ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ @@ -203,12 +205,13 @@ static void two_out_pipe(struct adapter *adapter, bool wifi_cfg) pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - - } else {/* typical setting */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:L */ - + } else { + /* + * typical setting + * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA + * 1, 1, 0, 0, 0, 0, 0, 0, 0 + * 0:H, 1:L + */ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ @@ -225,11 +228,13 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg) { struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - if (wifi_cfg) {/* for WMM */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:N, 2:L */ - + if (wifi_cfg) { + /* + * for WMM + * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA + * 1, 2, 1, 0, 0, 0, 0, 0, 0 + * 0:H, 1:N, 2:L + */ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ @@ -239,12 +244,13 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg) pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - - } else {/* typical setting */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:N, 2:L */ - + } else { + /* + * typical setting + * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA + * 2, 2, 1, 0, 0, 0, 0, 0, 0 + * 0:H, 1:N, 2:L + */ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ From 0d7fa8fa9cbc659ad825aacc3dc53e03400894ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Dost=C3=A1l?= Date: Mon, 2 Jul 2018 09:28:49 +0200 Subject: [PATCH 223/903] staging: fbtft: indent fbtft_device_display - last entry - pdev - dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dev section was opening curly bracket, but not adding ident, which resulted in two times "}," after each other with same indentation. Add ident at the right place fixes this problem. This formatting issue is not detectable by checkpatch.pl Signed-off-by: Radek Dostál Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft_device.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index ec8477674b7d..22ba81dbf093 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -1223,14 +1223,14 @@ static struct fbtft_device_display displays[] = { .name = "", .id = 0, .dev = { - .release = fbtft_device_pdev_release, - .platform_data = &(struct fbtft_platform_data) { - .gpios = (const struct fbtft_gpio []) { - {}, + .release = fbtft_device_pdev_release, + .platform_data = &(struct fbtft_platform_data) { + .gpios = (const struct fbtft_gpio []) { + {}, + }, }, }, }, - }, } }; From de7d179377356b7eb8912e29d72e92df7f919ca5 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 5 Jul 2018 08:00:26 +0200 Subject: [PATCH 224/903] staging: mt7621-gpio: set irq chip name only once There is only one irq chip so set its name only once in driver probe function. Signed-off-by: Sergio Paracuellos Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 281e6214d543..06024a3f649c 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -257,7 +257,6 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, return ret; } - mediatek_gpio_irq_chip.name = rg->chip.label; ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip, 0, handle_simple_irq, IRQ_TYPE_NONE); if (ret) { @@ -296,6 +295,7 @@ mediatek_gpio_probe(struct platform_device *pdev) gpio_data->gpio_irq = irq_of_parse_and_map(np, 0); gpio_data->dev = &pdev->dev; platform_set_drvdata(pdev, gpio_data); + mediatek_gpio_irq_chip.name = dev_name(&pdev->dev); for (i = 0; i < MTK_BANK_CNT; i++) mediatek_gpio_bank_probe(pdev, np, i); From cf229037c57d0e7ff4846ba304ba5a4ae2f7aee4 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 5 Jul 2018 08:00:27 +0200 Subject: [PATCH 225/903] staging: mt7621-gpio: use custom xlate function The default gpio.of_xlate function assumes there is one gpio chip for each devicetree node. Device tree had changed to only use one node, which corresponds to 3 different gpio chips now. For that approach to work we need a custom xlate function. Signed-off-by: Sergio Paracuellos Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 06024a3f649c..ccf2aa85d665 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -205,6 +205,22 @@ static inline const char * const mediatek_gpio_bank_name(int bank) return bank_names[bank]; } +static int +mediatek_gpio_xlate(struct gpio_chip *chip, + const struct of_phandle_args *spec, u32 *flags) +{ + int gpio = spec->args[0]; + struct mtk_gc *rg = to_mediatek_gpio(chip); + + if (rg->bank != gpio / MTK_BANK_WIDTH) + return -EINVAL; + + if (flags) + *flags = spec->args[1]; + + return gpio % MTK_BANK_WIDTH; +} + static int mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *node, int bank) @@ -220,6 +236,8 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, spin_lock_init(&rg->lock); rg->chip.of_node = node; rg->bank = bank; + rg->chip.of_gpio_n_cells = 2; + rg->chip.of_xlate = mediatek_gpio_xlate; rg->chip.label = mediatek_gpio_bank_name(rg->bank); dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); From 24186ccda251c8880de0e77ce3bb28a4066763b2 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 5 Jul 2018 08:00:28 +0200 Subject: [PATCH 226/903] staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init bgpio_init function set different data of the gpio chip, like the name. We want specific name for each bank so to get that not overwritten move all custom changes after the bgpio_init function call. Signed-off-by: Sergio Paracuellos Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index ccf2aa85d665..1b4588ab1ec1 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -236,9 +236,6 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, spin_lock_init(&rg->lock); rg->chip.of_node = node; rg->bank = bank; - rg->chip.of_gpio_n_cells = 2; - rg->chip.of_xlate = mediatek_gpio_xlate; - rg->chip.label = mediatek_gpio_bank_name(rg->bank); dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE); @@ -252,6 +249,10 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, return ret; } + rg->chip.of_gpio_n_cells = 2; + rg->chip.of_xlate = mediatek_gpio_xlate; + rg->chip.label = mediatek_gpio_bank_name(rg->bank); + ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n", From ff19ad29d257f7b3ff738054f9040606998cc114 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 5 Jul 2018 08:00:29 +0200 Subject: [PATCH 227/903] staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels Instead of using a custom function to return desired name for gpio use the default assigned one and concat it '-bankN' suffix using devm_kasprintf kernel function. Signed-off-by: Sergio Paracuellos Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 1b4588ab1ec1..d7256b56e621 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -196,15 +196,6 @@ static struct irq_chip mediatek_gpio_irq_chip = { .irq_set_type = mediatek_gpio_irq_type, }; -static inline const char * const mediatek_gpio_bank_name(int bank) -{ - static const char * const bank_names[] = { - "mt7621-bank0", "mt7621-bank1", "mt7621-bank2", - }; - - return bank_names[bank]; -} - static int mediatek_gpio_xlate(struct gpio_chip *chip, const struct of_phandle_args *spec, u32 *flags) @@ -251,7 +242,8 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, rg->chip.of_gpio_n_cells = 2; rg->chip.of_xlate = mediatek_gpio_xlate; - rg->chip.label = mediatek_gpio_bank_name(rg->bank); + rg->chip.label = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-bank%d", + dev_name(&pdev->dev), bank); ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio); if (ret < 0) { From b3cd051dc3a84fffe5ff1a896a6b6c7a33a96fe6 Mon Sep 17 00:00:00 2001 From: Sergej Perschin Date: Thu, 5 Jul 2018 14:41:01 +0200 Subject: [PATCH 228/903] staging: mt7621-mmc: Fix printk() facility level The patch fixes the following issue: WARNING: printk() should include KERN_ facility level Signed-off-by: Sergej Perschin Signed-off-by: Marcel Budoj Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/dbg.c | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c index 6e4e223cddfb..6e518dce9029 100644 --- a/drivers/staging/mt7621-mmc/dbg.c +++ b/drivers/staging/mt7621-mmc/dbg.c @@ -91,11 +91,11 @@ u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32) ret = new_L32 - old_L32; } else if (new_H32 == (old_H32 + 1)) { if (new_L32 > old_L32) - printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32); + pr_debug("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32); ret = (0xffffffff - old_L32); ret += new_L32; } else { - printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32); + pr_debug("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32); } return ret; @@ -106,34 +106,34 @@ void msdc_sdio_profile(struct sdio_profile *result) struct cmd_profile *cmd; u32 i; - printk("sdio === performance dump ===\n"); - printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n", - result->total_tc, result->total_tc / TICKS_ONE_MS, - result->total_tx_bytes, result->total_rx_bytes); + pr_debug("sdio === performance dump ===\n"); + pr_debug("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n", + result->total_tc, result->total_tc / TICKS_ONE_MS, + result->total_tx_bytes, result->total_rx_bytes); /* CMD52 Dump */ cmd = &result->cmd52_rx; - printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc, - cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count); + pr_debug("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc, + cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count); cmd = &result->cmd52_tx; - printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc, - cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count); + pr_debug("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc, + cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count); /* CMD53 Rx bytes + block mode */ for (i = 0; i < 512; i++) { cmd = &result->cmd53_rx_byte[i]; if (cmd->count) { - printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, - cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, - cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); + pr_debug("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, + cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, + cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); } } for (i = 0; i < 100; i++) { cmd = &result->cmd53_rx_blk[i]; if (cmd->count) { - printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, - cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, - cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); + pr_debug("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, + cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, + cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); } } @@ -141,21 +141,21 @@ void msdc_sdio_profile(struct sdio_profile *result) for (i = 0; i < 512; i++) { cmd = &result->cmd53_tx_byte[i]; if (cmd->count) { - printk("sdio<%6d><%3dB>_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, - cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, - cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); + pr_debug("sdio<%6d><%3dB>_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, + cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, + cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); } } for (i = 0; i < 100; i++) { cmd = &result->cmd53_tx_blk[i]; if (cmd->count) { - printk("sdio<%6d><%3d>B_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, - cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, - cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); + pr_debug("sdio<%6d><%3d>B_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, + cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, + cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); } } - printk("sdio === performance dump done ===\n"); + pr_debug("sdio === performance dump done ===\n"); } //========= sdio command table =========== @@ -176,7 +176,7 @@ void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks) } else { block = sizes / 512; if (block >= 99) { - printk("cmd53 error blocks\n"); + pr_err("cmd53 error blocks\n"); while (1) ; } @@ -247,7 +247,7 @@ static ssize_t msdc_debug_proc_write(struct file *file, return -EFAULT; cmd_buf[count] = '\0'; - printk("msdc Write %s\n", cmd_buf); + pr_debug("msdc Write %s\n", cmd_buf); sscanf(cmd_buf, "%x %x %x", &cmd, &p1, &p2); @@ -255,14 +255,14 @@ static ssize_t msdc_debug_proc_write(struct file *file, id = p1; zone = p2; zone &= 0x3ff; - printk("msdc host_id<%d> zone<0x%.8x>\n", id, zone); + pr_debug("msdc host_id<%d> zone<0x%.8x>\n", id, zone); if (id >= 0 && id <= 3) { sd_debug_zone[id] = zone; } else if (id == 4) { sd_debug_zone[0] = sd_debug_zone[1] = zone; sd_debug_zone[2] = sd_debug_zone[3] = zone; } else { - printk("msdc host_id error when set debug zone\n"); + pr_err("msdc host_id error when set debug zone\n"); } } else if (cmd == SD_TOOL_SDIO_PROFILE) { if (p1 == 1) { /* enable profile */ From f4da9b1ed66fa6a97d20fa3a93f2a83097c7717c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:02:57 +0200 Subject: [PATCH 229/903] staging: mt7621-pinctrl: avoid space after if condition Adding spaces between if condition and parenthesis are not needed at all and checkpatch script complains about them. Fix one in driver code. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 1e49a7b9e5fb..6c9517f10104 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -357,7 +357,7 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) p->pads = devm_kcalloc(p->dev, p->max_pins, sizeof(struct pinctrl_pin_desc), GFP_KERNEL); - if (!p->pads || !p->gpio ) { + if (!p->pads || !p->gpio) { dev_err(p->dev, "Failed to allocate gpio data\n"); return -ENOMEM; } From c60cf7e034d3868562f32e8e0458da32ba704b93 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:02:58 +0200 Subject: [PATCH 230/903] staging: mt7621-pinctrl: avoid lines over 80 chars This commit silence checkpatch warnings about lines which exceeds 80 chars. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- .../staging/mt7621-pinctrl/pinctrl-rt2880.c | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 6c9517f10104..849af875cd49 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -205,7 +205,8 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, /* dont allow double use */ if (p->groups[group].enabled) { - dev_err(p->dev, "%s is already enabled\n", p->groups[group].name); + dev_err(p->dev, "%s is already enabled\n", + p->groups[group].name); return -EBUSY; } @@ -283,8 +284,8 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) } /* allocate the group names array needed by the gpio function */ - p->group_names = devm_kcalloc(p->dev, p->group_count, sizeof(char *), - GFP_KERNEL); + p->group_names = devm_kcalloc(p->dev, p->group_count, + sizeof(char *), GFP_KERNEL); if (!p->group_names) return -1; @@ -318,7 +319,8 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) for (i = 0; i < p->group_count; i++) { for (j = 0; j < p->groups[i].func_count; j++) { f[c] = &p->groups[i].func[j]; - f[c]->groups = devm_kzalloc(p->dev, sizeof(int), GFP_KERNEL); + f[c]->groups = devm_kzalloc(p->dev, sizeof(int), + GFP_KERNEL); f[c]->groups[0] = i; f[c]->group_count = 1; c++; @@ -331,7 +333,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) { int i, j; - /* loop over the functions and initialize the pins array. also work out the highest pin used */ + /* + * loop over the functions and initialize the pins array. + * also work out the highest pin used. + */ for (i = 0; i < p->func_count; i++) { int pin; @@ -351,12 +356,11 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) } /* the buffer that tells us which pins are gpio */ - p->gpio = devm_kcalloc(p->dev,p->max_pins, sizeof(uint8_t), - GFP_KERNEL); + p->gpio = devm_kcalloc(p->dev, p->max_pins, + sizeof(uint8_t), GFP_KERNEL); /* the pads needed to tell pinctrl about our pins */ - p->pads = devm_kcalloc(p->dev, - p->max_pins, sizeof(struct pinctrl_pin_desc), - GFP_KERNEL); + p->pads = devm_kcalloc(p->dev, p->max_pins, + sizeof(struct pinctrl_pin_desc), GFP_KERNEL); if (!p->pads || !p->gpio) { dev_err(p->dev, "Failed to allocate gpio data\n"); return -ENOMEM; @@ -439,7 +443,7 @@ static int rt2880_pinmux_probe(struct platform_device *pdev) return -EINVAL; } - range = devm_kzalloc(p->dev, sizeof(struct pinctrl_gpio_range) + 4, GFP_KERNEL); + range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL); range->name = name = (char *) &range[1]; sprintf(name, "pio"); range->npins = __be32_to_cpu(*ngpio); From e5d66a1815a22a33af2619402f1d9afe40d0001a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:02:59 +0200 Subject: [PATCH 231/903] staging: mt7621-pinctrl: replace seq_printf with seq_puts For a constant format without additional arguments, use seq_puts() instead of seq_printf() fixing also the following checkpatch.pl warning: 'Prefer seq_puts to seq_printf' Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 849af875cd49..ea37ae4cadb3 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -92,7 +92,7 @@ static void rt2880_pinctrl_pin_dbg_show(struct pinctrl_dev *pctrldev, struct seq_file *s, unsigned int offset) { - seq_printf(s, "ralink pio"); + seq_puts(s, "ralink pio"); } static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev, From d756d387d4f4e8701ac195772a5b29efa717d19e Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:00 +0200 Subject: [PATCH 232/903] staging: mt7621-pinctrl: align function parameters in some functions Function parameters along the code has different alignment styles. Just unify all of them making style consistent. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- .../staging/mt7621-pinctrl/pinctrl-rt2880.c | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index ea37ae4cadb3..52d4951c8047 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -76,8 +76,8 @@ static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev, } static void rt2880_pinctrl_dt_free_map(struct pinctrl_dev *pctrldev, - struct pinctrl_map *map, - unsigned int num_maps) + struct pinctrl_map *map, + unsigned int num_maps) { int i; @@ -96,8 +96,8 @@ static void rt2880_pinctrl_pin_dbg_show(struct pinctrl_dev *pctrldev, } static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev, - struct device_node *np, - struct pinctrl_map **map) + struct device_node *np, + struct pinctrl_map **map) { const char *function; int func = of_property_read_string(np, "ralink,function", &function); @@ -121,9 +121,9 @@ static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev, } static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, - struct device_node *np_config, - struct pinctrl_map **map, - unsigned int *num_maps) + struct device_node *np_config, + struct pinctrl_map **map, + unsigned int *num_maps) { int max_maps = 0; struct pinctrl_map *tmp; @@ -169,7 +169,7 @@ static int rt2880_pmx_func_count(struct pinctrl_dev *pctrldev) } static const char *rt2880_pmx_func_name(struct pinctrl_dev *pctrldev, - unsigned int func) + unsigned int func) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); @@ -177,9 +177,9 @@ static const char *rt2880_pmx_func_name(struct pinctrl_dev *pctrldev, } static int rt2880_pmx_group_get_groups(struct pinctrl_dev *pctrldev, - unsigned int func, - const char * const **groups, - unsigned int * const num_groups) + unsigned int func, + const char * const **groups, + unsigned int * const num_groups) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); @@ -194,8 +194,7 @@ static int rt2880_pmx_group_get_groups(struct pinctrl_dev *pctrldev, } static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, - unsigned int func, - unsigned int group) + unsigned int func, unsigned int group) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); u32 mode = 0; @@ -239,8 +238,8 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, } static int rt2880_pmx_group_gpio_request_enable(struct pinctrl_dev *pctrldev, - struct pinctrl_gpio_range *range, - unsigned int pin) + struct pinctrl_gpio_range *range, + unsigned int pin) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); From a2a678b6972ce59dcffefd5d0a86bff07e67a9a2 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:01 +0200 Subject: [PATCH 233/903] staging: mt7621-pinctrl: use tabs instead of spaces in some indentations Kernel coding style use tabs for indent code instead of spaces. Fix some places where spaces were being used silencing also checkpatch script complains. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 52d4951c8047..bdee65c8f805 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -99,7 +99,7 @@ static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev, struct device_node *np, struct pinctrl_map **map) { - const char *function; + const char *function; int func = of_property_read_string(np, "ralink,function", &function); int grps = of_property_count_strings(np, "ralink,group"); int i; @@ -108,7 +108,7 @@ static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev, return; for (i = 0; i < grps; i++) { - const char *group; + const char *group; of_property_read_string_index(np, "ralink,group", i, &group); @@ -197,7 +197,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, unsigned int func, unsigned int group) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); - u32 mode = 0; + u32 mode = 0; u32 reg = SYSC_REG_GPIO_MODE; int i; int shift; From 39a30ef33f99d4c685dd202be01c15ea496c7282 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:02 +0200 Subject: [PATCH 234/903] staging: mt7621-pinctrl: make use of pinctrl_utils_free_map There was a custom 'rt2880_pinctrl_dt_free_map' function which it was doing the same as pinctrl_utils_free_map defined in 'pinctrl-utils.h' header file. Use it instead avoiding code duplications. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index bdee65c8f805..d08386601c73 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -20,6 +20,7 @@ #include #include "core.h" +#include "pinctrl-utils.h" #define SYSC_REG_GPIO_MODE 0x60 #define SYSC_REG_GPIO_MODE2 0x64 @@ -75,19 +76,6 @@ static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev, return 0; } -static void rt2880_pinctrl_dt_free_map(struct pinctrl_dev *pctrldev, - struct pinctrl_map *map, - unsigned int num_maps) -{ - int i; - - for (i = 0; i < num_maps; i++) - if (map[i].type == PIN_MAP_TYPE_CONFIGS_PIN || - map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP) - kfree(map[i].data.configs.configs); - kfree(map); -} - static void rt2880_pinctrl_pin_dbg_show(struct pinctrl_dev *pctrldev, struct seq_file *s, unsigned int offset) @@ -158,7 +146,7 @@ static const struct pinctrl_ops rt2880_pctrl_ops = { .get_group_pins = rt2880_get_group_pins, .pin_dbg_show = rt2880_pinctrl_pin_dbg_show, .dt_node_to_map = rt2880_pinctrl_dt_node_to_map, - .dt_free_map = rt2880_pinctrl_dt_free_map, + .dt_free_map = pinctrl_utils_free_map, }; static int rt2880_pmx_func_count(struct pinctrl_dev *pctrldev) From 4a1cf86bce6782a44c4a6c96e6e036e590099012 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:03 +0200 Subject: [PATCH 235/903] staging: mt7621-pinctrl: replace uint8_t type with u8 for 'gpio' field Struct 'rt2880_priv' contains a field 'gpio' which is defined as uint8_t and should be defined with 'u8' which is preferred. Update some cast along the code related with this new change. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index d08386601c73..65c6b5ad231b 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -38,7 +38,7 @@ struct rt2880_priv { const char **group_names; int group_count; - uint8_t *gpio; + u8 *gpio; int max_pins; }; @@ -343,8 +343,7 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) } /* the buffer that tells us which pins are gpio */ - p->gpio = devm_kcalloc(p->dev, p->max_pins, - sizeof(uint8_t), GFP_KERNEL); + p->gpio = devm_kcalloc(p->dev, p->max_pins, sizeof(u8), GFP_KERNEL); /* the pads needed to tell pinctrl about our pins */ p->pads = devm_kcalloc(p->dev, p->max_pins, sizeof(struct pinctrl_pin_desc), GFP_KERNEL); @@ -353,7 +352,7 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) return -ENOMEM; } - memset(p->gpio, 1, sizeof(uint8_t) * p->max_pins); + memset(p->gpio, 1, sizeof(u8) * p->max_pins); for (i = 0; i < p->func_count; i++) { if (!p->func[i]->pin_count) continue; From 62b6215c11eade6938d3d25e18a3682ed3dfcb91 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:04 +0200 Subject: [PATCH 236/903] staging: mt7621-pinctrl: make use of pinctrl_utils_reserve_map Function rt2880_pinctrl_dt_node_to_map was using 'kzalloc' to reserve map memory. There is a 'pinctrl_utils_reserve_map' to do this function. Just use it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 65c6b5ad231b..8a196d357e0f 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -113,7 +113,10 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, struct pinctrl_map **map, unsigned int *num_maps) { + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); + int ret; int max_maps = 0; + unsigned int reserved_maps = 0; struct pinctrl_map *tmp; struct device_node *np; @@ -127,9 +130,12 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, if (!max_maps) return max_maps; - *map = kcalloc(max_maps, sizeof(struct pinctrl_map), GFP_KERNEL); - if (!*map) - return -ENOMEM; + ret = pinctrl_utils_reserve_map(pctrldev, map, &reserved_maps, + num_maps, max_maps); + if (ret) { + dev_err(p->dev, "can't reserve map: %d\n", ret); + return ret; + } tmp = *map; From d7461eab5a04e8426dc5ddcbf7911903d22b69f4 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:05 +0200 Subject: [PATCH 237/903] staging: mt7621-dts: use 'function' and 'group' for pinctrl bindings According to documentation 'pinctrl-bindings.txt' bindings 'group' and 'function' can be used directly. So replace all of them. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 48 +++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index a87fcc6d61b2..4610403b470d 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -204,83 +204,83 @@ i2c_pins: i2c { i2c { - ralink,group = "i2c"; - ralink,function = "i2c"; + group = "i2c"; + function = "i2c"; }; }; spi_pins: spi { spi { - ralink,group = "spi"; - ralink,function = "spi"; + group = "spi"; + function = "spi"; }; }; uart1_pins: uart1 { uart1 { - ralink,group = "uart1"; - ralink,function = "uart1"; + group = "uart1"; + function = "uart1"; }; }; uart2_pins: uart2 { uart2 { - ralink,group = "uart2"; - ralink,function = "uart2"; + group = "uart2"; + function = "uart2"; }; }; uart3_pins: uart3 { uart3 { - ralink,group = "uart3"; - ralink,function = "uart3"; + group = "uart3"; + function = "uart3"; }; }; rgmii1_pins: rgmii1 { rgmii1 { - ralink,group = "rgmii1"; - ralink,function = "rgmii1"; + group = "rgmii1"; + function = "rgmii1"; }; }; rgmii2_pins: rgmii2 { rgmii2 { - ralink,group = "rgmii2"; - ralink,function = "rgmii2"; + group = "rgmii2"; + function = "rgmii2"; }; }; mdio_pins: mdio { mdio { - ralink,group = "mdio"; - ralink,function = "mdio"; + group = "mdio"; + function = "mdio"; }; }; pcie_pins: pcie { pcie { - ralink,group = "pcie"; - ralink,function = "pcie rst"; + group = "pcie"; + function = "pcie rst"; }; }; nand_pins: nand { spi-nand { - ralink,group = "spi"; - ralink,function = "nand1"; + group = "spi"; + function = "nand1"; }; sdhci-nand { - ralink,group = "sdhci"; - ralink,function = "nand2"; + group = "sdhci"; + function = "nand2"; }; }; sdhci_pins: sdhci { sdhci { - ralink,group = "sdhci"; - ralink,function = "sdhci"; + group = "sdhci"; + function = "sdhci"; }; }; }; From e12a1a6e087b9803befc6e9ab47734716c3e20e2 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:06 +0200 Subject: [PATCH 238/903] staging: mt7621-pinctrl: refactor rt2880_pinctrl_dt_node_to_map function Using 'function' and 'group' bindings in the device tree give the posibility of refactor 'rt2880_pinctrl_dt_node_to_map' and simplify it a lot. Make use of 'for_each_node_with_property' function to count number of groups for the node and iterate over the groups using 'of_property_for_each_string' calling 'pinctrl_utils_add_map_mux' function which is the same of the custom function in this driver code 'rt2880_pinctrl_dt_subnode_to_map' which is not needed anymore. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- .../staging/mt7621-pinctrl/pinctrl-rt2880.c | 58 +++++-------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 8a196d357e0f..c022718d8000 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -83,65 +83,37 @@ static void rt2880_pinctrl_pin_dbg_show(struct pinctrl_dev *pctrldev, seq_puts(s, "ralink pio"); } -static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev, - struct device_node *np, - struct pinctrl_map **map) -{ - const char *function; - int func = of_property_read_string(np, "ralink,function", &function); - int grps = of_property_count_strings(np, "ralink,group"); - int i; - - if (func || !grps) - return; - - for (i = 0; i < grps; i++) { - const char *group; - - of_property_read_string_index(np, "ralink,group", i, &group); - - (*map)->type = PIN_MAP_TYPE_MUX_GROUP; - (*map)->name = function; - (*map)->data.mux.group = group; - (*map)->data.mux.function = function; - (*map)++; - } -} - static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, struct device_node *np_config, struct pinctrl_map **map, unsigned int *num_maps) { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); + struct property *prop; + const char *function_name, *group_name; int ret; - int max_maps = 0; + int ngroups; unsigned int reserved_maps = 0; - struct pinctrl_map *tmp; - struct device_node *np; - for_each_child_of_node(np_config, np) { - int ret = of_property_count_strings(np, "ralink,group"); - - if (ret >= 0) - max_maps += ret; - } - - if (!max_maps) - return max_maps; + for_each_node_with_property(np_config, "group") + ngroups++; ret = pinctrl_utils_reserve_map(pctrldev, map, &reserved_maps, - num_maps, max_maps); + num_maps, ngroups); if (ret) { dev_err(p->dev, "can't reserve map: %d\n", ret); return ret; } - tmp = *map; - - for_each_child_of_node(np_config, np) - rt2880_pinctrl_dt_subnode_to_map(pctrldev, np, &tmp); - *num_maps = max_maps; + of_property_for_each_string(np_config, "group", prop, group_name) { + ret = pinctrl_utils_add_map_mux(pctrldev, map, &reserved_maps, + num_maps, group_name, + function_name); + if (ret) { + dev_err(p->dev, "can't add map: %d\n", ret); + return ret; + } + } return 0; } From 74ee97cc05110a8421fe554506309fe071103654 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:07 +0200 Subject: [PATCH 239/903] staging: mt7621-pinctrl: use ternary operator return in rt2880_get_group_name Trivial change to have only one return in 'rt2880_get_group_name' function using a ternary operator instead of an if statement and two returns. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index c022718d8000..a15e8e8c0ed1 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -54,10 +54,7 @@ static const char *rt2880_get_group_name(struct pinctrl_dev *pctrldev, { struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev); - if (group >= p->group_count) - return NULL; - - return p->group_names[group]; + return (group >= p->group_count) ? NULL : p->group_names[group]; } static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev, From b595818682bd7160266015555ea773296312c0e9 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:08 +0200 Subject: [PATCH 240/903] staging: mt7621-pinctrl: remove 'rt2880_pinctrl_pin_dbg_show' callback The debug information provided by this function does not make sense at all, so just remove it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index a15e8e8c0ed1..2cce2123d819 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -73,13 +73,6 @@ static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev, return 0; } -static void rt2880_pinctrl_pin_dbg_show(struct pinctrl_dev *pctrldev, - struct seq_file *s, - unsigned int offset) -{ - seq_puts(s, "ralink pio"); -} - static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, struct device_node *np_config, struct pinctrl_map **map, @@ -119,7 +112,6 @@ static const struct pinctrl_ops rt2880_pctrl_ops = { .get_groups_count = rt2880_get_group_count, .get_group_name = rt2880_get_group_name, .get_group_pins = rt2880_get_group_pins, - .pin_dbg_show = rt2880_pinctrl_pin_dbg_show, .dt_node_to_map = rt2880_pinctrl_dt_node_to_map, .dt_free_map = pinctrl_utils_free_map, }; From 7383f87de80694f1f4c21b81b964d42a54144cfb Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 28 Jun 2018 21:03:09 +0200 Subject: [PATCH 241/903] staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver We don't really need initialization of this at such an early stage. Just use builtin_platform_driver to initialize this driver. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 2cce2123d819..70259425e7e9 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -422,9 +422,4 @@ static struct platform_driver rt2880_pinmux_driver = { }, }; -int __init rt2880_pinmux_init(void) -{ - return platform_driver_register(&rt2880_pinmux_driver); -} - -core_initcall_sync(rt2880_pinmux_init); +builtin_platform_driver(rt2880_pinmux_driver); From 9f2378d94d0f026389fff351848f2adc484650fe Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 4 Jul 2018 10:31:25 -0700 Subject: [PATCH 242/903] drivers/staging/gasket: Use 2-factor allocator calls As already done treewide, switch from open-coded multiplication to using 2-factor allocator helpers. Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 6 +++--- drivers/staging/gasket/gasket_interrupt.c | 15 +++++++++------ drivers/staging/gasket/gasket_page_table.c | 6 +++--- drivers/staging/gasket/gasket_sysfs.c | 12 ++++++------ 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 6511a33eb658..82b3eca7774e 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1697,9 +1697,9 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) return -EPERM; } num_map_regions = bar_desc->num_mappable_regions; - map_regions = kzalloc( - num_map_regions * sizeof(*bar_desc->mappable_regions), - GFP_KERNEL); + map_regions = kcalloc(num_map_regions, + sizeof(*bar_desc->mappable_regions), + GFP_KERNEL); if (map_regions) { memcpy(map_regions, bar_desc->mappable_regions, num_map_regions * diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index b74eefe41d72..1fd7bee5db2f 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -136,23 +136,26 @@ int gasket_interrupt_init( interrupt_data->wire_interrupt_offsets = wire_int_offsets; /* Allocate all dynamic structures. */ - interrupt_data->msix_entries = kzalloc( - sizeof(struct msix_entry) * num_interrupts, GFP_KERNEL); + interrupt_data->msix_entries = kcalloc(num_interrupts, + sizeof(struct msix_entry), + GFP_KERNEL); if (!interrupt_data->msix_entries) { kfree(interrupt_data); return -ENOMEM; } - interrupt_data->eventfd_ctxs = kzalloc( - sizeof(struct eventfd_ctx *) * num_interrupts, GFP_KERNEL); + interrupt_data->eventfd_ctxs = kcalloc(num_interrupts, + sizeof(struct eventfd_ctx *), + GFP_KERNEL); if (!interrupt_data->eventfd_ctxs) { kfree(interrupt_data->msix_entries); kfree(interrupt_data); return -ENOMEM; } - interrupt_data->interrupt_counts = kzalloc( - sizeof(ulong) * num_interrupts, GFP_KERNEL); + interrupt_data->interrupt_counts = kcalloc(num_interrupts, + sizeof(ulong), + GFP_KERNEL); if (!interrupt_data->interrupt_counts) { kfree(interrupt_data->eventfd_ctxs); kfree(interrupt_data->msix_entries); diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 6dc10508b15e..c5390a860f86 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1674,9 +1674,9 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, gasket_dev->page_table[index]->num_coherent_pages = num_pages; /* allocate the physical memory block */ - gasket_dev->page_table[index]->coherent_pages = kzalloc( - num_pages * sizeof(struct gasket_coherent_page_entry), - GFP_KERNEL); + gasket_dev->page_table[index]->coherent_pages = + kcalloc(num_pages, sizeof(struct gasket_coherent_page_entry), + GFP_KERNEL); if (!gasket_dev->page_table[index]->coherent_pages) goto nomem; *dma_address = 0; diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index d45098c90b4b..40268fb50fc3 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -137,9 +137,9 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) device = mapping->device; legacy_device = mapping->legacy_device; num_files_to_remove = mapping->attribute_count; - files_to_remove = kzalloc( - num_files_to_remove * sizeof(*files_to_remove), - GFP_KERNEL); + files_to_remove = kcalloc(num_files_to_remove, + sizeof(*files_to_remove), + GFP_KERNEL); for (i = 0; i < num_files_to_remove; i++) files_to_remove[i] = mapping->attributes[i].attr; @@ -238,9 +238,9 @@ int gasket_sysfs_create_mapping( kref_init(&mapping->refcount); mapping->device = device; mapping->gasket_dev = gasket_dev; - mapping->attributes = kzalloc( - GASKET_SYSFS_MAX_NODES * sizeof(*mapping->attributes), - GFP_KERNEL); + mapping->attributes = kcalloc(GASKET_SYSFS_MAX_NODES, + sizeof(*mapping->attributes), + GFP_KERNEL); mapping->attribute_count = 0; if (!mapping->attributes) { gasket_nodev_error("Unable to allocate sysfs attribute array."); From 97b23455ccd53a632585d0fd06ff9d30877c810a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 6 Jul 2018 11:37:56 +0300 Subject: [PATCH 243/903] Staging: Gasket: uninitialized return in gasket_mmap() We forgot to set the error code on this error path so ret can be uninitialized. Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 82b3eca7774e..ad9442a5bb9d 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1719,8 +1719,10 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) /* Try the next region if this one was not mappable. */ if (map_status == DO_MAP_REGION_INVALID) continue; - if (map_status == DO_MAP_REGION_FAILURE) + if (map_status == DO_MAP_REGION_FAILURE) { + ret = -ENOMEM; goto fail; + } has_mapped_anything = 1; } From 7cc6dfd076e84359a96a851c41ac8dc696565a3f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 6 Jul 2018 11:38:25 +0300 Subject: [PATCH 244/903] Staging: Gasket: fix a couple off by one bugs The > should be >= or we end up writing one element beyond the end of the interrupt_data->eventfd_ctxs[] array. Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 1fd7bee5db2f..d1461b36f091 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -514,7 +514,7 @@ int gasket_interrupt_set_eventfd( if (IS_ERR(ctx)) return PTR_ERR(ctx); - if (interrupt < 0 || interrupt > interrupt_data->num_interrupts) + if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts) return -EINVAL; interrupt_data->eventfd_ctxs[interrupt] = ctx; @@ -524,7 +524,7 @@ int gasket_interrupt_set_eventfd( int gasket_interrupt_clear_eventfd( struct gasket_interrupt_data *interrupt_data, int interrupt) { - if (interrupt < 0 || interrupt > interrupt_data->num_interrupts) + if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts) return -EINVAL; interrupt_data->eventfd_ctxs[interrupt] = NULL; From c37a192ef442fc34e9aa7c9e479f20eb4cd6f7af Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 6 Jul 2018 11:39:21 +0300 Subject: [PATCH 245/903] Staging: Gasket: shift wrapping bug in gasket_read_modify_write_64() This function only has one caller so mask_width is 1 and mask_shift is 32. Shifting an int by 32 bits is undefined, but I guess on GCC it wraps to 0x1? Anyway it's supposed to be 0x100000000. Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 203b9a31377b..5d6535a0f254 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -683,7 +683,7 @@ static inline void gasket_read_modify_write_64( u64 mask, tmp; tmp = gasket_dev_read_64(dev, bar, location); - mask = ((1 << mask_width) - 1) << mask_shift; + mask = ((1ULL << mask_width) - 1) << mask_shift; tmp = (tmp & ~mask) | (value << mask_shift); gasket_dev_write_64(dev, tmp, bar, location); } From c5fae4f4fd28189b1062fb8ef7b21fec37cb8b17 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 2 Jul 2018 14:27:35 +0100 Subject: [PATCH 246/903] staging: rts5208: fix missing error check on call to rtsx_write_register Currently the check on error return from the call to rtsx_write_register is checking the error status from the previous call. Fix this by adding in the missing assignment of retval. Detected by CoverityScan, CID#709877 Fixes: fa590c222fba ("staging: rts5208: add support for rts5208 and rts5288") Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c index f2778abf10c0..e7efa34195c7 100644 --- a/drivers/staging/rts5208/sd.c +++ b/drivers/staging/rts5208/sd.c @@ -4690,7 +4690,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) goto sd_execute_write_cmd_failed; } - rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); + retval = rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); if (retval != STATUS_SUCCESS) { goto sd_execute_write_cmd_failed; } From 8602ffc65887d558198b742920f5569ec3a6a1a8 Mon Sep 17 00:00:00 2001 From: Razvan Stefanescu Date: Wed, 4 Jul 2018 11:17:44 +0300 Subject: [PATCH 247/903] staging: fsl-dpaa2/ethsw: Update maintainers for Ethernet Switch driver Removing myself as the maintainer for this driver and adding Ioana R. and Ioana C. Signed-off-by: Razvan Stefanescu Acked-by: Ioana Radulescu Acked-by: Ioana Ciornei Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index b6d0cc0f5374..0d36546fc61c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4434,7 +4434,8 @@ S: Maintained F: drivers/staging/fsl-dpaa2/ethernet DPAA2 ETHERNET SWITCH DRIVER -M: Razvan Stefanescu +M: Ioana Radulescu +M: Ioana Ciornei L: linux-kernel@vger.kernel.org S: Maintained F: drivers/staging/fsl-dpaa2/ethsw From 9b227cb1cf28464144fe4054f0c0fadf471649cb Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 2 Jul 2018 21:35:07 +0200 Subject: [PATCH 248/903] staging: rtl8188eu: remove rtw_mp_phy_regdef.h The header rtw_mp_phy_regdef.h is not used anywhere. 'git grep rtw_mp_phy_regdef.h' returns nothing, remove the file. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../rtl8188eu/include/rtw_mp_phy_regdef.h | 1078 ----------------- 1 file changed, 1078 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h diff --git a/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h b/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h deleted file mode 100644 index 9276e2321f2a..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h +++ /dev/null @@ -1,1078 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -/***************************************************************************** - * - * Module: __RTW_MP_PHY_REGDEF_H_ - * - * - * Note: 1. Define PMAC/BB register map - * 2. Define RF register map - * 3. PMAC/BB register bit mask. - * 4. RF reg bit mask. - * 5. Other BB/RF relative definition. - * - * - * Export: Constants, macro, functions(API), global variables(None). - * - * Abbrev: - * - * History: - * Data Who Remark - * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h. - * 2. Reorganize code architecture. - * 09/25/2008 MH 1. Add RL6052 register definition - * - *****************************************************************************/ -#ifndef __RTW_MP_PHY_REGDEF_H_ -#define __RTW_MP_PHY_REGDEF_H_ - - -/*--------------------------Define Parameters-------------------------------*/ - -/* */ -/* 8192S Regsiter offset definition */ -/* */ - -/* */ -/* BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */ -/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ -/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */ -/* 3. RF register 0x00-2E */ -/* 4. Bit Mask for BB/RF register */ -/* 5. Other definition for BB/RF R/W */ -/* */ - - -/* */ -/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ -/* 1. Page1(0x100) */ -/* */ -#define rPMAC_Reset 0x100 -#define rPMAC_TxStart 0x104 -#define rPMAC_TxLegacySIG 0x108 -#define rPMAC_TxHTSIG1 0x10c -#define rPMAC_TxHTSIG2 0x110 -#define rPMAC_PHYDebug 0x114 -#define rPMAC_TxPacketNum 0x118 -#define rPMAC_TxIdle 0x11c -#define rPMAC_TxMACHeader0 0x120 -#define rPMAC_TxMACHeader1 0x124 -#define rPMAC_TxMACHeader2 0x128 -#define rPMAC_TxMACHeader3 0x12c -#define rPMAC_TxMACHeader4 0x130 -#define rPMAC_TxMACHeader5 0x134 -#define rPMAC_TxDataType 0x138 -#define rPMAC_TxRandomSeed 0x13c -#define rPMAC_CCKPLCPPreamble 0x140 -#define rPMAC_CCKPLCPHeader 0x144 -#define rPMAC_CCKCRC16 0x148 -#define rPMAC_OFDMRxCRC32OK 0x170 -#define rPMAC_OFDMRxCRC32Er 0x174 -#define rPMAC_OFDMRxParityEr 0x178 -#define rPMAC_OFDMRxCRC8Er 0x17c -#define rPMAC_CCKCRxRC16Er 0x180 -#define rPMAC_CCKCRxRC32Er 0x184 -#define rPMAC_CCKCRxRC32OK 0x188 -#define rPMAC_TxStatus 0x18c - -/* */ -/* 2. Page2(0x200) */ -/* */ -/* The following two definition are only used for USB interface. */ -/* define RF_BB_CMD_ADDR 0x02c0 RF/BB read/write command address. */ -/* define RF_BB_CMD_DATA 0x02c4 RF/BB read/write command data. */ - -/* */ -/* 3. Page8(0x800) */ -/* */ -#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC RF BW Setting?? */ - -#define rFPGA0_TxInfo 0x804 /* Status report?? */ -#define rFPGA0_PSDFunction 0x808 - -#define rFPGA0_TxGainStage 0x80c /* Set TX PWR init gain? */ - -#define rFPGA0_RFTiming1 0x810 /* Useless now */ -#define rFPGA0_RFTiming2 0x814 -/* define rFPGA0_XC_RFTiming 0x818 */ -/* define rFPGA0_XD_RFTiming 0x81c */ - -#define rFPGA0_XA_HSSIParameter1 0x820 /* RF 3 wire register */ -#define rFPGA0_XA_HSSIParameter2 0x824 -#define rFPGA0_XB_HSSIParameter1 0x828 -#define rFPGA0_XB_HSSIParameter2 0x82c -#define rFPGA0_XC_HSSIParameter1 0x830 -#define rFPGA0_XC_HSSIParameter2 0x834 -#define rFPGA0_XD_HSSIParameter1 0x838 -#define rFPGA0_XD_HSSIParameter2 0x83c -#define rFPGA0_XA_LSSIParameter 0x840 -#define rFPGA0_XB_LSSIParameter 0x844 -#define rFPGA0_XC_LSSIParameter 0x848 -#define rFPGA0_XD_LSSIParameter 0x84c - -#define rFPGA0_RFWakeUpParameter 0x850 /* Useless now */ -#define rFPGA0_RFSleepUpParameter 0x854 - -#define rFPGA0_XAB_SwitchControl 0x858 /* RF Channel switch */ -#define rFPGA0_XCD_SwitchControl 0x85c - -#define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */ -#define rFPGA0_XB_RFInterfaceOE 0x864 -#define rFPGA0_XC_RFInterfaceOE 0x868 -#define rFPGA0_XD_RFInterfaceOE 0x86c - -#define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Interface Software Control */ -#define rFPGA0_XCD_RFInterfaceSW 0x874 - -#define rFPGA0_XAB_RFParameter 0x878 /* RF Parameter */ -#define rFPGA0_XCD_RFParameter 0x87c - -#define rFPGA0_AnalogParameter1 0x880 /* Crystal cap setting RF-R/W protection for parameter4?? */ -#define rFPGA0_AnalogParameter2 0x884 -#define rFPGA0_AnalogParameter3 0x888 /* Useless now */ -#define rFPGA0_AnalogParameter4 0x88c - -#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */ -#define rFPGA0_XB_LSSIReadBack 0x8a4 -#define rFPGA0_XC_LSSIReadBack 0x8a8 -#define rFPGA0_XD_LSSIReadBack 0x8ac - -#define rFPGA0_PSDReport 0x8b4 /* Useless now */ -#define rFPGA0_XAB_RFInterfaceRB 0x8e0 /* Useless now RF Interface Readback Value */ -#define rFPGA0_XCD_RFInterfaceRB 0x8e4 /* Useless now */ - -/* */ -/* 4. Page9(0x900) */ -/* */ -#define rFPGA1_RFMOD 0x900 /* RF mode & OFDM TxSC RF BW Setting?? */ - -#define rFPGA1_TxBlock 0x904 /* Useless now */ -#define rFPGA1_DebugSelect 0x908 /* Useless now */ -#define rFPGA1_TxInfo 0x90c /* Useless now Status report?? */ - -/* */ -/* 5. PageA(0xA00) */ -/* */ -/* Set Control channel to upper or lower. These settings are required only for 40MHz */ -#define rCCK0_System 0xa00 - -#define rCCK0_AFESetting 0xa04 /* Disable init gain now Select RX path by RSSI */ -#define rCCK0_CCA 0xa08 /* Disable init gain now Init gain */ - -#define rCCK0_RxAGC1 0xa0c /* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold, RX LNA Threshold useless now. Not the same as 90 series */ -#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ - -#define rCCK0_RxHP 0xa14 - -#define rCCK0_DSPParameter1 0xa18 /* Timing recovery & Channel estimation threshold */ -#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */ - -#define rCCK0_TxFilter1 0xa20 -#define rCCK0_TxFilter2 0xa24 -#define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */ -#define rCCK0_FalseAlarmReport 0xa2c /* 0xa2d useless now 0xa30-a4f channel report */ -#define rCCK0_TRSSIReport 0xa50 -#define rCCK0_RxReport 0xa54 /* 0xa57 */ -#define rCCK0_FACounterLower 0xa5c /* 0xa5b */ -#define rCCK0_FACounterUpper 0xa58 /* 0xa5c */ - -/* */ -/* 6. PageC(0xC00) */ -/* */ -#define rOFDM0_LSTF 0xc00 - -#define rOFDM0_TRxPathEnable 0xc04 -#define rOFDM0_TRMuxPar 0xc08 -#define rOFDM0_TRSWIsolation 0xc0c - -#define rOFDM0_XARxAFE 0xc10 /* RxIQ DC offset, Rx digital filter, DC notch filter */ -#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */ -#define rOFDM0_XBRxAFE 0xc18 -#define rOFDM0_XBRxIQImbalance 0xc1c -#define rOFDM0_XCRxAFE 0xc20 -#define rOFDM0_XCRxIQImbalance 0xc24 -#define rOFDM0_XDRxAFE 0xc28 -#define rOFDM0_XDRxIQImbalance 0xc2c - -#define rOFDM0_RxDetector1 0xc30 /* PD,BW & SBD DM tune init gain */ -#define rOFDM0_RxDetector2 0xc34 /* SBD & Fame Sync. */ -#define rOFDM0_RxDetector3 0xc38 /* Frame Sync. */ -#define rOFDM0_RxDetector4 0xc3c /* PD, SBD, Frame Sync & Short-GI */ - -#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ -#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */ -#define rOFDM0_CCADropThreshold 0xc48 /* CCA Drop threshold */ -#define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */ - -#define rOFDM0_XAAGCCore1 0xc50 /* DIG */ -#define rOFDM0_XAAGCCore2 0xc54 -#define rOFDM0_XBAGCCore1 0xc58 -#define rOFDM0_XBAGCCore2 0xc5c -#define rOFDM0_XCAGCCore1 0xc60 -#define rOFDM0_XCAGCCore2 0xc64 -#define rOFDM0_XDAGCCore1 0xc68 -#define rOFDM0_XDAGCCore2 0xc6c - -#define rOFDM0_AGCParameter1 0xc70 -#define rOFDM0_AGCParameter2 0xc74 -#define rOFDM0_AGCRSSITable 0xc78 -#define rOFDM0_HTSTFAGC 0xc7c - -#define rOFDM0_XATxIQImbalance 0xc80 /* TX PWR TRACK and DIG */ -#define rOFDM0_XATxAFE 0xc84 -#define rOFDM0_XBTxIQImbalance 0xc88 -#define rOFDM0_XBTxAFE 0xc8c -#define rOFDM0_XCTxIQImbalance 0xc90 -#define rOFDM0_XCTxAFE 0xc94 -#define rOFDM0_XDTxIQImbalance 0xc98 -#define rOFDM0_XDTxAFE 0xc9c -#define rOFDM0_RxIQExtAnta 0xca0 - -#define rOFDM0_RxHPParameter 0xce0 -#define rOFDM0_TxPseudoNoiseWgt 0xce4 -#define rOFDM0_FrameSync 0xcf0 -#define rOFDM0_DFSReport 0xcf4 -#define rOFDM0_TxCoeff1 0xca4 -#define rOFDM0_TxCoeff2 0xca8 -#define rOFDM0_TxCoeff3 0xcac -#define rOFDM0_TxCoeff4 0xcb0 -#define rOFDM0_TxCoeff5 0xcb4 -#define rOFDM0_TxCoeff6 0xcb8 - -/* 7. PageD(0xD00) */ -#define rOFDM1_LSTF 0xd00 -#define rOFDM1_TRxPathEnable 0xd04 - -#define rOFDM1_CFO 0xd08 /* No setting now */ -#define rOFDM1_CSI1 0xd10 -#define rOFDM1_SBD 0xd14 -#define rOFDM1_CSI2 0xd18 -#define rOFDM1_CFOTracking 0xd2c -#define rOFDM1_TRxMesaure1 0xd34 -#define rOFDM1_IntfDet 0xd3c -#define rOFDM1_PseudoNoiseStateAB 0xd50 -#define rOFDM1_PseudoNoiseStateCD 0xd54 -#define rOFDM1_RxPseudoNoiseWgt 0xd58 - -#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */ -#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */ -#define rOFDM_PHYCounter3 0xda8 /* MCS not support */ - -#define rOFDM_ShortCFOAB 0xdac /* No setting now */ -#define rOFDM_ShortCFOCD 0xdb0 -#define rOFDM_LongCFOAB 0xdb4 -#define rOFDM_LongCFOCD 0xdb8 -#define rOFDM_TailCFOAB 0xdbc -#define rOFDM_TailCFOCD 0xdc0 -#define rOFDM_PWMeasure1 0xdc4 -#define rOFDM_PWMeasure2 0xdc8 -#define rOFDM_BWReport 0xdcc -#define rOFDM_AGCReport 0xdd0 -#define rOFDM_RxSNR 0xdd4 -#define rOFDM_RxEVMCSI 0xdd8 -#define rOFDM_SIGReport 0xddc - - -/* */ -/* 8. PageE(0xE00) */ -/* */ -#define rTxAGC_Rate18_06 0xe00 -#define rTxAGC_Rate54_24 0xe04 -#define rTxAGC_CCK_Mcs32 0xe08 -#define rTxAGC_Mcs03_Mcs00 0xe10 -#define rTxAGC_Mcs07_Mcs04 0xe14 -#define rTxAGC_Mcs11_Mcs08 0xe18 -#define rTxAGC_Mcs15_Mcs12 0xe1c - -/* Analog- control in RX_WAIT_CCA : REG: EE0 [Analog- Power & Control Register] */ -#define rRx_Wait_CCCA 0xe70 -#define rAnapar_Ctrl_BB 0xee0 - -/* */ -/* 7. RF Register 0x00-0x2E (RF 8256) */ -/* RF-0222D 0x00-3F */ -/* */ -/* Zebra1 */ -#define RTL92SE_FPGA_VERIFY 0 -#define rZebra1_HSSIEnable 0x0 /* Useless now */ -#define rZebra1_TRxEnable1 0x1 -#define rZebra1_TRxEnable2 0x2 -#define rZebra1_AGC 0x4 -#define rZebra1_ChargePump 0x5 -/* if (RTL92SE_FPGA_VERIFY == 1) */ -#define rZebra1_Channel 0x7 /* RF channel switch */ -/* else */ - -/* endif */ -#define rZebra1_TxGain 0x8 /* Useless now */ -#define rZebra1_TxLPF 0x9 -#define rZebra1_RxLPF 0xb -#define rZebra1_RxHPFCorner 0xc - -/* Zebra4 */ -#define rGlobalCtrl 0 /* Useless now */ -#define rRTL8256_TxLPF 19 -#define rRTL8256_RxLPF 11 - -/* RTL8258 */ -#define rRTL8258_TxLPF 0x11 /* Useless now */ -#define rRTL8258_RxLPF 0x13 -#define rRTL8258_RSSILPF 0xa - -/* */ -/* RL6052 Register definition */ -#define RF_AC 0x00 /* */ - -#define RF_IQADJ_G1 0x01 /* */ -#define RF_IQADJ_G2 0x02 /* */ -#define RF_POW_TRSW 0x05 /* */ - -#define RF_GAIN_RX 0x06 /* */ -#define RF_GAIN_TX 0x07 /* */ - -#define RF_TXM_IDAC 0x08 /* */ -#define RF_BS_IQGEN 0x0F /* */ - -#define RF_MODE1 0x10 /* */ -#define RF_MODE2 0x11 /* */ - -#define RF_RX_AGC_HP 0x12 /* */ -#define RF_TX_AGC 0x13 /* */ -#define RF_BIAS 0x14 /* */ -#define RF_IPA 0x15 /* */ -#define RF_TXBIAS 0x16 /* */ -#define RF_POW_ABILITY 0x17 /* */ -#define RF_MODE_AG 0x18 /* */ -#define rRfChannel 0x18 /* RF channel and BW switch */ -#define RF_CHNLBW 0x18 /* RF channel and BW switch */ -#define RF_TOP 0x19 /* */ - -#define RF_RX_G1 0x1A /* */ -#define RF_RX_G2 0x1B /* */ - -#define RF_RX_BB2 0x1C /* */ -#define RF_RX_BB1 0x1D /* */ - -#define RF_RCK1 0x1E /* */ -#define RF_RCK2 0x1F /* */ - -#define RF_TX_G1 0x20 /* */ -#define RF_TX_G2 0x21 /* */ -#define RF_TX_G3 0x22 /* */ - -#define RF_TX_BB1 0x23 /* */ - -#define RF_T_METER 0x24 /* */ - -#define RF_SYN_G1 0x25 /* RF TX Power control */ -#define RF_SYN_G2 0x26 /* RF TX Power control */ -#define RF_SYN_G3 0x27 /* RF TX Power control */ -#define RF_SYN_G4 0x28 /* RF TX Power control */ -#define RF_SYN_G5 0x29 /* RF TX Power control */ -#define RF_SYN_G6 0x2A /* RF TX Power control */ -#define RF_SYN_G7 0x2B /* RF TX Power control */ -#define RF_SYN_G8 0x2C /* RF TX Power control */ - -#define RF_RCK_OS 0x30 /* RF TX PA control */ -#define RF_TXPA_G1 0x31 /* RF TX PA control */ -#define RF_TXPA_G2 0x32 /* RF TX PA control */ -#define RF_TXPA_G3 0x33 /* RF TX PA control */ - -/* */ -/* Bit Mask */ -/* */ -/* 1. Page1(0x100) */ -#define bBBResetB 0x100 /* Useless now? */ -#define bGlobalResetB 0x200 -#define bOFDMTxStart 0x4 -#define bCCKTxStart 0x8 -#define bCRC32Debug 0x100 -#define bPMACLoopback 0x10 -#define bTxLSIG 0xffffff -#define bOFDMTxRate 0xf -#define bOFDMTxReserved 0x10 -#define bOFDMTxLength 0x1ffe0 -#define bOFDMTxParity 0x20000 -#define bTxHTSIG1 0xffffff -#define bTxHTMCSRate 0x7f -#define bTxHTBW 0x80 -#define bTxHTLength 0xffff00 -#define bTxHTSIG2 0xffffff -#define bTxHTSmoothing 0x1 -#define bTxHTSounding 0x2 -#define bTxHTReserved 0x4 -#define bTxHTAggreation 0x8 -#define bTxHTSTBC 0x30 -#define bTxHTAdvanceCoding 0x40 -#define bTxHTShortGI 0x80 -#define bTxHTNumberHT_LTF 0x300 -#define bTxHTCRC8 0x3fc00 -#define bCounterReset 0x10000 -#define bNumOfOFDMTx 0xffff -#define bNumOfCCKTx 0xffff0000 -#define bTxIdleInterval 0xffff -#define bOFDMService 0xffff0000 -#define bTxMACHeader 0xffffffff -#define bTxDataInit 0xff -#define bTxHTMode 0x100 -#define bTxDataType 0x30000 -#define bTxRandomSeed 0xffffffff -#define bCCKTxPreamble 0x1 -#define bCCKTxSFD 0xffff0000 -#define bCCKTxSIG 0xff -#define bCCKTxService 0xff00 -#define bCCKLengthExt 0x8000 -#define bCCKTxLength 0xffff0000 -#define bCCKTxCRC16 0xffff -#define bCCKTxStatus 0x1 -#define bOFDMTxStatus 0x2 - -#define IS_BB_REG_OFFSET_92S(_Offset) ((_Offset >= 0x800) && (_Offset <= 0xfff)) - -/* 2. Page8(0x800) */ -#define bRFMOD 0x1 /* Reg 0x800 rFPGA0_RFMOD */ -#define bJapanMode 0x2 -#define bCCKTxSC 0x30 -#define bCCKEn 0x1000000 -#define bOFDMEn 0x2000000 - -#define bOFDMRxADCPhase 0x10000 /* Useless now */ -#define bOFDMTxDACPhase 0x40000 -#define bXATxAGC 0x3f - -#define bXBTxAGC 0xf00 /* Reg 80c rFPGA0_TxGainStage */ -#define bXCTxAGC 0xf000 -#define bXDTxAGC 0xf0000 - -#define bPAStart 0xf0000000 /* Useless now */ -#define bTRStart 0x00f00000 -#define bRFStart 0x0000f000 -#define bBBStart 0x000000f0 -#define bBBCCKStart 0x0000000f -#define bPAEnd 0xf /* Reg0x814 */ -#define bTREnd 0x0f000000 -#define bRFEnd 0x000f0000 -#define bCCAMask 0x000000f0 /* T2R */ -#define bR2RCCAMask 0x00000f00 -#define bHSSI_R2TDelay 0xf8000000 -#define bHSSI_T2RDelay 0xf80000 -#define bContTxHSSI 0x400 /* chane gain at continue Tx */ -#define bIGFromCCK 0x200 -#define bAGCAddress 0x3f -#define bRxHPTx 0x7000 -#define bRxHPT2R 0x38000 -#define bRxHPCCKIni 0xc0000 -#define bAGCTxCode 0xc00000 -#define bAGCRxCode 0x300000 - -#define b3WireDataLength 0x800 /* Reg 0x820~84f rFPGA0_XA_HSSIParameter1 */ -#define b3WireAddressLength 0x400 - -#define b3WireRFPowerDown 0x1 /* Useless now */ -/* define bHWSISelect 0x8 */ -#define b5GPAPEPolarity 0x40000000 -#define b2GPAPEPolarity 0x80000000 -#define bRFSW_TxDefaultAnt 0x3 -#define bRFSW_TxOptionAnt 0x30 -#define bRFSW_RxDefaultAnt 0x300 -#define bRFSW_RxOptionAnt 0x3000 -#define bRFSI_3WireData 0x1 -#define bRFSI_3WireClock 0x2 -#define bRFSI_3WireLoad 0x4 -#define bRFSI_3WireRW 0x8 -#define bRFSI_3Wire 0xf - -#define bRFSI_RFENV 0x10 /* Reg 0x870 rFPGA0_XAB_RFInterfaceSW */ - -#define bRFSI_TRSW 0x20 /* Useless now */ -#define bRFSI_TRSWB 0x40 -#define bRFSI_ANTSW 0x100 -#define bRFSI_ANTSWB 0x200 -#define bRFSI_PAPE 0x400 -#define bRFSI_PAPE5G 0x800 -#define bBandSelect 0x1 -#define bHTSIG2_GI 0x80 -#define bHTSIG2_Smoothing 0x01 -#define bHTSIG2_Sounding 0x02 -#define bHTSIG2_Aggreaton 0x08 -#define bHTSIG2_STBC 0x30 -#define bHTSIG2_AdvCoding 0x40 -#define bHTSIG2_NumOfHTLTF 0x300 -#define bHTSIG2_CRC8 0x3fc -#define bHTSIG1_MCS 0x7f -#define bHTSIG1_BandWidth 0x80 -#define bHTSIG1_HTLength 0xffff -#define bLSIG_Rate 0xf -#define bLSIG_Reserved 0x10 -#define bLSIG_Length 0x1fffe -#define bLSIG_Parity 0x20 -#define bCCKRxPhase 0x4 -#if (RTL92SE_FPGA_VERIFY == 1) -#define bLSSIReadAddress 0x3f000000 /* LSSI "Read" Address - * Reg 0x824 rFPGA0_XA_HSSIParameter2 - */ -#else -#define bLSSIReadAddress 0x7f800000 /* T65 RF */ -#endif -#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ -#if (RTL92SE_FPGA_VERIFY == 1) -#define bLSSIReadBackData 0xfff /* Reg 0x8a0 - * rFPGA0_XA_LSSIReadBack - */ -#else -#define bLSSIReadBackData 0xfffff /* T65 RF */ -#endif -#define bLSSIReadOKFlag 0x1000 /* Useless now */ -#define bCCKSampleRate 0x8 /* 0: 44MHz, 1:88MHz */ -#define bRegulator0Standby 0x1 -#define bRegulatorPLLStandby 0x2 -#define bRegulator1Standby 0x4 -#define bPLLPowerUp 0x8 -#define bDPLLPowerUp 0x10 -#define bDA10PowerUp 0x20 -#define bAD7PowerUp 0x200 -#define bDA6PowerUp 0x2000 -#define bXtalPowerUp 0x4000 -#define b40MDClkPowerUP 0x8000 -#define bDA6DebugMode 0x20000 -#define bDA6Swing 0x380000 - -#define bADClkPhase 0x4000000 /* Reg 0x880 - * rFPGA0_AnalogParameter1 20/40 CCK - * support switch 40/80 BB MHZ - */ - -#define b80MClkDelay 0x18000000 /* Useless */ -#define bAFEWatchDogEnable 0x20000000 - -#define bXtalCap01 0xc0000000 /* Reg 0x884 - * rFPGA0_AnalogParameter2 Crystal cap - */ -#define bXtalCap23 0x3 -#define bXtalCap92x 0x0f000000 -#define bXtalCap 0x0f000000 - -#define bIntDifClkEnable 0x400 /* Useless */ -#define bExtSigClkEnable 0x800 -#define bBandgapMbiasPowerUp 0x10000 -#define bAD11SHGain 0xc0000 -#define bAD11InputRange 0x700000 -#define bAD11OPCurrent 0x3800000 -#define bIPathLoopback 0x4000000 -#define bQPathLoopback 0x8000000 -#define bAFELoopback 0x10000000 -#define bDA10Swing 0x7e0 -#define bDA10Reverse 0x800 -#define bDAClkSource 0x1000 -#define bAD7InputRange 0x6000 -#define bAD7Gain 0x38000 -#define bAD7OutputCMMode 0x40000 -#define bAD7InputCMMode 0x380000 -#define bAD7Current 0xc00000 -#define bRegulatorAdjust 0x7000000 -#define bAD11PowerUpAtTx 0x1 -#define bDA10PSAtTx 0x10 -#define bAD11PowerUpAtRx 0x100 -#define bDA10PSAtRx 0x1000 -#define bCCKRxAGCFormat 0x200 -#define bPSDFFTSamplepPoint 0xc000 -#define bPSDAverageNum 0x3000 -#define bIQPathControl 0xc00 -#define bPSDFreq 0x3ff -#define bPSDAntennaPath 0x30 -#define bPSDIQSwitch 0x40 -#define bPSDRxTrigger 0x400000 -#define bPSDTxTrigger 0x80000000 -#define bPSDSineToneScale 0x7f000000 -#define bPSDReport 0xffff - -/* 3. Page9(0x900) */ -#define bOFDMTxSC 0x30000000 /* Useless */ -#define bCCKTxOn 0x1 -#define bOFDMTxOn 0x2 -#define bDebugPage 0xfff /* reset debug page and HWord, - * LWord - */ -#define bDebugItem 0xff /* reset debug page and LWord */ -#define bAntL 0x10 -#define bAntNonHT 0x100 -#define bAntHT1 0x1000 -#define bAntHT2 0x10000 -#define bAntHT1S1 0x100000 -#define bAntNonHTS1 0x1000000 - -/* 4. PageA(0xA00) */ -#define bCCKBBMode 0x3 /* Useless */ -#define bCCKTxPowerSaving 0x80 -#define bCCKRxPowerSaving 0x40 - -#define bCCKSideBand 0x10 /* Reg 0xa00 rCCK0 20/40 sw */ - -#define bCCKScramble 0x8 /* Useless */ -#define bCCKAntDiversity 0x8000 -#define bCCKCarrierRecovery 0x4000 -#define bCCKTxRate 0x3000 -#define bCCKDCCancel 0x0800 -#define bCCKISICancel 0x0400 -#define bCCKMatchFilter 0x0200 -#define bCCKEqualizer 0x0100 -#define bCCKPreambleDetect 0x800000 -#define bCCKFastFalseCCA 0x400000 -#define bCCKChEstStart 0x300000 -#define bCCKCCACount 0x080000 -#define bCCKcs_lim 0x070000 -#define bCCKBistMode 0x80000000 -#define bCCKCCAMask 0x40000000 -#define bCCKTxDACPhase 0x4 -#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */ -#define bCCKr_cp_mode0 0x0100 -#define bCCKTxDCOffset 0xf0 -#define bCCKRxDCOffset 0xf -#define bCCKCCAMode 0xc000 -#define bCCKFalseCS_lim 0x3f00 -#define bCCKCS_ratio 0xc00000 -#define bCCKCorgBit_sel 0x300000 -#define bCCKPD_lim 0x0f0000 -#define bCCKNewCCA 0x80000000 -#define bCCKRxHPofIG 0x8000 -#define bCCKRxIG 0x7f00 -#define bCCKLNAPolarity 0x800000 -#define bCCKRx1stGain 0x7f0000 -#define bCCKRFExtend 0x20000000 /* CCK Rx init gain polar */ -#define bCCKRxAGCSatLevel 0x1f000000 -#define bCCKRxAGCSatCount 0xe0 -#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */ -#define bCCKFixedRxAGC 0x8000 -#define bCCKAntennaPolarity 0x2000 -#define bCCKTxFilterType 0x0c00 -#define bCCKRxAGCReportType 0x0300 -#define bCCKRxDAGCEn 0x80000000 -#define bCCKRxDAGCPeriod 0x20000000 -#define bCCKRxDAGCSatLevel 0x1f000000 -#define bCCKTimingRecovery 0x800000 -#define bCCKTxC0 0x3f0000 -#define bCCKTxC1 0x3f000000 -#define bCCKTxC2 0x3f -#define bCCKTxC3 0x3f00 -#define bCCKTxC4 0x3f0000 -#define bCCKTxC5 0x3f000000 -#define bCCKTxC6 0x3f -#define bCCKTxC7 0x3f00 -#define bCCKDebugPort 0xff0000 -#define bCCKDACDebug 0x0f000000 -#define bCCKFalseAlarmEnable 0x8000 -#define bCCKFalseAlarmRead 0x4000 -#define bCCKTRSSI 0x7f -#define bCCKRxAGCReport 0xfe -#define bCCKRxReport_AntSel 0x80000000 -#define bCCKRxReport_MFOff 0x40000000 -#define bCCKRxRxReport_SQLoss 0x20000000 -#define bCCKRxReport_Pktloss 0x10000000 -#define bCCKRxReport_Lockedbit 0x08000000 -#define bCCKRxReport_RateError 0x04000000 -#define bCCKRxReport_RxRate 0x03000000 -#define bCCKRxFACounterLower 0xff -#define bCCKRxFACounterUpper 0xff000000 -#define bCCKRxHPAGCStart 0xe000 -#define bCCKRxHPAGCFinal 0x1c00 -#define bCCKRxFalseAlarmEnable 0x8000 -#define bCCKFACounterFreeze 0x4000 -#define bCCKTxPathSel 0x10000000 -#define bCCKDefaultRxPath 0xc000000 -#define bCCKOptionRxPath 0x3000000 - -/* 5. PageC(0xC00) */ -#define bNumOfSTF 0x3 /* Useless */ -#define bShift_L 0xc0 -#define bGI_TH 0xc -#define bRxPathA 0x1 -#define bRxPathB 0x2 -#define bRxPathC 0x4 -#define bRxPathD 0x8 -#define bTxPathA 0x1 -#define bTxPathB 0x2 -#define bTxPathC 0x4 -#define bTxPathD 0x8 -#define bTRSSIFreq 0x200 -#define bADCBackoff 0x3000 -#define bDFIRBackoff 0xc000 -#define bTRSSILatchPhase 0x10000 -#define bRxIDCOffset 0xff -#define bRxQDCOffset 0xff00 -#define bRxDFIRMode 0x1800000 -#define bRxDCNFType 0xe000000 -#define bRXIQImb_A 0x3ff -#define bRXIQImb_B 0xfc00 -#define bRXIQImb_C 0x3f0000 -#define bRXIQImb_D 0xffc00000 -#define bDC_dc_Notch 0x60000 -#define bRxNBINotch 0x1f000000 -#define bPD_TH 0xf -#define bPD_TH_Opt2 0xc000 -#define bPWED_TH 0x700 -#define bIfMF_Win_L 0x800 -#define bPD_Option 0x1000 -#define bMF_Win_L 0xe000 -#define bBW_Search_L 0x30000 -#define bwin_enh_L 0xc0000 -#define bBW_TH 0x700000 -#define bED_TH2 0x3800000 -#define bBW_option 0x4000000 -#define bRatio_TH 0x18000000 -#define bWindow_L 0xe0000000 -#define bSBD_Option 0x1 -#define bFrame_TH 0x1c -#define bFS_Option 0x60 -#define bDC_Slope_check 0x80 -#define bFGuard_Counter_DC_L 0xe00 -#define bFrame_Weight_Short 0x7000 -#define bSub_Tune 0xe00000 -#define bFrame_DC_Length 0xe000000 -#define bSBD_start_offset 0x30000000 -#define bFrame_TH_2 0x7 -#define bFrame_GI2_TH 0x38 -#define bGI2_Sync_en 0x40 -#define bSarch_Short_Early 0x300 -#define bSarch_Short_Late 0xc00 -#define bSarch_GI2_Late 0x70000 -#define bCFOAntSum 0x1 -#define bCFOAcc 0x2 -#define bCFOStartOffset 0xc -#define bCFOLookBack 0x70 -#define bCFOSumWeight 0x80 -#define bDAGCEnable 0x10000 -#define bTXIQImb_A 0x3ff -#define bTXIQImb_B 0xfc00 -#define bTXIQImb_C 0x3f0000 -#define bTXIQImb_D 0xffc00000 -#define bTxIDCOffset 0xff -#define bTxQDCOffset 0xff00 -#define bTxDFIRMode 0x10000 -#define bTxPesudoNoiseOn 0x4000000 -#define bTxPesudoNoise_A 0xff -#define bTxPesudoNoise_B 0xff00 -#define bTxPesudoNoise_C 0xff0000 -#define bTxPesudoNoise_D 0xff000000 -#define bCCADropOption 0x20000 -#define bCCADropThres 0xfff00000 -#define bEDCCA_H 0xf -#define bEDCCA_L 0xf0 -#define bLambda_ED 0x300 -#define bRxInitialGain 0x7f -#define bRxAntDivEn 0x80 -#define bRxAGCAddressForLNA 0x7f00 -#define bRxHighPowerFlow 0x8000 -#define bRxAGCFreezeThres 0xc0000 -#define bRxFreezeStep_AGC1 0x300000 -#define bRxFreezeStep_AGC2 0xc00000 -#define bRxFreezeStep_AGC3 0x3000000 -#define bRxFreezeStep_AGC0 0xc000000 -#define bRxRssi_Cmp_En 0x10000000 -#define bRxQuickAGCEn 0x20000000 -#define bRxAGCFreezeThresMode 0x40000000 -#define bRxOverFlowCheckType 0x80000000 -#define bRxAGCShift 0x7f -#define bTRSW_Tri_Only 0x80 -#define bPowerThres 0x300 -#define bRxAGCEn 0x1 -#define bRxAGCTogetherEn 0x2 -#define bRxAGCMin 0x4 -#define bRxHP_Ini 0x7 -#define bRxHP_TRLNA 0x70 -#define bRxHP_RSSI 0x700 -#define bRxHP_BBP1 0x7000 -#define bRxHP_BBP2 0x70000 -#define bRxHP_BBP3 0x700000 -#define bRSSI_H 0x7f0000 /* thresh for hi power */ -#define bRSSI_Gen 0x7f000000 /* thresh for ant div */ -#define bRxSettle_TRSW 0x7 -#define bRxSettle_LNA 0x38 -#define bRxSettle_RSSI 0x1c0 -#define bRxSettle_BBP 0xe00 -#define bRxSettle_RxHP 0x7000 -#define bRxSettle_AntSW_RSSI 0x38000 -#define bRxSettle_AntSW 0xc0000 -#define bRxProcessTime_DAGC 0x300000 -#define bRxSettle_HSSI 0x400000 -#define bRxProcessTime_BBPPW 0x800000 -#define bRxAntennaPowerShift 0x3000000 -#define bRSSITableSelect 0xc000000 -#define bRxHP_Final 0x7000000 -#define bRxHTSettle_BBP 0x7 -#define bRxHTSettle_HSSI 0x8 -#define bRxHTSettle_RxHP 0x70 -#define bRxHTSettle_BBPPW 0x80 -#define bRxHTSettle_Idle 0x300 -#define bRxHTSettle_Reserved 0x1c00 -#define bRxHTRxHPEn 0x8000 -#define bRxHTAGCFreezeThres 0x30000 -#define bRxHTAGCTogetherEn 0x40000 -#define bRxHTAGCMin 0x80000 -#define bRxHTAGCEn 0x100000 -#define bRxHTDAGCEn 0x200000 -#define bRxHTRxHP_BBP 0x1c00000 -#define bRxHTRxHP_Final 0xe0000000 -#define bRxPWRatioTH 0x3 -#define bRxPWRatioEn 0x4 -#define bRxMFHold 0x3800 -#define bRxPD_Delay_TH1 0x38 -#define bRxPD_Delay_TH2 0x1c0 -#define bRxPD_DC_COUNT_MAX 0x600 -/* define bRxMF_Hold 0x3800 */ -#define bRxPD_Delay_TH 0x8000 -#define bRxProcess_Delay 0xf0000 -#define bRxSearchrange_GI2_Early 0x700000 -#define bRxFrame_Guard_Counter_L 0x3800000 -#define bRxSGI_Guard_L 0xc000000 -#define bRxSGI_Search_L 0x30000000 -#define bRxSGI_TH 0xc0000000 -#define bDFSCnt0 0xff -#define bDFSCnt1 0xff00 -#define bDFSFlag 0xf0000 -#define bMFWeightSum 0x300000 -#define bMinIdxTH 0x7f000000 -#define bDAFormat 0x40000 -#define bTxChEmuEnable 0x01000000 -#define bTRSWIsolation_A 0x7f -#define bTRSWIsolation_B 0x7f00 -#define bTRSWIsolation_C 0x7f0000 -#define bTRSWIsolation_D 0x7f000000 -#define bExtLNAGain 0x7c00 - -/* 6. PageE(0xE00) */ -#define bSTBCEn 0x4 /* Useless */ -#define bAntennaMapping 0x10 -#define bNss 0x20 -#define bCFOAntSumD 0x200 -#define bPHYCounterReset 0x8000000 -#define bCFOReportGet 0x4000000 -#define bOFDMContinueTx 0x10000000 -#define bOFDMSingleCarrier 0x20000000 -#define bOFDMSingleTone 0x40000000 -/* define bRxPath1 0x01 */ -/* define bRxPath2 0x02 */ -/* define bRxPath3 0x04 */ -/* define bRxPath4 0x08 */ -/* define bTxPath1 0x10 */ -/* define bTxPath2 0x20 */ -#define bHTDetect 0x100 -#define bCFOEn 0x10000 -#define bCFOValue 0xfff00000 -#define bSigTone_Re 0x3f -#define bSigTone_Im 0x7f00 -#define bCounter_CCA 0xffff -#define bCounter_ParityFail 0xffff0000 -#define bCounter_RateIllegal 0xffff -#define bCounter_CRC8Fail 0xffff0000 -#define bCounter_MCSNoSupport 0xffff -#define bCounter_FastSync 0xffff -#define bShortCFO 0xfff -#define bShortCFOTLength 12 /* total */ -#define bShortCFOFLength 11 /* fraction */ -#define bLongCFO 0x7ff -#define bLongCFOTLength 11 -#define bLongCFOFLength 11 -#define bTailCFO 0x1fff -#define bTailCFOTLength 13 -#define bTailCFOFLength 12 -#define bmax_en_pwdB 0xffff -#define bCC_power_dB 0xffff0000 -#define bnoise_pwdB 0xffff -#define bPowerMeasTLength 10 -#define bPowerMeasFLength 3 -#define bRx_HT_BW 0x1 -#define bRxSC 0x6 -#define bRx_HT 0x8 -#define bNB_intf_det_on 0x1 -#define bIntf_win_len_cfg 0x30 -#define bNB_Intf_TH_cfg 0x1c0 -#define bRFGain 0x3f -#define bTableSel 0x40 -#define bTRSW 0x80 -#define bRxSNR_A 0xff -#define bRxSNR_B 0xff00 -#define bRxSNR_C 0xff0000 -#define bRxSNR_D 0xff000000 -#define bSNREVMTLength 8 -#define bSNREVMFLength 1 -#define bCSI1st 0xff -#define bCSI2nd 0xff00 -#define bRxEVM1st 0xff0000 -#define bRxEVM2nd 0xff000000 -#define bSIGEVM 0xff -#define bPWDB 0xff00 -#define bSGIEN 0x10000 - -#define bSFactorQAM1 0xf /* Useless */ -#define bSFactorQAM2 0xf0 -#define bSFactorQAM3 0xf00 -#define bSFactorQAM4 0xf000 -#define bSFactorQAM5 0xf0000 -#define bSFactorQAM6 0xf0000 -#define bSFactorQAM7 0xf00000 -#define bSFactorQAM8 0xf000000 -#define bSFactorQAM9 0xf0000000 -#define bCSIScheme 0x100000 - -#define bNoiseLvlTopSet 0x3 /* Useless */ -#define bChSmooth 0x4 -#define bChSmoothCfg1 0x38 -#define bChSmoothCfg2 0x1c0 -#define bChSmoothCfg3 0xe00 -#define bChSmoothCfg4 0x7000 -#define bMRCMode 0x800000 -#define bTHEVMCfg 0x7000000 - -#define bLoopFitType 0x1 /* Useless */ -#define bUpdCFO 0x40 -#define bUpdCFOOffData 0x80 -#define bAdvUpdCFO 0x100 -#define bAdvTimeCtrl 0x800 -#define bUpdClko 0x1000 -#define bFC 0x6000 -#define bTrackingMode 0x8000 -#define bPhCmpEnable 0x10000 -#define bUpdClkoLTF 0x20000 -#define bComChCFO 0x40000 -#define bCSIEstiMode 0x80000 -#define bAdvUpdEqz 0x100000 -#define bUChCfg 0x7000000 -#define bUpdEqz 0x8000000 - -#define bTxAGCRate18_06 0x7f7f7f7f /* Useless */ -#define bTxAGCRate54_24 0x7f7f7f7f -#define bTxAGCRateMCS32 0x7f -#define bTxAGCRateCCK 0x7f00 -#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f -#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f -#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f -#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f - -/* Rx Pseduo noise */ -#define bRxPesudoNoiseOn 0x20000000 /* Useless */ -#define bRxPesudoNoise_A 0xff -#define bRxPesudoNoise_B 0xff00 -#define bRxPesudoNoise_C 0xff0000 -#define bRxPesudoNoise_D 0xff000000 -#define bPesudoNoiseState_A 0xffff -#define bPesudoNoiseState_B 0xffff0000 -#define bPesudoNoiseState_C 0xffff -#define bPesudoNoiseState_D 0xffff0000 - -/* 7. RF Register */ -/* Zebra1 */ -#define bZebra1_HSSIEnable 0x8 /* Useless */ -#define bZebra1_TRxControl 0xc00 -#define bZebra1_TRxGainSetting 0x07f -#define bZebra1_RxCorner 0xc00 -#define bZebra1_TxChargePump 0x38 -#define bZebra1_RxChargePump 0x7 -#define bZebra1_ChannelNum 0xf80 -#define bZebra1_TxLPFBW 0x400 -#define bZebra1_RxLPFBW 0x600 - -/* Zebra4 */ -#define bRTL8256RegModeCtrl1 0x100 /* Useless */ -#define bRTL8256RegModeCtrl0 0x40 -#define bRTL8256_TxLPFBW 0x18 -#define bRTL8256_RxLPFBW 0x600 - -/* RTL8258 */ -#define bRTL8258_TxLPFBW 0xc /* Useless */ -#define bRTL8258_RxLPFBW 0xc00 -#define bRTL8258_RSSILPFBW 0xc0 - - -/* */ -/* Other Definition */ -/* */ - -/* byte endable for sb_write */ -#define bByte0 0x1 /* Useless */ -#define bByte1 0x2 -#define bByte2 0x4 -#define bByte3 0x8 -#define bWord0 0x3 -#define bWord1 0xc -#define bDWord 0xf - -/* for PutRegsetting & GetRegSetting BitMask */ -#define bMaskByte0 0xff /* Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */ -#define bMaskByte1 0xff00 -#define bMaskByte2 0xff0000 -#define bMaskByte3 0xff000000 -#define bMaskHWord 0xffff0000 -#define bMaskLWord 0x0000ffff -#define bMaskDWord 0xffffffff -#define bMaskH4Bits 0xf0000000 -#define bMaskOFDM_D 0xffc00000 -#define bMaskCCK 0x3f3f3f3f -#define bMask12Bits 0xfff - -/* for PutRFRegsetting & GetRFRegSetting BitMask */ -#if (RTL92SE_FPGA_VERIFY == 1) -#define bRFRegOffsetMask 0xfff -#else -#define bRFRegOffsetMask 0xfffff -#endif -#define bEnable 0x1 /* Useless */ -#define bDisabl 0x0 - -#define LeftAntenna 0x0 /* Useless */ -#define RightAntenna 0x1 - -#define tCheckTxStatus 500 /* 500ms Useless */ -#define tUpdateRxCounter 100 /* 100ms */ - -#define rateCCK 0 /* Useless */ -#define rateOFDM 1 -#define rateHT 2 - -/* define Register-End */ -#define bPMAC_End 0x1ff /* Useless */ -#define bFPGAPHY0_End 0x8ff -#define bFPGAPHY1_End 0x9ff -#define bCCKPHY0_End 0xaff -#define bOFDMPHY0_End 0xcff -#define bOFDMPHY1_End 0xdff - -/* define max debug item in each debug page */ -/* define bMaxItem_FPGA_PHY0 0x9 */ -/* define bMaxItem_FPGA_PHY1 0x3 */ -/* define bMaxItem_PHY_11B 0x16 */ -/* define bMaxItem_OFDM_PHY0 0x29 */ -/* define bMaxItem_OFDM_PHY1 0x0 */ - -#define bPMACControl 0x0 /* Useless */ -#define bWMACControl 0x1 -#define bWNICControl 0x2 - -#define RCR_AAP BIT(0) /* accept all physical address */ -#define RCR_APM BIT(1) /* accept physical match */ -#define RCR_AM BIT(2) /* accept multicast */ -#define RCR_AB BIT(3) /* accept broadcast */ -#define RCR_ACRC32 BIT(5) /* accept error packet */ -#define RCR_9356SEL BIT(6) -#define RCR_AICV BIT(12) /* Accept ICV error packet */ -#define RCR_RXFTH0 (BIT(13)|BIT(14)|BIT(15)) /* Rx FIFO threshold */ -#define RCR_ADF BIT(18) /* Accept Data(frame type) frame */ -#define RCR_ACF BIT(19) /* Accept control frame */ -#define RCR_AMF BIT(20) /* Accept management frame */ -#define RCR_ADD3 BIT(21) -#define RCR_APWRMGT BIT(22) /* Accept power management packet */ -#define RCR_CBSSID BIT(23) /* Accept BSSID match packet */ -#define RCR_ENMARP BIT(28) /* enable mac auto reset phy */ -#define RCR_EnCS1 BIT(29) /* enable carrier sense method 1 */ -#define RCR_EnCS2 BIT(30) /* enable carrier sense method 2 */ -#define RCR_OnlyErlPkt BIT(31) /* Rx Early mode is performed for - * packet size greater than 1536 - */ - -/*--------------------------Define Parameters-------------------------------*/ - - -#endif /* __INC_HAL8192SPHYREG_H */ From 15c3381e3abba34c8634575305db1e414e587e3b Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 5 Jul 2018 14:52:35 +0530 Subject: [PATCH 249/903] staging: wilc1000: fix static checker warning to unlock mutex in wilc_deinit() Fix for static checker warning inconsistent returns of 'hif_deinit_lock'(more details [1]). "drivers/staging/wilc1000/host_interface.c:3390 wilc_deinit() warn: inconsistent returns 'hif_deinit_lock'." Fixes: ff52a57a7a42 ("staging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd()") [1]. https://www.spinics.net/lists/linux-driver-devel/msg114216.html Reported-by: Dan Carpenter Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 52c0c1066375..918d06e8cd34 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3370,15 +3370,15 @@ int wilc_deinit(struct wilc_vif *vif) struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_hif_exit_work, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - result = wilc_enqueue_work(msg); - if (result) - netdev_err(vif->ndev, "deinit : Error(%d)\n", result); - else - wait_for_completion(&msg->work_comp); - kfree(msg); + if (!IS_ERR(msg)) { + result = wilc_enqueue_work(msg); + if (result) + netdev_err(vif->ndev, "deinit : Error(%d)\n", + result); + else + wait_for_completion(&msg->work_comp); + kfree(msg); + } destroy_workqueue(hif_workqueue); } From de63831a21e944c66f8b4165451f7159fdff7b20 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 6 Jul 2018 16:56:01 +0200 Subject: [PATCH 250/903] staging: rtl8723bs: remove rtl8192c_rf.h All functions declared in rtl8192c_rf.h have no definition/are not used in any other file/anywhere. Checked with 'git grep '. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/include/rtl8192c_rf.h | 28 ------------------- .../staging/rtl8723bs/include/rtl8723b_rf.h | 1 - 2 files changed, 29 deletions(-) delete mode 100644 drivers/staging/rtl8723bs/include/rtl8192c_rf.h diff --git a/drivers/staging/rtl8723bs/include/rtl8192c_rf.h b/drivers/staging/rtl8723bs/include/rtl8192c_rf.h deleted file mode 100644 index ad684add8dd6..000000000000 --- a/drivers/staging/rtl8723bs/include/rtl8192c_rf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTL8192C_RF_H_ -#define _RTL8192C_RF_H_ - - -/* */ -/* RF RL6052 Series API */ -/* */ -void rtl8192c_RF_ChangeTxPath(struct adapter *Adapter, - u16 DataRate); -void rtl8192c_PHY_RF6052SetBandwidth(struct adapter *Adapter, - enum CHANNEL_WIDTH Bandwidth); -void rtl8192c_PHY_RF6052SetCckTxPower(struct adapter *Adapter, - u8 *pPowerlevel); -void rtl8192c_PHY_RF6052SetOFDMTxPower(struct adapter *Adapter, - u8 *pPowerLevel, - u8 Channel); -int PHY_RF6052_Config8192C(struct adapter *Adapter); - -/*--------------------------Exported Function prototype---------------------*/ - - -#endif/* End of HalRf.h */ diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_rf.h b/drivers/staging/rtl8723bs/include/rtl8723b_rf.h index 1c16183caf9b..987b9f12a4f4 100644 --- a/drivers/staging/rtl8723bs/include/rtl8723b_rf.h +++ b/drivers/staging/rtl8723bs/include/rtl8723b_rf.h @@ -7,7 +7,6 @@ #ifndef __RTL8723B_RF_H__ #define __RTL8723B_RF_H__ -#include "rtl8192c_rf.h" int PHY_RF6052_Config8723B(struct adapter *Adapter ); From 4d31db586090dd88ef74b4c8891ac981d971df46 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 4 Jul 2018 13:37:39 +0200 Subject: [PATCH 251/903] staging: rtl8188eu: rename Hal8188EPhyCfg.h Rename header file to avoid CamelCase. Hal8188EPhyCfg.h -> hal8188e_phy_cfg.h Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../rtl8188eu/include/{Hal8188EPhyCfg.h => hal8188e_phy_cfg.h} | 0 drivers/staging/rtl8188eu/include/hal_intf.h | 2 +- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename drivers/staging/rtl8188eu/include/{Hal8188EPhyCfg.h => hal8188e_phy_cfg.h} (100%) diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h similarity index 100% rename from drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h rename to drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 5a706818d079..e5be27af7bf5 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -9,7 +9,7 @@ #include #include -#include +#include enum RTL871X_HCI_TYPE { RTW_PCIE = BIT(0), diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index 54d34976c721..e04e97e98ab7 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -11,7 +11,7 @@ /* include HAL Related header after HAL Related compiling flags */ #include "rtl8188e_spec.h" #include "Hal8188EPhyReg.h" -#include "Hal8188EPhyCfg.h" +#include "hal8188e_phy_cfg.h" #include "rtl8188e_dm.h" #include "rtl8188e_recv.h" #include "rtl8188e_xmit.h" From 89778d0d6c2a198b01df44ba20222e4da5442910 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 4 Jul 2018 13:37:40 +0200 Subject: [PATCH 252/903] staging: rtl8188eu: rename Hal8188EPhyReg.h Rename header file to avoid CamelCase. Hal8188EPhyReg.h -> hal8188e_phy_reg.h Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../rtl8188eu/include/{Hal8188EPhyReg.h => hal8188e_phy_reg.h} | 0 drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/staging/rtl8188eu/include/{Hal8188EPhyReg.h => hal8188e_phy_reg.h} (100%) diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h b/drivers/staging/rtl8188eu/include/hal8188e_phy_reg.h similarity index 100% rename from drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h rename to drivers/staging/rtl8188eu/include/hal8188e_phy_reg.h diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index e04e97e98ab7..a86b07d3c82a 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -10,7 +10,7 @@ /* include HAL Related header after HAL Related compiling flags */ #include "rtl8188e_spec.h" -#include "Hal8188EPhyReg.h" +#include "hal8188e_phy_reg.h" #include "hal8188e_phy_cfg.h" #include "rtl8188e_dm.h" #include "rtl8188e_recv.h" From ad515954f634b69847d54c1c4c2eb0de1834a489 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 4 Jul 2018 13:37:41 +0200 Subject: [PATCH 253/903] staging: rtl8188eu: rename Hal8188ERateAdaptive Rename header and source file to avoid CamelCase. Hal8188ERateAdaptive.h -> hal8188e_rate_adaptive.h Hal8188ERateAdaptive.c -> hal8188e_rate_adaptive.c Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/Makefile | 2 +- .../hal/{Hal8188ERateAdaptive.c => hal8188e_rate_adaptive.c} | 0 .../{Hal8188ERateAdaptive.h => hal8188e_rate_adaptive.h} | 0 drivers/staging/rtl8188eu/include/odm_precomp.h | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename drivers/staging/rtl8188eu/hal/{Hal8188ERateAdaptive.c => hal8188e_rate_adaptive.c} (100%) rename drivers/staging/rtl8188eu/include/{Hal8188ERateAdaptive.h => hal8188e_rate_adaptive.h} (100%) diff --git a/drivers/staging/rtl8188eu/Makefile b/drivers/staging/rtl8188eu/Makefile index 033fb2e6950d..aa6ea65d05fe 100644 --- a/drivers/staging/rtl8188eu/Makefile +++ b/drivers/staging/rtl8188eu/Makefile @@ -24,7 +24,7 @@ r8188eu-y := \ hal/rf_cfg.o \ hal/pwrseqcmd.o \ hal/pwrseq.o \ - hal/Hal8188ERateAdaptive.o\ + hal/hal8188e_rate_adaptive.o \ hal/hal_intf.o \ hal/hal_com.o \ hal/odm.o \ diff --git a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c similarity index 100% rename from drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c rename to drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c diff --git a/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h similarity index 100% rename from drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h rename to drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h index c01714be141f..f00967fd9599 100644 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -26,7 +26,7 @@ #include "odm_debug.h" #include "odm_RegDefine11N.h" -#include "Hal8188ERateAdaptive.h"/* for RA,Power training */ +#include "hal8188e_rate_adaptive.h" /* for RA,Power training */ #include "rtl8188e_hal.h" #include "odm_reg.h" From c336f8325ff03afecc51631ead0f7dfc1ac6e0c5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 12:59:21 +0100 Subject: [PATCH 254/903] staging: rtl8192u: Use __func__ instead of hardcoded string - Style Changed logging statements to use %s and __func__ instead of hard coding the function name in a string. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_HTProc.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 98d74d87bf11..a549d9678214 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -534,7 +534,9 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u //u8 bIsDeclareMCS13; if (!posHTCap || !pHT) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); + IEEE80211_DEBUG(IEEE80211_DL_ERR, + "posHTCap or pHTInfo can't be null in %s\n", + __func__); return; } memset(posHTCap, 0, *len); @@ -645,7 +647,9 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo; if (!posHTInfo || !pHTInfoEle) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); + IEEE80211_DEBUG(IEEE80211_DL_ERR, + "posHTInfo or pHTInfoEle can't be null in %s\n", + __func__); return; } @@ -709,7 +713,9 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len) { if (!posRT2RTAgg) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); + IEEE80211_DEBUG(IEEE80211_DL_ERR, + "posRT2RTAgg can't be null in %s\n", + __func__); return; } memset(posRT2RTAgg, 0, *len); @@ -758,7 +764,9 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) u8 i; if (!pOperateMCS) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); + IEEE80211_DEBUG(IEEE80211_DL_ERR, + "pOperateMCS can't be null in %s\n", + __func__); return false; } @@ -820,7 +828,9 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF u8 availableMcsRate[16]; if (!pMCSRateSet || !pMCSFilter) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); + IEEE80211_DEBUG(IEEE80211_DL_ERR, + "pMCSRateSet or pMCSFilter can't be null in %s\n", + __func__); return false; } for (i = 0; i < 16; i++) @@ -900,7 +910,9 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily if (!pHTInfo->bCurrentHTSupport) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); + IEEE80211_DEBUG(IEEE80211_DL_ERR, + "<=== %s: HT_DISABLE\n", + __func__); return; } IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); From 868e346c1c5c4b0dac7765b63a85f986dba15a49 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:49 +0100 Subject: [PATCH 255/903] staging: rtl8192u: Use memset to initialize memory, instead of loop. Replaced memory initialising loop with memset instead. Suggested-by: Andy Shevchenko Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index a549d9678214..abf55877331e 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -761,8 +761,6 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, */ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) { - u8 i; - if (!pOperateMCS) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in %s\n", @@ -777,8 +775,7 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS) //legacy rate routine handled at selectedrate //no MCS rate - for (i = 0; i <= 15; i++) - pOperateMCS[i] = 0; + memset(pOperateMCS, 0, 16); break; case IEEE_N_24G: //assume CCK rate ok From 15d7e53e66b7e92c19d0f9231595e22d14a63fe5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:50 +0100 Subject: [PATCH 256/903] staging: rtl8192u: Remove redundant definitions in header Truncated header file removing definitions which aren't used. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_HT.h | 117 ------------------ 1 file changed, 117 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h index a85036022aa8..6abf32b142ef 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h @@ -7,21 +7,10 @@ // reassociation request and probe response frames //------------------------------------------------------------ -// -// Operation mode value -// -#define HT_OPMODE_NO_PROTECT 0 -#define HT_OPMODE_OPTIONAL 1 -#define HT_OPMODE_40MHZ_PROTECT 2 -#define HT_OPMODE_MIXED 3 - // // MIMO Power Save Settings // #define MIMO_PS_STATIC 0 -#define MIMO_PS_DYNAMIC 1 -#define MIMO_PS_NOLIMIT 3 - // // There should be 128 bits to cover all of the MCS rates. However, since @@ -35,27 +24,6 @@ #define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 #define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP - -typedef enum _HT_MCS_RATE { - HT_MCS0 = 0x00000001, - HT_MCS1 = 0x00000002, - HT_MCS2 = 0x00000004, - HT_MCS3 = 0x00000008, - HT_MCS4 = 0x00000010, - HT_MCS5 = 0x00000020, - HT_MCS6 = 0x00000040, - HT_MCS7 = 0x00000080, - HT_MCS8 = 0x00000100, - HT_MCS9 = 0x00000200, - HT_MCS10 = 0x00000400, - HT_MCS11 = 0x00000800, - HT_MCS12 = 0x00001000, - HT_MCS13 = 0x00002000, - HT_MCS14 = 0x00004000, - HT_MCS15 = 0x00008000, - // Do not define MCS32 here although 8190 support MCS32 -} HT_MCS_RATE, *PHT_MCS_RATE; - // // Represent Channel Width in HT Capabilities // @@ -120,28 +88,6 @@ typedef union _HT_CAPABILITY_MACPARA{ }HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA; */ -typedef enum _HT_ACTION { - ACT_RECOMMAND_WIDTH = 0, - ACT_MIMO_PWR_SAVE = 1, - ACT_PSMP = 2, - ACT_SET_PCO_PHASE = 3, - ACT_MIMO_CHL_MEASURE = 4, - ACT_RECIPROCITY_CORRECT = 5, - ACT_MIMO_CSI_MATRICS = 6, - ACT_MIMO_NOCOMPR_STEER = 7, - ACT_MIMO_COMPR_STEER = 8, - ACT_ANTENNA_SELECT = 9, -} HT_ACTION, *PHT_ACTION; - - -/* 2007/06/07 MH Define sub-carrier mode for 40MHZ. */ -typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier { - SC_MODE_DUPLICATE = 0, - SC_MODE_LOWER = 1, - SC_MODE_UPPER = 2, - SC_MODE_FULL40MHZ = 3, -}HT_BW40_SC_E; - typedef struct _HT_CAPABILITY_ELE { //HT capability info @@ -212,16 +158,6 @@ typedef struct _HT_INFORMATION_ELE { u8 BasicMSC[16]; } __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE; -// -// MIMO Power Save control field. -// This is appear in MIMO Power Save Action Frame -// -typedef struct _MIMOPS_CTRL { - u8 MimoPsEnable:1; - u8 MimoPsMode:1; - u8 Reserved:6; -} MIMOPS_CTRL, *PMIMOPS_CTRL; - typedef enum _HT_SPEC_VER { HT_SPEC_VER_IEEE = 0, HT_SPEC_VER_EWC = 1, @@ -342,37 +278,6 @@ typedef struct _RT_HIGH_THROUGHPUT { u32 IOTAction; } __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT; - -//------------------------------------------------------------ -// The Data structure is used to keep HT related variable for "each Sta" -// when card is configured as "AP mode" -//------------------------------------------------------------ - -typedef struct _RT_HTINFO_STA_ENTRY { - u8 bEnableHT; - - u8 bSupportCck; - - u16 AMSDU_MaxSize; - - u8 AMPDU_Factor; - u8 MPDU_Density; - - u8 HTHighestOperaRate; - - u8 bBw40MHz; - - u8 MimoPs; - - u8 McsRateSet[16]; - - -}RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY; - - - - - //------------------------------------------------------------ // The Data structure is used to keep HT related variable for "each AP" // when card is configured as "STA mode" @@ -396,28 +301,6 @@ typedef struct _BSS_HT { u8 bdRT2RTLongSlotTime; } __attribute__ ((packed)) BSS_HT, *PBSS_HT; -typedef struct _MIMO_RSSI { - u32 EnableAntenna; - u32 AntennaA; - u32 AntennaB; - u32 AntennaC; - u32 AntennaD; - u32 Average; -}MIMO_RSSI, *PMIMO_RSSI; - -typedef struct _MIMO_EVM { - u32 EVM1; - u32 EVM2; -}MIMO_EVM, *PMIMO_EVM; - -typedef struct _FALSE_ALARM_STATISTICS { - u32 Cnt_Parity_Fail; - u32 Cnt_Rate_Illegal; - u32 Cnt_Crc8_fail; - u32 Cnt_all; -}FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS; - - extern u8 MCS_FILTER_ALL[16]; extern u8 MCS_FILTER_1SS[16]; From 5e540f8acb302cf5a7ac4ea6687c822f5c18d2d1 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:51 +0100 Subject: [PATCH 257/903] staging: rtl8192u: Remove superfluous blank lines - Coding Style Removal of extra blank lines from the ieee80211_softmac.c file Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 105 ------------------ 1 file changed, 105 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 9d9a9e102bb8..7ef761632629 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -12,8 +12,6 @@ * * released under the GPL */ - - #include "ieee80211.h" #include @@ -98,7 +96,6 @@ static void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) *tag_p = tag; } - static void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -216,7 +213,6 @@ static u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee) return rate; } - void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) @@ -289,14 +285,11 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee static inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) { - short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *) skb->data; - if(single){ - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -307,7 +300,6 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) /* avoid watchdog triggers */ netif_trans_update(ieee->dev); ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -318,7 +310,6 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) ieee->seq_ctrl[0]++; ieee->softmac_hard_start_xmit(skb, ieee->dev); - } //dev_kfree_skb_any(skb);//edit by thomas } @@ -390,7 +381,6 @@ static void ieee80211_send_beacon(struct ieee80211_device *ieee) //spin_unlock_irqrestore(&ieee->beacon_lock,flags); } - static void ieee80211_send_beacon_cb(struct timer_list *t) { struct ieee80211_device *ieee = @@ -402,7 +392,6 @@ static void ieee80211_send_beacon_cb(struct timer_list *t) spin_unlock_irqrestore(&ieee->beacon_lock, flags); } - static void ieee80211_send_probe(struct ieee80211_device *ieee) { struct sk_buff *skb; @@ -436,7 +425,6 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) while(1) { - do{ ch++; if (ch > MAX_CHANNEL_NUMBER) @@ -475,7 +463,6 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) goto out; msleep_interruptible(IEEE80211_SOFTMAC_SCAN_TIME); - } out: if(ieee->state < IEEE80211_LINKED){ @@ -520,7 +507,6 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) if(channel_map[ieee->current_network.channel] == 1) ieee80211_send_probe_requests(ieee); - schedule_delayed_work(&ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); mutex_unlock(&ieee->scan_mutex); @@ -534,8 +520,6 @@ out: mutex_unlock(&ieee->scan_mutex); } - - static void ieee80211_beacons_start(struct ieee80211_device *ieee) { unsigned long flags; @@ -557,10 +541,8 @@ static void ieee80211_beacons_stop(struct ieee80211_device *ieee) del_timer_sync(&ieee->beacon_timer); spin_unlock_irqrestore(&ieee->beacon_lock, flags); - } - void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) { if(ieee->stop_send_beacons) @@ -624,7 +606,6 @@ static void ieee80211_start_scan(struct ieee80211_device *ieee) } }else ieee->start_scan(ieee->dev); - } /* called with wx_mutex held */ @@ -642,7 +623,6 @@ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) ieee80211_softmac_scan_syncro(ieee); else ieee->scan_syncro(ieee->dev); - } EXPORT_SYMBOL(ieee80211_start_scan_syncro); @@ -654,7 +634,6 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, struct ieee80211_authentication *auth; int len = sizeof(struct ieee80211_authentication) + challengelen + ieee->tx_headroom; - skb = dev_alloc_skb(len); if (!skb) return NULL; @@ -687,10 +666,8 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); return skb; - } - static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest) { u8 *tag; @@ -728,10 +705,8 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d else erp_len = 0; - crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); /* HT ralated element */ @@ -742,7 +717,6 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt); HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); - if (pHTInfo->bRegRT2RTAggregation) { tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; @@ -787,7 +761,6 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d if (encrypt) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP); beacon_buf->info_element[0].id = MFIE_TYPE_SSID; beacon_buf->info_element[0].len = ssid_len; @@ -842,7 +815,6 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d return skb; } - static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) { @@ -872,7 +844,6 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - if(ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); @@ -923,8 +894,6 @@ static struct sk_buff *ieee80211_auth_resp(struct ieee80211_device *ieee, memcpy(auth->header.addr1, dest, ETH_ALEN); auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - } static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, @@ -949,11 +918,8 @@ static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, (pwr ? IEEE80211_FCTL_PM:0)); return skb; - - } - static void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); @@ -962,7 +928,6 @@ static void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8 *dest) softmac_mgmt_xmit(buf, ieee); } - static void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8 *dest) { @@ -972,17 +937,13 @@ static void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, softmac_mgmt_xmit(buf, ieee); } - static void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) { - - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); if (buf) softmac_mgmt_xmit(buf, ieee); } - static inline struct sk_buff * ieee80211_association_req(struct ieee80211_network *beacon, struct ieee80211_device *ieee) @@ -1031,14 +992,12 @@ ieee80211_association_req(struct ieee80211_network *beacon, realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); - } } if (ieee->qos_support) { wmm_info_len = beacon->qos_data.supported?9:0; } - if (beacon->bCkipSupported) { ckip_ie_len = 30+2; @@ -1076,7 +1035,6 @@ ieee80211_association_req(struct ieee80211_network *beacon, + cxvernum_ie_len + ieee->tx_headroom; #endif - skb = dev_alloc_skb(len); if (!skb) @@ -1086,7 +1044,6 @@ ieee80211_association_req(struct ieee80211_network *beacon, hdr = skb_put(skb, sizeof(struct ieee80211_assoc_request_frame) + 2); - hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; hdr->header.duration_id = cpu_to_le16(37); memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); @@ -1182,7 +1139,6 @@ ieee80211_association_req(struct ieee80211_network *beacon, } } - //choose what wpa_supplicant gives to associate. if (wpa_ie_len) { skb_put_data(skb, ieee->wpa_ie, wpa_ie_len); @@ -1223,7 +1179,6 @@ ieee80211_association_req(struct ieee80211_network *beacon, void ieee80211_associate_abort(struct ieee80211_device *ieee) { - unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); @@ -1258,7 +1213,6 @@ static void ieee80211_associate_abort_cb(struct timer_list *t) ieee80211_associate_abort(dev); } - static void ieee80211_associate_step1(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; @@ -1430,7 +1384,6 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not @@ -1443,7 +1396,6 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid * if the network does broadcast and the user does not set essid it is OK @@ -1505,10 +1457,8 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); ieee->state = IEEE80211_LINKED; } - } } - } void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) @@ -1532,10 +1482,8 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) } spin_unlock_irqrestore(&ieee->lock, flags); - } - static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) { struct ieee80211_authentication *a; @@ -1558,10 +1506,8 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) } return le16_to_cpu(a->status); - } - static int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct ieee80211_authentication *a; @@ -1615,7 +1561,6 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); - } static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) @@ -1697,7 +1642,6 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) static inline void ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) { - u8 dest[ETH_ALEN]; //unsigned long flags; @@ -1713,7 +1657,6 @@ ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) static void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) { - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); if (buf) @@ -1767,13 +1710,10 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, } return 1; - - } static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) { - u32 th, tl; short sleep; @@ -1799,7 +1739,6 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) goto out; if(sleep == 1){ - if(ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev, th, tl); @@ -1808,8 +1747,6 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); if(ieee->ps_is_queue_empty(ieee->dev)){ - - ieee->sta_sleep = 2; ieee->ps_request_tx_ack(ieee->dev); @@ -1820,10 +1757,7 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) ieee->ps_tl = tl; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - } - - }else if(sleep == 2){ //#warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); @@ -1832,10 +1766,8 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - out: spin_unlock_irqrestore(&ieee->lock, flags); - } void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) @@ -1847,7 +1779,6 @@ void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) ieee80211_sta_ps_send_null_frame(ieee, 0); } return; - } if(ieee->sta_sleep == 1) @@ -1879,7 +1810,6 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) } /* 21112005 - tx again null without PS bit if lost */ else { - if ((ieee->sta_sleep == 0) && !success) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); ieee80211_sta_ps_send_null_frame(ieee, 0); @@ -1917,7 +1847,6 @@ static void ieee80211_process_action(struct ieee80211_device *ieee, break; } return; - } static void ieee80211_check_auth_response(struct ieee80211_device *ieee, @@ -2004,10 +1933,8 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, ieee->last_rx_ps_time = jiffies; switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && @@ -2060,7 +1987,6 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) @@ -2068,7 +1994,6 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, break; case IEEE80211_STYPE_AUTH: - if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA) { @@ -2082,7 +2007,6 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, break; case IEEE80211_STYPE_PROBE_REQ: - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && @@ -2140,7 +2064,6 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, */ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - unsigned int queue_index = txb->queue_index; unsigned long flags; int i; @@ -2215,12 +2138,10 @@ static void ieee80211_resume_tx(struct ieee80211_device *ieee) } } - ieee80211_txb_free(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } - void ieee80211_reset_queue(struct ieee80211_device *ieee) { unsigned long flags; @@ -2233,13 +2154,11 @@ void ieee80211_reset_queue(struct ieee80211_device *ieee) } ieee->queue_stop = 0; spin_unlock_irqrestore(&ieee->lock, flags); - } EXPORT_SYMBOL(ieee80211_reset_queue); void ieee80211_wake_queue(struct ieee80211_device *ieee) { - unsigned long flags; struct sk_buff *skb; struct rtl_80211_hdr_3addr *header; @@ -2272,7 +2191,6 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - exit : spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2289,7 +2207,6 @@ void ieee80211_stop_queue(struct ieee80211_device *ieee) } ieee->queue_stop = 1; //spin_unlock_irqrestore(&ieee->lock,flags); - } EXPORT_SYMBOL(ieee80211_stop_queue); @@ -2332,7 +2249,6 @@ static void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) } static void ieee80211_start_ibss_wq(struct work_struct *work) { - struct delayed_work *dwork = to_delayed_work(work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq); /* iwconfig mode ad-hoc will schedule this and return @@ -2357,7 +2273,6 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) /* check if we have this cell in our network list */ ieee80211_softmac_check_all_nets(ieee); - // if((IS_DOT11D_ENABLE(ieee)) && (ieee->state == IEEE80211_NOLINK)) if (ieee->state == IEEE80211_NOLINK) ieee->current_network.channel = 6; @@ -2392,7 +2307,6 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - }else ieee->current_network.rates_len = 0; @@ -2486,8 +2400,6 @@ void ieee80211_start_bss(struct ieee80211_device *ieee) /* called only in userspace context */ void ieee80211_disassociate(struct ieee80211_device *ieee) { - - netif_carrier_off(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) ieee80211_reset_queue(ieee); @@ -2501,7 +2413,6 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) ieee->link_change(ieee->dev); //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); notify_wx_assoc_event(ieee); - } EXPORT_SYMBOL(ieee80211_disassociate); @@ -2562,7 +2473,6 @@ struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); return skb; - } struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) @@ -2653,7 +2563,6 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) ieee->init_wmmparam_flag = 0;//reinitialize AC_xx_PARAM registers. - /* if the user set the MAC of the ad-hoc cell and then * switch to managed mode, shall we make sure that association * attempts does not fail just because the user provide the essid @@ -2672,7 +2581,6 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) ieee80211_start_monitor_mode(ieee); } - #define DRV_NAME "Ieee80211" void ieee80211_softmac_init(struct ieee80211_device *ieee) { @@ -2724,7 +2632,6 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) timer_setup(&ieee->beacon_timer, ieee80211_send_beacon_cb, 0); - INIT_DELAYED_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq); INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq); INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq); @@ -2732,7 +2639,6 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq); INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq); - mutex_init(&ieee->wx_mutex); mutex_init(&ieee->scan_mutex); @@ -2742,7 +2648,6 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) tasklet_init(&ieee->ps_task, (void(*)(unsigned long)) ieee80211_sta_ps, (unsigned long)ieee); - } void ieee80211_softmac_free(struct ieee80211_device *ieee) @@ -2761,8 +2666,6 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee) * Start of WPA code. * * this is stolen from the ipw2200 driver * ********************************************************/ - - static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver @@ -2772,7 +2675,6 @@ static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) return 0; } - static void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { @@ -2782,10 +2684,8 @@ static void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, ieee80211_disassociate(ieee); } - static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) { - int ret = 0; switch (command) { @@ -2805,7 +2705,6 @@ static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int re return ret; } - static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { @@ -2839,7 +2738,6 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) { - struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2859,7 +2757,6 @@ static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) ieee->auth_mode = 2; } - if (ieee->set_security) ieee->set_security(ieee->dev, &sec); //else @@ -2943,7 +2840,6 @@ static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 v } /* implementation borrowed from hostap driver */ - static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { @@ -3117,7 +3013,6 @@ static inline struct sk_buff *ieee80211_disassociate_skb( return skb; } - void SendDisassociation( struct ieee80211_device *ieee, From 5d22905819bc56292f10e0f3b63c201caad97aed Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:52 +0100 Subject: [PATCH 258/903] staging: rtl8192u: Add space required around '==' opeartor - Style Simple addition of the coding style required spaces around '==' operator. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 7ef761632629..0e4d1febd958 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -193,8 +193,8 @@ static u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee) if (rate == 0) { /* 2005.01.26, by rcnjko. */ if(ieee->mode == IEEE_A|| - ieee->mode== IEEE_N_5G|| - (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) + ieee->mode == IEEE_N_5G|| + (ieee->mode == IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) rate = 0x0c; else rate = 0x02; @@ -1315,7 +1315,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) } ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); // To prevent the immediately calling watch_dog after association. - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0||ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; @@ -1391,8 +1391,8 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee */ apset = ieee->wap_set;//(memcmp(ieee->current_network.bssid, zero,ETH_ALEN)!=0 ); ssidset = ieee->ssid_set;//ieee->current_network.ssid[0] != '\0'; - ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); - apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); + ssidbroad = !(net->ssid_len == 0 || net->ssid[0] == '\0'); + apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN) == 0); ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); @@ -1595,8 +1595,8 @@ static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb *aid = le16_to_cpu(response_head->aid) & 0x3fff; status_code = le16_to_cpu(response_head->status); - if((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \ - status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&& + if((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || \ + status_code == WLAN_STATUS_CAPS_UNSUPPORTED)&& ((ieee->mode == IEEE_G) && (ieee->current_network.mode == IEEE_N_24G) && (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { From bb81b8241fbfe8356b5f1c9d641fb45f81a76bc3 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:53 +0100 Subject: [PATCH 259/903] staging: rtl8192u: Add required spaces around '||' operator - Sytle Additon of the coding style required spaces around the '||' operator. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 0e4d1febd958..337d86effa69 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -192,8 +192,8 @@ static u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee) if (rate == 0) { /* 2005.01.26, by rcnjko. */ - if(ieee->mode == IEEE_A|| - ieee->mode == IEEE_N_5G|| + if(ieee->mode == IEEE_A || + ieee->mode == IEEE_N_5G || (ieee->mode == IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) rate = 0x0c; else @@ -265,8 +265,8 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee ieee->seq_ctrl[0]++; /* check whether the managed packet queued greater than 5 */ - if(!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\ - (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\ + if(!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index) ||\ + (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) ||\ (ieee->queue_stop) ) { /* insert the skb packet to the management queue */ /* as for the completion function, it does not need @@ -1315,7 +1315,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) } ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); // To prevent the immediately calling watch_dog after association. - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0||ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; @@ -2088,7 +2088,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * #else if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) || #endif - (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\ + (!ieee->check_nic_enough_desc(ieee->dev,queue_index)) || \ (ieee->queue_stop)) { /* insert the skb packet to the wait queue */ /* as for the completion function, it does not need From e19532885f52c9ea2f3eea4ebfa309287ce1ecdf Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:54 +0100 Subject: [PATCH 260/903] staging: rtl8192u: Remove space after cast - Coding Style According to checkpatch - No space is necessary after a cast. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 337d86effa69..e7b5cd896f02 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -220,7 +220,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct rtl_80211_hdr_3addr *header= - (struct rtl_80211_hdr_3addr *) skb->data; + (struct rtl_80211_hdr_3addr *)skb->data; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); @@ -287,7 +287,7 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) { short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct rtl_80211_hdr_3addr *header = - (struct rtl_80211_hdr_3addr *) skb->data; + (struct rtl_80211_hdr_3addr *)skb->data; if(single){ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -710,9 +710,9 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); /* HT ralated element */ - tmp_ht_cap_buf =(u8 *) &(ieee->pHTInfo->SelfHTCap); + tmp_ht_cap_buf =(u8 *)&(ieee->pHTInfo->SelfHTCap); tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - tmp_ht_info_buf =(u8 *) &(ieee->pHTInfo->SelfHTInfo); + tmp_ht_info_buf =(u8 *)&(ieee->pHTInfo->SelfHTInfo); tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt); HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); @@ -765,7 +765,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d beacon_buf->info_element[0].id = MFIE_TYPE_SSID; beacon_buf->info_element[0].len = ssid_len; - tag = (u8 *) beacon_buf->info_element[0].data; + tag = (u8 *)beacon_buf->info_element[0].data; memcpy(tag, ssid, ssid_len); @@ -1493,7 +1493,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) return 0xcafe; } *challenge = NULL; - a = (struct ieee80211_authentication *) skb->data; + a = (struct ieee80211_authentication *)skb->data; if (skb->len > (sizeof(struct ieee80211_authentication) + 3)) { t = skb->data + sizeof(struct ieee80211_authentication); @@ -1516,7 +1516,7 @@ static int auth_rq_parse(struct sk_buff *skb, u8 *dest) IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); return -1; } - a = (struct ieee80211_authentication *) skb->data; + a = (struct ieee80211_authentication *)skb->data; memcpy(dest,a->header.addr2, ETH_ALEN); @@ -1534,7 +1534,7 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 ssidlen = 0; struct rtl_80211_hdr_3addr *header = - (struct rtl_80211_hdr_3addr *) skb->data; + (struct rtl_80211_hdr_3addr *)skb->data; if (skb->len < sizeof (struct rtl_80211_hdr_3addr )) return -1; /* corrupted */ @@ -1574,7 +1574,7 @@ static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) return -1; } - a = (struct ieee80211_assoc_request_frame *) skb->data; + a = (struct ieee80211_assoc_request_frame *)skb->data; memcpy(dest,a->header.addr2,ETH_ALEN); @@ -1591,7 +1591,7 @@ static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb return 0xcafe; } - response_head = (struct ieee80211_assoc_response_frame *) skb->data; + response_head = (struct ieee80211_assoc_response_frame *)skb->data; *aid = le16_to_cpu(response_head->aid) & 0x3fff; status_code = le16_to_cpu(response_head->status); @@ -1913,7 +1913,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { - struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *)skb->data; u16 errcode; int aid; struct ieee80211_assoc_response_frame *assoc_resp; @@ -2171,7 +2171,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - header = (struct rtl_80211_hdr_3addr *) skb->data; + header = (struct rtl_80211_hdr_3addr *)skb->data; header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -2469,7 +2469,7 @@ struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) if (!skb) return NULL; - b = (struct ieee80211_probe_response *) skb->data; + b = (struct ieee80211_probe_response *)skb->data; b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); return skb; @@ -2484,7 +2484,7 @@ struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) if(!skb) return NULL; - b = (struct ieee80211_probe_response *) skb->data; + b = (struct ieee80211_probe_response *)skb->data; b->header.seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -2857,7 +2857,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; if (param_len != - (int) ((char *) param->u.crypt.key - (char *) param) + + (int)((char *)param->u.crypt.key - (char *)param) + param->u.crypt.key_len) { printk("Len mismatch %d, %d\n", param_len, param->u.crypt.key_len); From 60ecbaae5e3ba21a43ebf6b83de10d5aa34a85eb Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:55 +0100 Subject: [PATCH 261/903] staging: rtl8192u: Add required space around '=' operator - Style checkpatch requires spaces around '=' operator so added. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index e7b5cd896f02..c7c391b1077e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -219,7 +219,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct rtl_80211_hdr_3addr *header= + struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *)skb->data; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); @@ -686,12 +686,12 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d u8 erpinfo_content = 0; u8 *tmp_ht_cap_buf; - u8 tmp_ht_cap_len=0; + u8 tmp_ht_cap_len = 0; u8 *tmp_ht_info_buf; - u8 tmp_ht_info_len=0; + u8 tmp_ht_info_len = 0; PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - u8 *tmp_generic_ie_buf=NULL; - u8 tmp_generic_ie_len=0; + u8 *tmp_generic_ie_buf = NULL; + u8 tmp_generic_ie_len = 0; if(rate_ex_len > 0) rate_ex_len+=2; @@ -710,9 +710,9 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); /* HT ralated element */ - tmp_ht_cap_buf =(u8 *)&(ieee->pHTInfo->SelfHTCap); + tmp_ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - tmp_ht_info_buf =(u8 *)&(ieee->pHTInfo->SelfHTInfo); + tmp_ht_info_buf = (u8 *)&(ieee->pHTInfo->SelfHTInfo); tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt); HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); @@ -858,7 +858,7 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); - if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; + if (ieee->assoc_id == 0x2007) ieee->assoc_id = 0; else ieee->assoc_id++; tag = skb_put(skb, rate_len); @@ -960,13 +960,13 @@ ieee80211_association_req(struct ieee80211_network *beacon, //unsigned int wpa_len = beacon->wpa_ie_len; //for HT u8 *ht_cap_buf = NULL; - u8 ht_cap_len=0; - u8 *realtek_ie_buf=NULL; - u8 realtek_ie_len=0; - int wpa_ie_len= ieee->wpa_ie_len; - unsigned int ckip_ie_len=0; - unsigned int ccxrm_ie_len=0; - unsigned int cxvernum_ie_len=0; + u8 ht_cap_len = 0; + u8 *realtek_ie_buf = NULL; + u8 realtek_ie_len = 0; + int wpa_ie_len = ieee->wpa_ie_len; + unsigned int ckip_ie_len = 0; + unsigned int ccxrm_ie_len = 0; + unsigned int cxvernum_ie_len = 0; struct ieee80211_crypt_data *crypt; int encrypt; @@ -1221,7 +1221,7 @@ static void ieee80211_associate_step1(struct ieee80211_device *ieee) IEEE80211_DEBUG_MGMT("Stopping scan\n"); ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); + skb = ieee80211_authentication_req(beacon, ieee, 0); if (!skb) ieee80211_associate_abort(ieee); @@ -1280,7 +1280,7 @@ static void ieee80211_associate_step2(struct ieee80211_device *ieee) IEEE80211_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); + skb = ieee80211_association_req(beacon, ieee); if (!skb) ieee80211_associate_abort(ieee); else{ @@ -1318,7 +1318,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } ieee->link_change(ieee->dev); if (!ieee->is_silent_reset) { @@ -1530,7 +1530,7 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, { u8 *tag; u8 *skbend; - u8 *ssid=NULL; + u8 *ssid = NULL; u8 ssidlen = 0; struct rtl_80211_hdr_3addr *header = @@ -1945,7 +1945,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, errcode = assoc_parse(ieee, skb, &aid); if (!errcode) { - ieee->state=IEEE80211_LINKED; + ieee->state = IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; /* station support qos */ @@ -2597,8 +2597,8 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n"); //added for AP roaming ieee->LinkDetectInfo.SlotNum = 2; - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; ieee->assoc_id = 0; ieee->queue_stop = 0; @@ -2611,9 +2611,9 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) ieee->rate = 22; ieee->ps = IEEE80211_PS_DISABLED; ieee->sta_sleep = 0; - ieee->Regdot11HTOperationalRateSet[0]= 0xff;//support MCS 0~7 - ieee->Regdot11HTOperationalRateSet[1]= 0xff;//support MCS 8~15 - ieee->Regdot11HTOperationalRateSet[4]= 0x01; + ieee->Regdot11HTOperationalRateSet[0] = 0xff;//support MCS 0~7 + ieee->Regdot11HTOperationalRateSet[1] = 0xff;//support MCS 8~15 + ieee->Regdot11HTOperationalRateSet[4] = 0x01; //added by amy ieee->actscanning = false; ieee->beinretry = false; From 4031e6ca35993fd5818d2ddf3ced5351b1d46c36 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 4 Jul 2018 15:20:56 +0100 Subject: [PATCH 262/903] staging: rtl8192u: Add space after ', ' character - Coding Style checkpatch requires a space after ',' - Added. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index c7c391b1077e..5895d6e5eb67 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -248,7 +248,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee /* avoid watchdog triggers */ netif_trans_update(ieee->dev); - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); //dev_kfree_skb_any(skb);//edit by thomas } @@ -265,14 +265,14 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee ieee->seq_ctrl[0]++; /* check whether the managed packet queued greater than 5 */ - if(!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index) ||\ + if(!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||\ (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) ||\ (ieee->queue_stop) ) { /* insert the skb packet to the management queue */ /* as for the completion function, it does not need * to check it any more. * */ - printk("%s():insert to waitqueue!\n",__func__); + printk("%s():insert to waitqueue!\n", __func__); skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); } else { ieee->softmac_hard_start_xmit(skb, ieee->dev); @@ -299,7 +299,7 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) /* avoid watchdog triggers */ netif_trans_update(ieee->dev); - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -347,8 +347,8 @@ static inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) memcpy(tag, ieee->current_network.ssid, len); tag += len; - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + ieee80211_MFIE_Brate(ieee, &tag); + ieee80211_MFIE_Grate(ieee, &tag); return skb; } @@ -523,7 +523,7 @@ out: static void ieee80211_beacons_start(struct ieee80211_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 1; ieee80211_send_beacon(ieee); @@ -659,7 +659,7 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, auth->algorithm = cpu_to_le16(WLAN_AUTH_SHARED_KEY); else if(ieee->auth_mode == 2) auth->algorithm = WLAN_AUTH_OPEN; /* 0x80; */ - printk("=================>%s():auth->algorithm is %d\n",__func__,auth->algorithm); + printk("=================>%s():auth->algorithm is %d\n", __func__, auth->algorithm); auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; @@ -714,8 +714,8 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); tmp_ht_info_buf = (u8 *)&(ieee->pHTInfo->SelfHTInfo); tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); - HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt); - HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); + HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len, encrypt); + HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len, encrypt); if (pHTInfo->bRegRT2RTAggregation) { @@ -742,7 +742,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d return NULL; skb_reserve(skb, ieee->tx_headroom); beacon_buf = skb_put(skb, (beacon_size - ieee->tx_headroom)); - memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); + memcpy (beacon_buf->header.addr1, dest, ETH_ALEN); memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); @@ -838,7 +838,7 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, assoc = skb_put(skb, sizeof(struct ieee80211_assoc_response_frame)); assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); - memcpy(assoc->header.addr1, dest,ETH_ALEN); + memcpy(assoc->header.addr1, dest, ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? @@ -979,7 +979,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, int len = 0; crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len)); + encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); /* Include High Throuput capability && Realtek proprietary */ if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) @@ -1419,7 +1419,12 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); ieee->current_network.ssid_len = tmp_ssid_len; - printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT); + printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d\n", + ieee->current_network.ssid, + ieee->current_network.channel, + ieee->current_network.qos_data.supported, + ieee->pHTInfo->bEnableHT, + ieee->current_network.bssht.bdSupportHT); //ieee->pHTInfo->IOTAction = 0; HTResetIOTSetting(ieee->pHTInfo); @@ -1489,7 +1494,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) struct ieee80211_authentication *a; u8 *t; if (skb->len < (sizeof(struct ieee80211_authentication) - sizeof(struct ieee80211_info_element))) { - IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); + IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } *challenge = NULL; @@ -1513,12 +1518,12 @@ static int auth_rq_parse(struct sk_buff *skb, u8 *dest) struct ieee80211_authentication *a; if (skb->len < (sizeof(struct ieee80211_authentication) - sizeof(struct ieee80211_info_element))) { - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n", skb->len); return -1; } a = (struct ieee80211_authentication *)skb->data; - memcpy(dest,a->header.addr2, ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; @@ -1539,7 +1544,7 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, if (skb->len < sizeof (struct rtl_80211_hdr_3addr )) return -1; /* corrupted */ - memcpy(src,header->addr2, ETH_ALEN); + memcpy(src, header->addr2, ETH_ALEN); skbend = (u8 *)skb->data + skb->len; @@ -1576,7 +1581,7 @@ static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) a = (struct ieee80211_assoc_request_frame *)skb->data; - memcpy(dest,a->header.addr2,ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); return 0; } @@ -1733,7 +1738,7 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); + sleep = ieee80211_sta_ps_sleep(ieee, &th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ if(sleep == 0) goto out; @@ -1802,7 +1807,7 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) /* Null frame with PS bit set */ if (success) { ieee->sta_sleep = 1; - ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); + ieee->enter_sleep_state(ieee->dev, ieee->ps_th, ieee->ps_tl); } /* if the card report not success we can't be sure the AP * has not RXed so we can't assume the AP believe us awake @@ -1953,9 +1958,9 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, if (ieee->qos_support) { assoc_resp = (struct ieee80211_assoc_response_frame *)skb->data; memset(network, 0, sizeof(*network)); - if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\ + if (ieee80211_parse_info_param(ieee, assoc_resp->info_element,\ rx_stats->len - sizeof(*assoc_resp),\ - network,rx_stats)){ + network, rx_stats)){ return 1; } else @@ -2088,7 +2093,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * #else if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) || #endif - (!ieee->check_nic_enough_desc(ieee->dev,queue_index)) || \ + (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) || \ (ieee->queue_stop)) { /* insert the skb packet to the wait queue */ /* as for the completion function, it does not need @@ -2180,7 +2185,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) else ieee->seq_ctrl[0]++; - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); //dev_kfree_skb_any(skb);//edit by thomas } } @@ -3071,7 +3076,7 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_poin break; default: - printk("Unknown WPA supplicant request: %d\n",param->cmd); + printk("Unknown WPA supplicant request: %d\n", param->cmd); ret = -EOPNOTSUPP; break; } From 4cc4dbbc0946c31b0988bb44eea19d759b054351 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Fri, 6 Jul 2018 23:43:10 -0700 Subject: [PATCH 263/903] drivers/staging/gasket: Use refcount_read() Use the refcount_read accessor function, avoid reaching into refcount and atomic struct fields. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index 40268fb50fc3..a3705d6e088a 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -122,7 +122,7 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) } mutex_lock(&mapping->mutex); - if (mapping->refcount.refcount.refs.counter == 0) + if (refcount_read(&mapping->refcount.refcount) == 0) gasket_nodev_error("Refcount is already 0!"); if (kref_put(&mapping->refcount, release_entry)) { gasket_nodev_info("Removing Gasket sysfs mapping, device %s", From b6c319606eb62c393a95bc53f9d4cbee31d5b88d Mon Sep 17 00:00:00 2001 From: Peter Vernia Date: Sat, 7 Jul 2018 03:07:55 -0400 Subject: [PATCH 264/903] staging: mt7621-pci: Fix spaces around parenthesis in pci-7621.c Adds spaces before open parenthesis, and removes spaces after open parenthesis Signed-off-by: Peter Vernia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index b373d761312a..ded58bad08e7 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -139,14 +139,14 @@ rt_sysc_m32(0, val, RALINK_RSTCTRL); \ else \ rt_sysc_m32(val, 0, RALINK_RSTCTRL); \ - } while(0) + } while (0) #define DEASSERT_SYSRST_PCIE(val) \ do { \ if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101) \ rt_sysc_m32(val, 0, RALINK_RSTCTRL); \ else \ rt_sysc_m32(0, val, RALINK_RSTCTRL); \ - } while(0) + } while (0) #define RALINK_CLKCFG1 0x30 #define RALINK_RSTCTRL 0x34 #define RALINK_GPIOMODE 0x60 @@ -195,7 +195,7 @@ static int config_access(unsigned char access_type, struct pci_bus *bus, (func << 8) | (where & 0xfc) | 0x80000000; MV_WRITE(address_reg, address); - switch(access_type) { + switch (access_type) { case PCI_ACCESS_WRITE_1: MV_WRITE_8(data_reg+(where&0x3), *data); break; @@ -206,7 +206,7 @@ static int config_access(unsigned char access_type, struct pci_bus *bus, MV_WRITE(data_reg, *data); break; case PCI_ACCESS_READ_1: - MV_READ_8( data_reg+(where&0x3), data); + MV_READ_8(data_reg+(where&0x3), data); break; case PCI_ACCESS_READ_2: MV_READ_16(data_reg+(where&0x3), data); @@ -391,7 +391,7 @@ set_phy_for_ssc(void) set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 1 enable control set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x00); // rg_pe1_phy_en //Port 1 disable - if(reg <= 5 && reg >= 3) { // 40MHz Xtal + if (reg <= 5 && reg >= 3) { // 40MHz Xtal set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) printk("***** Xtal 40MHz *****\n"); } else { // 25MHz | 20MHz Xtal @@ -414,7 +414,7 @@ set_phy_for_ssc(void) set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN - if(reg <= 5 && reg >= 3) { // 40MHz Xtal + if (reg <= 5 && reg >= 3) { // 40MHz Xtal set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv } @@ -430,7 +430,7 @@ set_phy_for_ssc(void) set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable - if(reg <= 5 && reg >= 3) { // 40MHz Xtal + if (reg <= 5 && reg >= 3) { // 40MHz Xtal set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) } else { // 25MHz | 20MHz Xtal set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) @@ -449,7 +449,7 @@ set_phy_for_ssc(void) set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN - if(reg <= 5 && reg >= 3) { // 40MHz Xtal + if (reg <= 5 && reg >= 3) { // 40MHz Xtal set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv } @@ -532,7 +532,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) *(unsigned int *)(0xbe000620) |= 0x1<<19 | 0x1<<8 | 0x1<<7; // set DATA mdelay(1000); - if(( RALINK_PCI0_STATUS & 0x1) == 0) + if ((RALINK_PCI0_STATUS & 0x1) == 0) { printk("PCIE0 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST); @@ -543,7 +543,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt } - if(( RALINK_PCI1_STATUS & 0x1) == 0) + if ((RALINK_PCI1_STATUS & 0x1) == 0) { printk("PCIE1 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE1_RST); @@ -554,7 +554,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) RALINK_PCI_PCIMSK_ADDR |= (1<<21); // enable pcie1 interrupt } - if (( RALINK_PCI2_STATUS & 0x1) == 0) { + if ((RALINK_PCI2_STATUS & 0x1) == 0) { printk("PCIE2 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE2_RST); rt_sysc_m32(RALINK_PCIE2_CLK_EN, 0, RALINK_CLKCFG1); @@ -578,7 +578,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num 3'b110 1 0 x 3'b111 2 1 0 */ - switch(pcie_link_status) { + switch (pcie_link_status) { case 2: RALINK_PCI_PCICFG_ADDR &= ~0x00ff0000; RALINK_PCI_PCICFG_ADDR |= 0x1 << 16; //port0 @@ -613,7 +613,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num RALINK_PCI_IOBASE = RALINK_PCI_IO_MAP_BASE; //PCIe0 - if((pcie_link_status & 0x1) != 0) { + if ((pcie_link_status & 0x1) != 0) { RALINK_PCI0_BAR0SETUP_ADDR = 0x7FFF0001; //open 7FFF:2G; ENABLE RALINK_PCI0_IMBASEBAR0_ADDR = MEMORY_BASE; RALINK_PCI0_CLASS = 0x06040001; @@ -636,7 +636,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num printk("PCIE2 enabled\n"); } - switch(pcie_link_status) { + switch (pcie_link_status) { case 7: read_config(0, 2, 0, 0x4, &val); write_config(0, 2, 0, 0x4, val|0x4); From d723b7cca52b89de0945cd7f90fad3c49930b394 Mon Sep 17 00:00:00 2001 From: Peter Vernia Date: Sat, 7 Jul 2018 03:08:36 -0400 Subject: [PATCH 265/903] staging: mt7621-pci: Fix spacing around equals sign Add spaces in front of the equals sign in assignment operations Signed-off-by: Peter Vernia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index ded58bad08e7..c7932ae00db1 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -292,7 +292,7 @@ pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u } } -struct pci_ops mt7621_pci_ops= { +struct pci_ops mt7621_pci_ops = { .read = pci_config_read, .write = pci_config_write, }; @@ -480,8 +480,8 @@ static int mt7621_pci_probe(struct platform_device *pdev) unsigned long val = 0; iomem_resource.start = 0; - iomem_resource.end= ~0; - ioport_resource.start= 0; + iomem_resource.end = ~0; + ioport_resource.start = 0; ioport_resource.end = ~0; val = RALINK_PCIE0_RST; From bd84b268351db4bd26843974a3c0ca917f7e0cca Mon Sep 17 00:00:00 2001 From: Peter Vernia Date: Sat, 7 Jul 2018 03:09:19 -0400 Subject: [PATCH 266/903] staging: mt7621-pci: Add spaces after commas in pci-mt7621.c Adds spaces after commas in parameter lists in pci-mt7621.c Signed-off-by: Peter Vernia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index c7932ae00db1..3c7978e4355d 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -399,10 +399,10 @@ set_phy_for_ssc(void) if (reg >= 6) { printk("***** Xtal 25MHz *****\n"); set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x49c), 0,31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a4), 0,16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 0,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 16,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial } else { printk("***** Xtal 20MHz *****\n"); } @@ -436,10 +436,10 @@ set_phy_for_ssc(void) set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) if (reg >= 6) { // 25MHz Xtal set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x49c), 0,31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a4), 0,16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 0,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 16,12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control + set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial } } set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion From 4cd6bacfaa74ecf15b5e6f50b94100d62f00c52c Mon Sep 17 00:00:00 2001 From: Peter Vernia Date: Sat, 7 Jul 2018 03:10:22 -0400 Subject: [PATCH 267/903] staging: mt7621-pci: Move open-braces to match kernel code style Moves some open-braces to the end of the conditional statement to match the kernel's coding style Signed-off-by: Peter Vernia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 3c7978e4355d..c12447dfbc0f 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -532,8 +532,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) *(unsigned int *)(0xbe000620) |= 0x1<<19 | 0x1<<8 | 0x1<<7; // set DATA mdelay(1000); - if ((RALINK_PCI0_STATUS & 0x1) == 0) - { + if ((RALINK_PCI0_STATUS & 0x1) == 0) { printk("PCIE0 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST); rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1); @@ -543,8 +542,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt } - if ((RALINK_PCI1_STATUS & 0x1) == 0) - { + if ((RALINK_PCI1_STATUS & 0x1) == 0) { printk("PCIE1 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE1_RST); rt_sysc_m32(RALINK_PCIE1_CLK_EN, 0, RALINK_CLKCFG1); From 33d77fc00e9027266884a2dbcffd9b9f75ef39ad Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 6 Jul 2018 20:54:37 -0700 Subject: [PATCH 268/903] staging/rtl8192u: fix defined but not used build warnings Fix build warnings in rtl8192u when CONFIG_PROC_FS is not enabled by marking the unused functions as __maybe_unused. ../drivers/staging/rtl8192u/r8192U_core.c:508:12: warning: 'proc_get_stats_ap' defined but not used [-Wunused-function] ../drivers/staging/rtl8192u/r8192U_core.c:527:12: warning: 'proc_get_registers' defined but not used [-Wunused-function] ../drivers/staging/rtl8192u/r8192U_core.c:568:12: warning: 'proc_get_stats_tx' defined but not used [-Wunused-function] ../drivers/staging/rtl8192u/r8192U_core.c:627:12: warning: 'proc_get_stats_rx' defined but not used [-Wunused-function] Signed-off-by: Randy Dunlap Cc: Jerry chuang Cc: devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 1 + drivers/staging/rtl8192u/r8192U_core.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 51c150a39fc2..215f618c6760 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -18,6 +18,7 @@ #ifndef R819xU_H #define R819xU_H +#include #include #include #include diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 74c5865cf8c8..848239e24859 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -505,7 +505,7 @@ static void watch_dog_timer_callback(struct timer_list *t); static struct proc_dir_entry *rtl8192_proc; -static int proc_get_stats_ap(struct seq_file *m, void *v) +static int __maybe_unused proc_get_stats_ap(struct seq_file *m, void *v) { struct net_device *dev = m->private; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); @@ -524,7 +524,7 @@ static int proc_get_stats_ap(struct seq_file *m, void *v) return 0; } -static int proc_get_registers(struct seq_file *m, void *v) +static int __maybe_unused proc_get_registers(struct seq_file *m, void *v) { struct net_device *dev = m->private; int i, n, max = 0xff; @@ -565,7 +565,7 @@ static int proc_get_registers(struct seq_file *m, void *v) return 0; } -static int proc_get_stats_tx(struct seq_file *m, void *v) +static int __maybe_unused proc_get_stats_tx(struct seq_file *m, void *v) { struct net_device *dev = m->private; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); @@ -624,7 +624,7 @@ static int proc_get_stats_tx(struct seq_file *m, void *v) return 0; } -static int proc_get_stats_rx(struct seq_file *m, void *v) +static int __maybe_unused proc_get_stats_rx(struct seq_file *m, void *v) { struct net_device *dev = m->private; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); From 0148f49c118ad786fedf64621ac0037475a027fa Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 6 Jul 2018 20:38:13 +0100 Subject: [PATCH 269/903] staging: wlan-ng: fix expression continuation in prism2fw.c checkpatch reports "CHECK: Logical continuations should be on the previous line" when a continuation line begins with an operator. Reformat the code so that the operator appears at the end of the line being continued. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2fw.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index 5860d0d65841..4fb91294570d 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -1189,9 +1189,10 @@ static int validate_identity(void) /* PRI compat range */ if ((s3info[i].info.compat.role == 1) && (s3info[i].info.compat.id == 3)) { - if ((s3info[i].info.compat.bottom > priid.top) - || (s3info[i].info.compat.top < - priid.bottom)) { + if ((s3info[i].info.compat.bottom > + priid.top) || + (s3info[i].info.compat.top < + priid.bottom)) { result = 3; } } From e47b374ce4bec599f792d55ff9bcaa1f5322778c Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 6 Jul 2018 20:38:14 +0100 Subject: [PATCH 270/903] staging: wlan-ng: fix expression continuation in prism2mgmt.c checkpatch reports "CHECK: Logical continuations should be on the previous line" when a continuation line begins with an operator. Reformat the code so that the operator appears at the end of the line being continued. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mgmt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index ebfe69b138c7..13fff7b19fb6 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -1269,9 +1269,8 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) goto failed; } if ((msg->keepwepflags.status == - P80211ENUM_msgitem_status_data_ok) - && (msg->keepwepflags.data != - P80211ENUM_truth_true)) { + P80211ENUM_msgitem_status_data_ok) && + (msg->keepwepflags.data != P80211ENUM_truth_true)) { /* Set the wepflags for no decryption */ word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; @@ -1291,8 +1290,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) } /* Do we want to strip the FCS in monitor mode? */ - if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok) - && (msg->stripfcs.data == P80211ENUM_truth_true)) { + if ((msg->stripfcs.status == + P80211ENUM_msgitem_status_data_ok) && + (msg->stripfcs.data == P80211ENUM_truth_true)) { hw->sniff_fcs = 0; } else { hw->sniff_fcs = 1; From 460f6f8b24ff94fbd9635502e2339dda7927f556 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 6 Jul 2018 20:38:15 +0100 Subject: [PATCH 271/903] staging: wlan-ng: remove unneeded parentheses from prism2mgmt.c remove parentheses reported as unnecessary by checkpatch Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mgmt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index 13fff7b19fb6..7350fe5d96a3 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -414,7 +414,7 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) goto exit; } - item = &(hw->scanresults->info.hscanresult.result[req->bssindex.data]); + item = &hw->scanresults->info.hscanresult.result[req->bssindex.data]; /* signal and noise */ req->signal.status = P80211ENUM_msgitem_status_data_ok; req->noise.status = P80211ENUM_msgitem_status_data_ok; @@ -1075,7 +1075,7 @@ int prism2mgmt_autojoin(struct wlandevice *wlandev, void *msgp) /* Set the ssid */ memset(bytebuf, 0, 256); - pstr = (struct p80211pstrd *)&(msg->ssid.data); + pstr = (struct p80211pstrd *)&msg->ssid.data; prism2mgmt_pstr2bytestr(p2bytestr, pstr); result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, bytebuf, @@ -1199,7 +1199,7 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) /* Save macport 0 state */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFPORTTYPE, - &(hw->presniff_port_type)); + &hw->presniff_port_type); if (result) { netdev_dbg (wlandev->netdev, @@ -1210,7 +1210,7 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) /* Save the wepflags state */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFWEPFLAGS, - &(hw->presniff_wepflags)); + &hw->presniff_wepflags); if (result) { netdev_dbg (wlandev->netdev, From 7898a516c35639af4cc9e634ec5c144a191f50c6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 7 Jul 2018 13:38:40 +0200 Subject: [PATCH 272/903] staging: rtl8723bs: remove rtw_br_ext.h The header rtw_br_ext.h is not used anywhere. 'git grep rtw_br_ext.h' returns nothing, remove the file. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/include/rtw_br_ext.h | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 drivers/staging/rtl8723bs/include/rtw_br_ext.h diff --git a/drivers/staging/rtl8723bs/include/rtw_br_ext.h b/drivers/staging/rtl8723bs/include/rtw_br_ext.h deleted file mode 100644 index 5eaeb3c9a97c..000000000000 --- a/drivers/staging/rtl8723bs/include/rtw_br_ext.h +++ /dev/null @@ -1,55 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_BR_EXT_H_ -#define _RTW_BR_EXT_H_ - -#define MACADDRLEN 6 -#define _DEBUG_ERR DBG_8192C -#define _DEBUG_INFO /* DBG_8192C */ -#define DEBUG_WARN DBG_8192C -#define DEBUG_INFO /* DBG_8192C */ -#define DEBUG_ERR DBG_8192C -/* define GET_MY_HWADDR ((GET_MIB(priv))->dot11OperationEntry.hwaddr) */ -#define GET_MY_HWADDR(padapter) ((padapter)->eeprompriv.mac_addr) - -#define NAT25_HASH_BITS 4 -#define NAT25_HASH_SIZE (1 << NAT25_HASH_BITS) -#define NAT25_AGEING_TIME 300 - -#define MAX_NETWORK_ADDR_LEN 17 - -struct nat25_network_db_entry -{ - struct nat25_network_db_entry *next_hash; - struct nat25_network_db_entry **pprev_hash; - atomic_t use_count; - unsigned char macAddr[6]; - unsigned long ageing_timer; - unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; -}; - -enum NAT25_METHOD { - NAT25_MIN, - NAT25_CHECK, - NAT25_INSERT, - NAT25_LOOKUP, - NAT25_PARSE, - NAT25_MAX -}; - -struct br_ext_info { - unsigned int nat25_disable; - unsigned int macclone_enable; - unsigned int dhcp_bcst_disable; - int addPPPoETag; /* 1: Add PPPoE relay-SID, 0: disable */ - unsigned char nat25_dmzMac[MACADDRLEN]; - unsigned int nat25sc_disable; -}; - -void nat25_db_cleanup(struct adapter *priv); - -#endif /* _RTW_BR_EXT_H_ */ From 50730e79a2af78c592c72f3c335de7ffc0409626 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 7 Jul 2018 13:38:41 +0200 Subject: [PATCH 273/903] staging: rtl8723bs: remove rtw_beamforming.h The header rtw_beamforming.h is not used anywhere. 'git grep rtw_beamforming.h' returns nothing, remove the file. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../rtl8723bs/include/rtw_beamforming.h | 127 ------------------ 1 file changed, 127 deletions(-) delete mode 100644 drivers/staging/rtl8723bs/include/rtw_beamforming.h diff --git a/drivers/staging/rtl8723bs/include/rtw_beamforming.h b/drivers/staging/rtl8723bs/include/rtw_beamforming.h deleted file mode 100644 index 031496c8c02c..000000000000 --- a/drivers/staging/rtl8723bs/include/rtw_beamforming.h +++ /dev/null @@ -1,127 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_BEAMFORMING_H_ -#define __RTW_BEAMFORMING_H_ - -#define BEAMFORMING_ENTRY_NUM 2 -#define GET_BEAMFORM_INFO(_pmlmepriv) ((struct beamforming_info *)(&(_pmlmepriv)->beamforming_info)) - -typedef enum _BEAMFORMING_ENTRY_STATE -{ - BEAMFORMING_ENTRY_STATE_UNINITIALIZE, - BEAMFORMING_ENTRY_STATE_INITIALIZEING, - BEAMFORMING_ENTRY_STATE_INITIALIZED, - BEAMFORMING_ENTRY_STATE_PROGRESSING, - BEAMFORMING_ENTRY_STATE_PROGRESSED, -}BEAMFORMING_ENTRY_STATE, *PBEAMFORMING_ENTRY_STATE; - - -typedef enum _BEAMFORMING_STATE -{ - BEAMFORMING_STATE_IDLE, - BEAMFORMING_STATE_START, - BEAMFORMING_STATE_END, -}BEAMFORMING_STATE, *PBEAMFORMING_STATE; - - -typedef enum _BEAMFORMING_CAP -{ - BEAMFORMING_CAP_NONE = 0x0, - BEAMFORMER_CAP_HT_EXPLICIT = 0x1, - BEAMFORMEE_CAP_HT_EXPLICIT = 0x2, - BEAMFORMER_CAP_VHT_SU = 0x4, /* Self has er Cap, because Reg er & peer ee */ - BEAMFORMEE_CAP_VHT_SU = 0x8, /* Self has ee Cap, because Reg ee & peer er */ - BEAMFORMER_CAP = 0x10, - BEAMFORMEE_CAP = 0x20, -}BEAMFORMING_CAP, *PBEAMFORMING_CAP; - - -typedef enum _SOUNDING_MODE -{ - SOUNDING_SW_VHT_TIMER = 0x0, - SOUNDING_SW_HT_TIMER = 0x1, - SOUNDING_STOP_All_TIMER = 0x2, - SOUNDING_HW_VHT_TIMER = 0x3, - SOUNDING_HW_HT_TIMER = 0x4, - SOUNDING_STOP_OID_TIMER = 0x5, - SOUNDING_AUTO_VHT_TIMER = 0x6, - SOUNDING_AUTO_HT_TIMER = 0x7, - SOUNDING_FW_VHT_TIMER = 0x8, - SOUNDING_FW_HT_TIMER = 0x9, -}SOUNDING_MODE, *PSOUNDING_MODE; - - -enum BEAMFORMING_CTRL_TYPE -{ - BEAMFORMING_CTRL_ENTER = 0, - BEAMFORMING_CTRL_LEAVE = 1, - BEAMFORMING_CTRL_START_PERIOD = 2, - BEAMFORMING_CTRL_END_PERIOD = 3, - BEAMFORMING_CTRL_SOUNDING_FAIL =4, - BEAMFORMING_CTRL_SOUNDING_CLK =5, -}; - -struct beamforming_entry { - bool bUsed; - bool bSound; - u16 aid; /* Used to construct AID field of NDPA packet. */ - u16 mac_id; /* Used to Set Reg42C in IBSS mode. */ - u16 p_aid; /* Used to fill Reg42C & Reg714 to compare with P_AID of Tx DESC. */ - u8 mac_addr[6];/* Used to fill Reg6E4 to fill Mac address of CSI report frame. */ - enum CHANNEL_WIDTH sound_bw; /* Sounding BandWidth */ - u16 sound_period; - BEAMFORMING_CAP beamforming_entry_cap; - BEAMFORMING_ENTRY_STATE beamforming_entry_state; - u8 LogSeq; - u8 LogRetryCnt; - u8 LogSuccessCnt; - u8 LogStatusFailCnt; - u8 PreCsiReport[327]; - u8 DefaultCsiCnt; - bool bDefaultCSI; -}; - -struct sounding_info { - u8 sound_idx; - enum CHANNEL_WIDTH sound_bw; - SOUNDING_MODE sound_mode; - u16 sound_period; -}; - -struct beamforming_info { - BEAMFORMING_CAP beamforming_cap; - BEAMFORMING_STATE beamforming_state; - struct beamforming_entry beamforming_entry[BEAMFORMING_ENTRY_NUM]; - u8 beamforming_cur_idx; - u8 beamforming_in_progress; - u8 sounding_sequence; - struct sounding_info sounding_info; -}; - -struct rtw_ndpa_sta_info { - u16 aid:12; - u16 feedback_type:1; - u16 nc_index:3; -}; - -BEAMFORMING_CAP beamforming_get_entry_beam_cap_by_mac_id(void *pmlmepriv , u8 mac_id); -void beamforming_notify(struct adapter * adapter); -BEAMFORMING_CAP beamforming_get_beamform_cap(struct beamforming_info *pBeamInfo); - -u32 beamforming_get_report_frame(struct adapter * Adapter, union recv_frame *precv_frame); - -bool beamforming_send_ht_ndpa_packet(struct adapter * Adapter, u8 *ra, enum CHANNEL_WIDTH bw, u8 qidx); -bool beamforming_send_vht_ndpa_packet(struct adapter * Adapter, u8 *ra, u16 aid, enum CHANNEL_WIDTH bw, u8 qidx); - -void beamforming_check_sounding_success(struct adapter * Adapter, bool status); - -void beamforming_watchdog(struct adapter * Adapter); - -void beamforming_wk_hdl(struct adapter *padapter, u8 type, u8 *pbuf); -u8 beamforming_wk_cmd(struct adapter *padapter, s32 type, u8 *pbuf, s32 size, u8 enqueue); - -#endif From e17f46c6715448dace0e6300ac48f9052a3ca613 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 7 Jul 2018 13:22:50 +0200 Subject: [PATCH 274/903] staging: rtl8188eu: replace while with shorter for loop Simplify rtw_get_rateset_len() by replacing the while loop with a shorter for loop. Also replace tabs with spaces in the definition line. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index e47927b9c3b8..711ebb0ad640 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -200,17 +200,13 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode) } } -uint rtw_get_rateset_len(u8 *rateset) +uint rtw_get_rateset_len(u8 *rateset) { - uint i = 0; + uint i; - while (1) { - if ((rateset[i]) == 0) + for (i = 0; i < 13; i++) + if (rateset[i] == 0) break; - if (i > 12) - break; - i++; - } return i; } From cd50699fe1b546a2abffdfdcd022d702e9c58f3f Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 11 Jun 2018 09:42:02 +0200 Subject: [PATCH 275/903] MAINTAINERS: update two greybus sections Fix a file entry typo and drop the obsolete timesync entries, which were all caught by: scripts/get_maintainer.pl --self-test=patterns Reported-by: Joe Perches Signed-off-by: Johan Hovold Acked-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 0d36546fc61c..8c7625817367 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6161,7 +6161,7 @@ F: drivers/staging/greybus/bootrom.c F: drivers/staging/greybus/firmware.h F: drivers/staging/greybus/fw-core.c F: drivers/staging/greybus/fw-download.c -F: drivers/staging/greybus/fw-managament.c +F: drivers/staging/greybus/fw-management.c F: drivers/staging/greybus/greybus_authentication.h F: drivers/staging/greybus/greybus_firmware.h F: drivers/staging/greybus/hid.c @@ -6170,12 +6170,10 @@ F: drivers/staging/greybus/spi.c F: drivers/staging/greybus/spilib.c F: drivers/staging/greybus/spilib.h -GREYBUS LOOPBACK/TIME PROTOCOLS DRIVERS +GREYBUS LOOPBACK DRIVER M: Bryan O'Donoghue S: Maintained F: drivers/staging/greybus/loopback.c -F: drivers/staging/greybus/timesync.c -F: drivers/staging/greybus/timesync_platform.c GREYBUS PLATFORM DRIVERS M: Vaibhav Hiremath From 7d6cd21d82bacab2d1786fe5e989e4815b75d9a3 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Mon, 25 Jun 2018 00:05:21 +0900 Subject: [PATCH 276/903] iio: adc: ina2xx: avoid kthread_stop() with stale task_struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the buffer is enabled for ina2xx driver, a dedicated kthread is invoked to capture mesurement data. When the buffer is disabled, the kthread is stopped. However if the kthread gets register access errors, it immediately exits and when the malfunctional buffer is disabled, the stale task_struct pointer is accessed as there is no kthread to be stopped. A similar issue in the usbip driver is prevented by kthread_get_run and kthread_stop_put helpers by increasing usage count of the task_struct. This change applies the same solution. Cc: Stefan Brüns Cc: Jonathan Cameron Signed-off-by: Akinobu Mita Fixes: c43a102e67db ("iio: ina2xx: add support for TI INA2xx Power Monitors") Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ina2xx-adc.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index 0635a79864bf..d1239624187d 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -826,6 +827,7 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev) { struct ina2xx_chip_info *chip = iio_priv(indio_dev); unsigned int sampling_us = SAMPLING_PERIOD(chip); + struct task_struct *task; dev_dbg(&indio_dev->dev, "Enabling buffer w/ scan_mask %02x, freq = %d, avg =%u\n", (unsigned int)(*indio_dev->active_scan_mask), @@ -835,11 +837,17 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev) dev_dbg(&indio_dev->dev, "Async readout mode: %d\n", chip->allow_async_readout); - chip->task = kthread_run(ina2xx_capture_thread, (void *)indio_dev, - "%s:%d-%uus", indio_dev->name, indio_dev->id, - sampling_us); + task = kthread_create(ina2xx_capture_thread, (void *)indio_dev, + "%s:%d-%uus", indio_dev->name, indio_dev->id, + sampling_us); + if (IS_ERR(task)) + return PTR_ERR(task); - return PTR_ERR_OR_ZERO(chip->task); + get_task_struct(task); + wake_up_process(task); + chip->task = task; + + return 0; } static int ina2xx_buffer_disable(struct iio_dev *indio_dev) @@ -848,6 +856,7 @@ static int ina2xx_buffer_disable(struct iio_dev *indio_dev) if (chip->task) { kthread_stop(chip->task); + put_task_struct(chip->task); chip->task = NULL; } From 19868faad4c59646a9fbebc34c3bf07733db341e Mon Sep 17 00:00:00 2001 From: Nikolaus Voss Date: Tue, 3 Jul 2018 07:41:00 +0200 Subject: [PATCH 277/903] IIO: st_accel_i2c.c: Simplify access to driver data Use device_get_match_data API to simplify access to driver data. Let acpi_device_id table entries point to the same driver data as of_device_id table entries and uniquify access to driver data by using device_get_match_data API. Remove unused i2c_device_id .driver_data fields. Signed-off-by: Nikolaus Voss Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_i2c.c | 59 ++++++++++++++------------------ 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 056dddb27236..d02298f0256c 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -14,8 +14,8 @@ #include #include #include +#include -#include #include #include "st_accel.h" @@ -107,8 +107,8 @@ MODULE_DEVICE_TABLE(of, st_accel_of_match); #ifdef CONFIG_ACPI static const struct acpi_device_id st_accel_acpi_match[] = { - {"SMO8840", LNG2DM}, - {"SMO8A90", LNG2DM}, + {"SMO8840", (kernel_ulong_t)LNG2DM_ACCEL_DEV_NAME}, + {"SMO8A90", (kernel_ulong_t)LNG2DM_ACCEL_DEV_NAME}, { }, }; MODULE_DEVICE_TABLE(acpi, st_accel_acpi_match); @@ -117,24 +117,24 @@ MODULE_DEVICE_TABLE(acpi, st_accel_acpi_match); #endif static const struct i2c_device_id st_accel_id_table[] = { - { LSM303DLH_ACCEL_DEV_NAME, LSM303DLH }, - { LSM303DLHC_ACCEL_DEV_NAME, LSM303DLHC }, - { LIS3DH_ACCEL_DEV_NAME, LIS3DH }, - { LSM330D_ACCEL_DEV_NAME, LSM330D }, - { LSM330DL_ACCEL_DEV_NAME, LSM330DL }, - { LSM330DLC_ACCEL_DEV_NAME, LSM330DLC }, - { LIS331DLH_ACCEL_DEV_NAME, LIS331DLH }, - { LSM303DL_ACCEL_DEV_NAME, LSM303DL }, - { LSM303DLM_ACCEL_DEV_NAME, LSM303DLM }, - { LSM330_ACCEL_DEV_NAME, LSM330 }, - { LSM303AGR_ACCEL_DEV_NAME, LSM303AGR }, - { LIS2DH12_ACCEL_DEV_NAME, LIS2DH12 }, - { LIS3L02DQ_ACCEL_DEV_NAME, LIS3L02DQ }, - { LNG2DM_ACCEL_DEV_NAME, LNG2DM }, - { H3LIS331DL_ACCEL_DEV_NAME, H3LIS331DL }, - { LIS331DL_ACCEL_DEV_NAME, LIS331DL }, - { LIS3LV02DL_ACCEL_DEV_NAME, LIS3LV02DL }, - { LIS2DW12_ACCEL_DEV_NAME, LIS2DW12 }, + { LSM303DLH_ACCEL_DEV_NAME }, + { LSM303DLHC_ACCEL_DEV_NAME }, + { LIS3DH_ACCEL_DEV_NAME }, + { LSM330D_ACCEL_DEV_NAME }, + { LSM330DL_ACCEL_DEV_NAME }, + { LSM330DLC_ACCEL_DEV_NAME }, + { LIS331DLH_ACCEL_DEV_NAME }, + { LSM303DL_ACCEL_DEV_NAME }, + { LSM303DLM_ACCEL_DEV_NAME }, + { LSM330_ACCEL_DEV_NAME }, + { LSM303AGR_ACCEL_DEV_NAME }, + { LIS2DH12_ACCEL_DEV_NAME }, + { LIS3L02DQ_ACCEL_DEV_NAME }, + { LNG2DM_ACCEL_DEV_NAME }, + { H3LIS331DL_ACCEL_DEV_NAME }, + { LIS331DL_ACCEL_DEV_NAME }, + { LIS3LV02DL_ACCEL_DEV_NAME }, + { LIS2DW12_ACCEL_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(i2c, st_accel_id_table); @@ -144,6 +144,7 @@ static int st_accel_i2c_probe(struct i2c_client *client, { struct iio_dev *indio_dev; struct st_sensor_data *adata; + const char *match; int ret; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adata)); @@ -152,19 +153,9 @@ static int st_accel_i2c_probe(struct i2c_client *client, adata = iio_priv(indio_dev); - if (client->dev.of_node) { - st_sensors_of_name_probe(&client->dev, st_accel_of_match, - client->name, sizeof(client->name)); - } else if (ACPI_HANDLE(&client->dev)) { - ret = st_sensors_match_acpi_device(&client->dev); - if ((ret < 0) || (ret >= ST_ACCEL_MAX)) - return -ENODEV; - - strlcpy(client->name, st_accel_id_table[ret].name, - sizeof(client->name)); - } else if (!id) - return -ENODEV; - + match = device_get_match_data(&client->dev); + if (match) + strlcpy(client->name, match, sizeof(client->name)); st_sensors_i2c_configure(indio_dev, client, adata); From 6b0b3e378e16f75338665fa519c2a06e4a071889 Mon Sep 17 00:00:00 2001 From: Nikolaus Voss Date: Tue, 3 Jul 2018 08:06:57 +0200 Subject: [PATCH 278/903] IIO: st_accel_i2c.c: Use probe_new() instead of probe() struct i2c_device_id argument of probe() is not used, so use probe_new() instead. Signed-off-by: Nikolaus Voss Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_i2c.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index d02298f0256c..2ca5d1f6ade0 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -139,8 +139,7 @@ static const struct i2c_device_id st_accel_id_table[] = { }; MODULE_DEVICE_TABLE(i2c, st_accel_id_table); -static int st_accel_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int st_accel_i2c_probe(struct i2c_client *client) { struct iio_dev *indio_dev; struct st_sensor_data *adata; @@ -179,7 +178,7 @@ static struct i2c_driver st_accel_driver = { .of_match_table = of_match_ptr(st_accel_of_match), .acpi_match_table = ACPI_PTR(st_accel_acpi_match), }, - .probe = st_accel_i2c_probe, + .probe_new = st_accel_i2c_probe, .remove = st_accel_i2c_remove, .id_table = st_accel_id_table, }; From 366995df8b9ed7743386813412dcfa991c170d28 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 2 Jul 2018 11:24:35 +0100 Subject: [PATCH 279/903] iio: dac: ti-dac5571 remove redundant variable 'shift' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Variable shift is being assigned but is never used hence it is redundant and can be removed. Cleans up two clang warnings: warning: variable ‘shift’ set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Reviewed-by: Sean Nyekjaer Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ti-dac5571.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/iio/dac/ti-dac5571.c b/drivers/iio/dac/ti-dac5571.c index dd21eebed6a8..e39d1e901353 100644 --- a/drivers/iio/dac/ti-dac5571.c +++ b/drivers/iio/dac/ti-dac5571.c @@ -97,9 +97,6 @@ static int dac5571_cmd_quad(struct dac5571_data *data, int channel, u16 val) static int dac5571_pwrdwn_single(struct dac5571_data *data, int channel, u8 pwrdwn) { - unsigned int shift; - - shift = 12 - data->spec->resolution; data->buf[1] = 0; data->buf[0] = pwrdwn << DAC5571_SINGLE_PWRDWN_BITS; @@ -111,9 +108,6 @@ static int dac5571_pwrdwn_single(struct dac5571_data *data, int channel, u8 pwrd static int dac5571_pwrdwn_quad(struct dac5571_data *data, int channel, u8 pwrdwn) { - unsigned int shift; - - shift = 16 - data->spec->resolution; data->buf[2] = 0; data->buf[1] = pwrdwn << DAC5571_QUAD_PWRDWN_BITS; data->buf[0] = (channel << DAC5571_CHANNEL_SELECT) | From 5f0d4fd6b2c6f4ce14af861b17b9bebc8ba1265a Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 2 Jul 2018 11:13:59 +0100 Subject: [PATCH 280/903] iio: dac: ltc2632 remove redundant pointer chip_info and spi_dev_id Pointers chip_info and spi_dev_id are being assigned but are never used hence they are redundant and can be removed. Cleans up clang warning: warning: variable 'chip_info' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ltc2632.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c index cca278eaa138..28e9b7656b20 100644 --- a/drivers/iio/dac/ltc2632.c +++ b/drivers/iio/dac/ltc2632.c @@ -87,12 +87,7 @@ static int ltc2632_read_raw(struct iio_dev *indio_dev, int *val2, long m) { - struct ltc2632_chip_info *chip_info; - const struct ltc2632_state *st = iio_priv(indio_dev); - const struct spi_device_id *spi_dev_id = spi_get_device_id(st->spi_dev); - - chip_info = (struct ltc2632_chip_info *)spi_dev_id->driver_data; switch (m) { case IIO_CHAN_INFO_SCALE: From 82d65f9d552818b7e56c85edaaf6c3d2b104d07d Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 3 Jul 2018 14:35:50 -0500 Subject: [PATCH 281/903] iio:imu:adis: Mark expected switch fall-throughs In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Jonathan Cameron --- drivers/iio/imu/adis.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c index ad6f91d06185..c771ae6803a9 100644 --- a/drivers/iio/imu/adis.c +++ b/drivers/iio/imu/adis.c @@ -81,9 +81,11 @@ int adis_write_reg(struct adis *adis, unsigned int reg, adis->tx[9] = (value >> 24) & 0xff; adis->tx[6] = ADIS_WRITE_REG(reg + 2); adis->tx[7] = (value >> 16) & 0xff; + /* fall through */ case 2: adis->tx[4] = ADIS_WRITE_REG(reg + 1); adis->tx[5] = (value >> 8) & 0xff; + /* fall through */ case 1: adis->tx[2] = ADIS_WRITE_REG(reg); adis->tx[3] = value & 0xff; @@ -167,6 +169,7 @@ int adis_read_reg(struct adis *adis, unsigned int reg, adis->tx[2] = ADIS_READ_REG(reg + 2); adis->tx[3] = 0; spi_message_add_tail(&xfers[1], &msg); + /* fall through */ case 2: adis->tx[4] = ADIS_READ_REG(reg); adis->tx[5] = 0; From e161ef7c3c376f6807cdef7e8a2804b964dd7584 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 3 Jul 2018 14:44:36 -0500 Subject: [PATCH 282/903] iio: mma8452: Mark expected switch fall-through In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Warning level 2 was used in this case: -Wimplicit-fallthrough=2 Signed-off-by: Gustavo A. R. Silva Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 7e3d82cff3d5..31eccb8533d2 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1547,6 +1547,7 @@ static int mma8452_probe(struct i2c_client *client, case FXLS8471_DEVICE_ID: if (ret == data->chip_info->chip_id) break; + /* else: fall through */ default: return -ENODEV; } From 28d1a7ac2a0d9589e04dd36a83f242b3e14da1eb Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Wed, 4 Jul 2018 17:32:03 +0300 Subject: [PATCH 283/903] iio: dac: Add AD5758 support The AD5758 is a single channel DAC with 16-bit precision which uses the SPI interface that operates at clock rates up to 50MHz. The output can be configured as voltage or current and is available on a single terminal. Datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/ad5758.pdf Signed-off-by: Stefan Popa Signed-off-by: Jonathan Cameron --- MAINTAINERS | 7 + drivers/iio/dac/Kconfig | 10 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/ad5758.c | 897 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 915 insertions(+) create mode 100644 drivers/iio/dac/ad5758.c diff --git a/MAINTAINERS b/MAINTAINERS index a21cadbf39e7..728ae34b7b32 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -796,6 +796,13 @@ M: Michael Hanselmann S: Supported F: drivers/macintosh/ams/ +ANALOG DEVICES INC AD5758 DRIVER +M: Stefan Popa +L: linux-iio@vger.kernel.org +W: http://ez.analog.com/community/linux-device-drivers +S: Supported +F: drivers/iio/dac/ad5758.c + ANALOG DEVICES INC AD5686 DRIVER M: Stefan Popa L: linux-pm@vger.kernel.org diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 06e90debb9f5..80beb64e9e0c 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -167,6 +167,16 @@ config AD5755 To compile this driver as a module, choose M here: the module will be called ad5755. +config AD5758 + tristate "Analog Devices AD5758 DAC driver" + depends on SPI_MASTER + help + Say yes here to build support for Analog Devices AD5758 single channel + Digital to Analog Converter. + + To compile this driver as a module, choose M here: the + module will be called ad5758. + config AD5761 tristate "Analog Devices AD5761/61R/21/21R DAC driver" depends on SPI_MASTER diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile index 57aa230d34ab..a1b37cf99441 100644 --- a/drivers/iio/dac/Makefile +++ b/drivers/iio/dac/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_AD5592R_BASE) += ad5592r-base.o obj-$(CONFIG_AD5592R) += ad5592r.o obj-$(CONFIG_AD5593R) += ad5593r.o obj-$(CONFIG_AD5755) += ad5755.o +obj-$(CONFIG_AD5755) += ad5758.o obj-$(CONFIG_AD5761) += ad5761.o obj-$(CONFIG_AD5764) += ad5764.o obj-$(CONFIG_AD5791) += ad5791.o diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c new file mode 100644 index 000000000000..bd36333257af --- /dev/null +++ b/drivers/iio/dac/ad5758.c @@ -0,0 +1,897 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * AD5758 Digital to analog converters driver + * + * Copyright 2018 Analog Devices Inc. + * + * TODO: Currently CRC is not supported in this driver + */ +#include +#include +#include +#include +#include +#include + +#include +#include + +/* AD5758 registers definition */ +#define AD5758_NOP 0x00 +#define AD5758_DAC_INPUT 0x01 +#define AD5758_DAC_OUTPUT 0x02 +#define AD5758_CLEAR_CODE 0x03 +#define AD5758_USER_GAIN 0x04 +#define AD5758_USER_OFFSET 0x05 +#define AD5758_DAC_CONFIG 0x06 +#define AD5758_SW_LDAC 0x07 +#define AD5758_KEY 0x08 +#define AD5758_GP_CONFIG1 0x09 +#define AD5758_GP_CONFIG2 0x0A +#define AD5758_DCDC_CONFIG1 0x0B +#define AD5758_DCDC_CONFIG2 0x0C +#define AD5758_WDT_CONFIG 0x0F +#define AD5758_DIGITAL_DIAG_CONFIG 0x10 +#define AD5758_ADC_CONFIG 0x11 +#define AD5758_FAULT_PIN_CONFIG 0x12 +#define AD5758_TWO_STAGE_READBACK_SELECT 0x13 +#define AD5758_DIGITAL_DIAG_RESULTS 0x14 +#define AD5758_ANALOG_DIAG_RESULTS 0x15 +#define AD5758_STATUS 0x16 +#define AD5758_CHIP_ID 0x17 +#define AD5758_FREQ_MONITOR 0x18 +#define AD5758_DEVICE_ID_0 0x19 +#define AD5758_DEVICE_ID_1 0x1A +#define AD5758_DEVICE_ID_2 0x1B +#define AD5758_DEVICE_ID_3 0x1C + +/* AD5758_DAC_CONFIG */ +#define AD5758_DAC_CONFIG_RANGE_MSK GENMASK(3, 0) +#define AD5758_DAC_CONFIG_RANGE_MODE(x) (((x) & 0xF) << 0) +#define AD5758_DAC_CONFIG_INT_EN_MSK BIT(5) +#define AD5758_DAC_CONFIG_INT_EN_MODE(x) (((x) & 0x1) << 5) +#define AD5758_DAC_CONFIG_OUT_EN_MSK BIT(6) +#define AD5758_DAC_CONFIG_OUT_EN_MODE(x) (((x) & 0x1) << 6) +#define AD5758_DAC_CONFIG_SR_EN_MSK BIT(8) +#define AD5758_DAC_CONFIG_SR_EN_MODE(x) (((x) & 0x1) << 8) +#define AD5758_DAC_CONFIG_SR_CLOCK_MSK GENMASK(12, 9) +#define AD5758_DAC_CONFIG_SR_CLOCK_MODE(x) (((x) & 0xF) << 9) +#define AD5758_DAC_CONFIG_SR_STEP_MSK GENMASK(15, 13) +#define AD5758_DAC_CONFIG_SR_STEP_MODE(x) (((x) & 0x7) << 13) + +/* AD5758_KEY */ +#define AD5758_KEY_CODE_RESET_1 0x15FA +#define AD5758_KEY_CODE_RESET_2 0xAF51 +#define AD5758_KEY_CODE_SINGLE_ADC_CONV 0x1ADC +#define AD5758_KEY_CODE_RESET_WDT 0x0D06 +#define AD5758_KEY_CODE_CALIB_MEM_REFRESH 0xFCBA + +/* AD5758_DCDC_CONFIG1 */ +#define AD5758_DCDC_CONFIG1_DCDC_VPROG_MSK GENMASK(4, 0) +#define AD5758_DCDC_CONFIG1_DCDC_VPROG_MODE(x) (((x) & 0x1F) << 0) +#define AD5758_DCDC_CONFIG1_DCDC_MODE_MSK GENMASK(6, 5) +#define AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(x) (((x) & 0x3) << 5) +#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK BIT(7) +#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(x) (((x) & 0x1) << 7) + +/* AD5758_DCDC_CONFIG2 */ +#define AD5758_DCDC_CONFIG2_ILIMIT_MSK GENMASK(3, 1) +#define AD5758_DCDC_CONFIG2_ILIMIT_MODE(x) (((x) & 0x7) << 1) +#define AD5758_DCDC_CONFIG2_INTR_SAT_3WI_MSK BIT(11) +#define AD5758_DCDC_CONFIG2_BUSY_3WI_MSK BIT(12) + +/* AD5758_DIGITAL_DIAG_RESULTS */ +#define AD5758_CAL_MEM_UNREFRESHED_MSK BIT(15) + +#define AD5758_WR_FLAG_MSK(x) (0x80 | ((x) & 0x1F)) + +#define AD5758_FULL_SCALE_MICRO 65535000000ULL + +/** + * struct ad5758_state - driver instance specific data + * @spi: spi_device + * @lock: mutex lock + * @out_range: struct which stores the output range + * @dc_dc_mode: variable which stores the mode of operation + * @dc_dc_ilim: variable which stores the dc-to-dc converter current limit + * @slew_time: variable which stores the target slew time + * @pwr_down: variable which contains whether a channel is powered down or not + * @data: spi transfer buffers + */ + +struct ad5758_range { + int reg; + int min; + int max; +}; + +struct ad5758_state { + struct spi_device *spi; + struct mutex lock; + struct ad5758_range out_range; + unsigned int dc_dc_mode; + unsigned int dc_dc_ilim; + unsigned int slew_time; + bool pwr_down; + __be32 d32[3]; +}; + +/** + * Output ranges corresponding to bits [3:0] from DAC_CONFIG register + * 0000: 0 V to 5 V voltage range + * 0001: 0 V to 10 V voltage range + * 0010: ±5 V voltage range + * 0011: ±10 V voltage range + * 1000: 0 mA to 20 mA current range + * 1001: 0 mA to 24 mA current range + * 1010: 4 mA to 20 mA current range + * 1011: ±20 mA current range + * 1100: ±24 mA current range + * 1101: -1 mA to +22 mA current range + */ +enum ad5758_output_range { + AD5758_RANGE_0V_5V, + AD5758_RANGE_0V_10V, + AD5758_RANGE_PLUSMINUS_5V, + AD5758_RANGE_PLUSMINUS_10V, + AD5758_RANGE_0mA_20mA = 8, + AD5758_RANGE_0mA_24mA, + AD5758_RANGE_4mA_24mA, + AD5758_RANGE_PLUSMINUS_20mA, + AD5758_RANGE_PLUSMINUS_24mA, + AD5758_RANGE_MINUS_1mA_PLUS_22mA, +}; + +enum ad5758_dc_dc_mode { + AD5758_DCDC_MODE_POWER_OFF, + AD5758_DCDC_MODE_DPC_CURRENT, + AD5758_DCDC_MODE_DPC_VOLTAGE, + AD5758_DCDC_MODE_PPC_CURRENT, +}; + +static const struct ad5758_range ad5758_voltage_range[] = { + { AD5758_RANGE_0V_5V, 0, 5000000 }, + { AD5758_RANGE_0V_10V, 0, 10000000 }, + { AD5758_RANGE_PLUSMINUS_5V, -5000000, 5000000 }, + { AD5758_RANGE_PLUSMINUS_10V, -10000000, 10000000 } +}; + +static const struct ad5758_range ad5758_current_range[] = { + { AD5758_RANGE_0mA_20mA, 0, 20000}, + { AD5758_RANGE_0mA_24mA, 0, 24000 }, + { AD5758_RANGE_4mA_24mA, 4, 24000 }, + { AD5758_RANGE_PLUSMINUS_20mA, -20000, 20000 }, + { AD5758_RANGE_PLUSMINUS_24mA, -24000, 24000 }, + { AD5758_RANGE_MINUS_1mA_PLUS_22mA, -1000, 22000 }, +}; + +static const int ad5758_sr_clk[16] = { + 240000, 200000, 150000, 128000, 64000, 32000, 16000, 8000, 4000, 2000, + 1000, 512, 256, 128, 64, 16 +}; + +static const int ad5758_sr_step[8] = { + 4, 12, 64, 120, 256, 500, 1820, 2048 +}; + +static const int ad5758_dc_dc_ilim[6] = { + 150000, 200000, 250000, 300000, 350000, 400000 +}; + +static int ad5758_spi_reg_read(struct ad5758_state *st, unsigned int addr) +{ + struct spi_transfer t[] = { + { + .tx_buf = &st->d32[0], + .len = 4, + .cs_change = 1, + }, { + .tx_buf = &st->d32[1], + .rx_buf = &st->d32[2], + .len = 4, + }, + }; + int ret; + + st->d32[0] = cpu_to_be32( + (AD5758_WR_FLAG_MSK(AD5758_TWO_STAGE_READBACK_SELECT) << 24) | + (addr << 8)); + st->d32[1] = cpu_to_be32(AD5758_WR_FLAG_MSK(AD5758_NOP) << 24); + + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); + if (ret < 0) + return ret; + + return (be32_to_cpu(st->d32[2]) >> 8) & 0xFFFF; +} + +static int ad5758_spi_reg_write(struct ad5758_state *st, + unsigned int addr, + unsigned int val) +{ + st->d32[0] = cpu_to_be32((AD5758_WR_FLAG_MSK(addr) << 24) | + ((val & 0xFFFF) << 8)); + + return spi_write(st->spi, &st->d32[0], sizeof(st->d32[0])); +} + +static int ad5758_spi_write_mask(struct ad5758_state *st, + unsigned int addr, + unsigned long int mask, + unsigned int val) +{ + int regval; + + regval = ad5758_spi_reg_read(st, addr); + if (regval < 0) + return regval; + + regval &= ~mask; + regval |= val; + + return ad5758_spi_reg_write(st, addr, regval); +} + +static int cmpfunc(const void *a, const void *b) +{ + return *(int *)a - *(int *)b; +} + +static int ad5758_find_closest_match(const int *array, + unsigned int size, int val) +{ + int i; + + for (i = 0; i < size; i++) { + if (val <= array[i]) + return i; + } + + return size - 1; +} + +static int ad5758_wait_for_task_complete(struct ad5758_state *st, + unsigned int reg, + unsigned int mask) +{ + unsigned int timeout; + int ret; + + timeout = 10; + do { + ret = ad5758_spi_reg_read(st, reg); + if (ret < 0) + return ret; + + if (!(ret & mask)) + return 0; + + usleep_range(100, 1000); + } while (--timeout); + + dev_err(&st->spi->dev, + "Error reading bit 0x%x in 0x%x register\n", mask, reg); + + return -EIO; +} + +static int ad5758_calib_mem_refresh(struct ad5758_state *st) +{ + int ret; + + ret = ad5758_spi_reg_write(st, AD5758_KEY, + AD5758_KEY_CODE_CALIB_MEM_REFRESH); + if (ret < 0) { + dev_err(&st->spi->dev, + "Failed to initiate a calibration memory refresh\n"); + return ret; + } + + /* Wait to allow time for the internal calibrations to complete */ + return ad5758_wait_for_task_complete(st, AD5758_DIGITAL_DIAG_RESULTS, + AD5758_CAL_MEM_UNREFRESHED_MSK); +} + +static int ad5758_soft_reset(struct ad5758_state *st) +{ + int ret; + + ret = ad5758_spi_reg_write(st, AD5758_KEY, AD5758_KEY_CODE_RESET_1); + if (ret < 0) + return ret; + + ret = ad5758_spi_reg_write(st, AD5758_KEY, AD5758_KEY_CODE_RESET_2); + + /* Perform a software reset and wait at least 100us */ + usleep_range(100, 1000); + + return ret; +} + +static int ad5758_set_dc_dc_conv_mode(struct ad5758_state *st, + enum ad5758_dc_dc_mode mode) +{ + int ret; + + ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1, + AD5758_DCDC_CONFIG1_DCDC_MODE_MSK, + AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(mode)); + if (ret < 0) + return ret; + + /* + * Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is 0. + * This allows the 3-wire interface communication to complete. + */ + ret = ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2, + AD5758_DCDC_CONFIG2_BUSY_3WI_MSK); + if (ret < 0) + return ret; + + st->dc_dc_mode = mode; + + return ret; +} + +static int ad5758_set_dc_dc_ilim(struct ad5758_state *st, unsigned int ilim) +{ + int ret; + + ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG2, + AD5758_DCDC_CONFIG2_ILIMIT_MSK, + AD5758_DCDC_CONFIG2_ILIMIT_MODE(ilim)); + if (ret < 0) + return ret; + /* + * Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is 0. + * This allows the 3-wire interface communication to complete. + */ + return ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2, + AD5758_DCDC_CONFIG2_BUSY_3WI_MSK); +} + +static int ad5758_slew_rate_set(struct ad5758_state *st, + unsigned int sr_clk_idx, + unsigned int sr_step_idx) +{ + unsigned int mode; + unsigned long int mask; + int ret; + + mask = AD5758_DAC_CONFIG_SR_EN_MSK | + AD5758_DAC_CONFIG_SR_CLOCK_MSK | + AD5758_DAC_CONFIG_SR_STEP_MSK; + mode = AD5758_DAC_CONFIG_SR_EN_MODE(1) | + AD5758_DAC_CONFIG_SR_STEP_MODE(sr_step_idx) | + AD5758_DAC_CONFIG_SR_CLOCK_MODE(sr_clk_idx); + + ret = ad5758_spi_write_mask(st, AD5758_DAC_CONFIG, mask, mode); + if (ret < 0) + return ret; + + /* Wait to allow time for the internal calibrations to complete */ + return ad5758_wait_for_task_complete(st, AD5758_DIGITAL_DIAG_RESULTS, + AD5758_CAL_MEM_UNREFRESHED_MSK); +} + +static int ad5758_slew_rate_config(struct ad5758_state *st) +{ + unsigned int sr_clk_idx, sr_step_idx; + int i, res; + s64 diff_new, diff_old; + u64 sr_step, calc_slew_time; + + sr_clk_idx = 0; + sr_step_idx = 0; + diff_old = S64_MAX; + /* + * The slew time can be determined by using the formula: + * Slew Time = (Full Scale Out / (Step Size x Update Clk Freq)) + * where Slew time is expressed in microseconds + * Given the desired slew time, the following algorithm determines the + * best match for the step size and the update clock frequency. + */ + for (i = 0; i < ARRAY_SIZE(ad5758_sr_clk); i++) { + /* + * Go through each valid update clock freq and determine a raw + * value for the step size by using the formula: + * Step Size = Full Scale Out / (Update Clk Freq * Slew Time) + */ + sr_step = AD5758_FULL_SCALE_MICRO; + do_div(sr_step, ad5758_sr_clk[i]); + do_div(sr_step, st->slew_time); + /* + * After a raw value for step size was determined, find the + * closest valid match + */ + res = ad5758_find_closest_match(ad5758_sr_step, + ARRAY_SIZE(ad5758_sr_step), + sr_step); + /* Calculate the slew time */ + calc_slew_time = AD5758_FULL_SCALE_MICRO; + do_div(calc_slew_time, ad5758_sr_step[res]); + do_div(calc_slew_time, ad5758_sr_clk[i]); + /* + * Determine with how many microseconds the calculated slew time + * is different from the desired slew time and store the diff + * for the next iteration + */ + diff_new = abs(st->slew_time - calc_slew_time); + if (diff_new < diff_old) { + diff_old = diff_new; + sr_clk_idx = i; + sr_step_idx = res; + } + } + + return ad5758_slew_rate_set(st, sr_clk_idx, sr_step_idx); +} + +static int ad5758_set_out_range(struct ad5758_state *st, int range) +{ + int ret; + + ret = ad5758_spi_write_mask(st, AD5758_DAC_CONFIG, + AD5758_DAC_CONFIG_RANGE_MSK, + AD5758_DAC_CONFIG_RANGE_MODE(range)); + if (ret < 0) + return ret; + + /* Wait to allow time for the internal calibrations to complete */ + return ad5758_wait_for_task_complete(st, AD5758_DIGITAL_DIAG_RESULTS, + AD5758_CAL_MEM_UNREFRESHED_MSK); +} + +static int ad5758_fault_prot_switch_en(struct ad5758_state *st, bool enable) +{ + int ret; + + ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1, + AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK, + AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(enable)); + if (ret < 0) + return ret; + /* + * Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is 0. + * This allows the 3-wire interface communication to complete. + */ + return ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2, + AD5758_DCDC_CONFIG2_BUSY_3WI_MSK); +} + +static int ad5758_internal_buffers_en(struct ad5758_state *st, bool enable) +{ + int ret; + + ret = ad5758_spi_write_mask(st, AD5758_DAC_CONFIG, + AD5758_DAC_CONFIG_INT_EN_MSK, + AD5758_DAC_CONFIG_INT_EN_MODE(enable)); + if (ret < 0) + return ret; + + /* Wait to allow time for the internal calibrations to complete */ + return ad5758_wait_for_task_complete(st, AD5758_DIGITAL_DIAG_RESULTS, + AD5758_CAL_MEM_UNREFRESHED_MSK); +} + +static int ad5758_reg_access(struct iio_dev *indio_dev, + unsigned int reg, + unsigned int writeval, + unsigned int *readval) +{ + struct ad5758_state *st = iio_priv(indio_dev); + int ret; + + mutex_lock(&st->lock); + if (readval) { + ret = ad5758_spi_reg_read(st, reg); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + + *readval = ret; + ret = 0; + } else { + ret = ad5758_spi_reg_write(st, reg, writeval); + } + mutex_unlock(&st->lock); + + return ret; +} + +static int ad5758_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long info) +{ + struct ad5758_state *st = iio_priv(indio_dev); + int max, min, ret; + + switch (info) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + ret = ad5758_spi_reg_read(st, AD5758_DAC_INPUT); + mutex_unlock(&st->lock); + if (ret < 0) + return ret; + + *val = ret; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + min = st->out_range.min; + max = st->out_range.max; + *val = (max - min) / 1000; + *val2 = 16; + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_OFFSET: + min = st->out_range.min; + max = st->out_range.max; + *val = ((min * (1 << 16)) / (max - min)) / 1000; + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int ad5758_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long info) +{ + struct ad5758_state *st = iio_priv(indio_dev); + int ret; + + switch (info) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + ret = ad5758_spi_reg_write(st, AD5758_DAC_INPUT, val); + mutex_unlock(&st->lock); + return ret; + default: + return -EINVAL; + } +} + +static ssize_t ad5758_read_powerdown(struct iio_dev *indio_dev, + uintptr_t priv, + const struct iio_chan_spec *chan, + char *buf) +{ + struct ad5758_state *st = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", st->pwr_down); +} + +static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev, + uintptr_t priv, + struct iio_chan_spec const *chan, + const char *buf, size_t len) +{ + struct ad5758_state *st = iio_priv(indio_dev); + bool pwr_down; + unsigned int dcdc_config1_mode, dc_dc_mode, dac_config_mode, val; + unsigned long int dcdc_config1_msk, dac_config_msk; + int ret; + + ret = kstrtobool(buf, &pwr_down); + if (ret) + return ret; + + mutex_lock(&st->lock); + if (pwr_down) { + dc_dc_mode = AD5758_DCDC_MODE_POWER_OFF; + val = 0; + } else { + dc_dc_mode = st->dc_dc_mode; + val = 1; + } + + dcdc_config1_mode = AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(dc_dc_mode) | + AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(val); + dcdc_config1_msk = AD5758_DCDC_CONFIG1_DCDC_MODE_MSK | + AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK; + + ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1, + dcdc_config1_msk, + dcdc_config1_mode); + if (ret < 0) + goto err_unlock; + + dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) | + AD5758_DAC_CONFIG_INT_EN_MODE(val); + dac_config_msk = AD5758_DAC_CONFIG_OUT_EN_MSK | + AD5758_DAC_CONFIG_INT_EN_MSK; + + ret = ad5758_spi_write_mask(st, AD5758_DAC_CONFIG, + dac_config_msk, + dac_config_mode); + if (ret < 0) + goto err_unlock; + + st->pwr_down = pwr_down; + +err_unlock: + mutex_unlock(&st->lock); + + return ret ? ret : len; +} + +static const struct iio_info ad5758_info = { + .read_raw = ad5758_read_raw, + .write_raw = ad5758_write_raw, + .debugfs_reg_access = &ad5758_reg_access, +}; + +static const struct iio_chan_spec_ext_info ad5758_ext_info[] = { + { + .name = "powerdown", + .read = ad5758_read_powerdown, + .write = ad5758_write_powerdown, + .shared = IIO_SHARED_BY_TYPE, + }, + { } +}; + +#define AD5758_DAC_CHAN(_chan_type) { \ + .type = (_chan_type), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .indexed = 1, \ + .output = 1, \ + .ext_info = ad5758_ext_info, \ +} + +static const struct iio_chan_spec ad5758_voltage_ch[] = { + AD5758_DAC_CHAN(IIO_VOLTAGE) +}; + +static const struct iio_chan_spec ad5758_current_ch[] = { + AD5758_DAC_CHAN(IIO_CURRENT) +}; + +static bool ad5758_is_valid_mode(enum ad5758_dc_dc_mode mode) +{ + switch (mode) { + case AD5758_DCDC_MODE_DPC_CURRENT: + case AD5758_DCDC_MODE_DPC_VOLTAGE: + case AD5758_DCDC_MODE_PPC_CURRENT: + return true; + default: + return false; + } +} + +static int ad5758_crc_disable(struct ad5758_state *st) +{ + unsigned int mask; + + mask = (AD5758_WR_FLAG_MSK(AD5758_DIGITAL_DIAG_CONFIG) << 24) | 0x5C3A; + st->d32[0] = cpu_to_be32(mask); + + return spi_write(st->spi, &st->d32[0], 4); +} + +static int ad5758_find_out_range(struct ad5758_state *st, + const struct ad5758_range *range, + unsigned int size, + int min, int max) +{ + int i; + + for (i = 0; i < size; i++) { + if ((min == range[i].min) && (max == range[i].max)) { + st->out_range.reg = range[i].reg; + st->out_range.min = range[i].min; + st->out_range.max = range[i].max; + + return 0; + } + } + + return -EINVAL; +} + +static int ad5758_parse_dt(struct ad5758_state *st) +{ + unsigned int tmp, tmparray[2], size; + const struct ad5758_range *range; + int *index, ret; + + st->dc_dc_ilim = 0; + ret = device_property_read_u32(&st->spi->dev, + "adi,dc-dc-ilim-microamp", &tmp); + if (ret) { + dev_dbg(&st->spi->dev, + "Missing \"dc-dc-ilim-microamp\" property\n"); + } else { + index = bsearch(&tmp, ad5758_dc_dc_ilim, + ARRAY_SIZE(ad5758_dc_dc_ilim), + sizeof(int), cmpfunc); + if (!index) + dev_dbg(&st->spi->dev, "dc-dc-ilim out of range\n"); + else + st->dc_dc_ilim = index - ad5758_dc_dc_ilim; + } + + ret = device_property_read_u32(&st->spi->dev, "adi,dc-dc-mode", + &st->dc_dc_mode); + if (ret) { + dev_err(&st->spi->dev, "Missing \"dc-dc-mode\" property\n"); + return ret; + } + + if (!ad5758_is_valid_mode(st->dc_dc_mode)) + return -EINVAL; + + if (st->dc_dc_mode == AD5758_DCDC_MODE_DPC_VOLTAGE) { + ret = device_property_read_u32_array(&st->spi->dev, + "adi,range-microvolt", + tmparray, 2); + if (ret) { + dev_err(&st->spi->dev, + "Missing \"range-microvolt\" property\n"); + return ret; + } + range = ad5758_voltage_range; + size = ARRAY_SIZE(ad5758_voltage_range); + } else { + ret = device_property_read_u32_array(&st->spi->dev, + "adi,range-microamp", + tmparray, 2); + if (ret) { + dev_err(&st->spi->dev, + "Missing \"range-microamp\" property\n"); + return ret; + } + range = ad5758_current_range; + size = ARRAY_SIZE(ad5758_current_range); + } + + ret = ad5758_find_out_range(st, range, size, tmparray[0], tmparray[1]); + if (ret) { + dev_err(&st->spi->dev, "range invalid\n"); + return ret; + } + + ret = device_property_read_u32(&st->spi->dev, "adi,slew-time-us", &tmp); + if (ret) { + dev_dbg(&st->spi->dev, "Missing \"slew-time-us\" property\n"); + st->slew_time = 0; + } else { + st->slew_time = tmp; + } + + return 0; +} + +static int ad5758_init(struct ad5758_state *st) +{ + int regval, ret; + + /* Disable CRC checks */ + ret = ad5758_crc_disable(st); + if (ret < 0) + return ret; + + /* Perform a software reset */ + ret = ad5758_soft_reset(st); + if (ret < 0) + return ret; + + /* Disable CRC checks */ + ret = ad5758_crc_disable(st); + if (ret < 0) + return ret; + + /* Perform a calibration memory refresh */ + ret = ad5758_calib_mem_refresh(st); + if (ret < 0) + return ret; + + regval = ad5758_spi_reg_read(st, AD5758_DIGITAL_DIAG_RESULTS); + if (regval < 0) + return regval; + + /* Clear all the error flags */ + ret = ad5758_spi_reg_write(st, AD5758_DIGITAL_DIAG_RESULTS, regval); + if (ret < 0) + return ret; + + /* Set the dc-to-dc current limit */ + ret = ad5758_set_dc_dc_ilim(st, st->dc_dc_ilim); + if (ret < 0) + return ret; + + /* Configure the dc-to-dc controller mode */ + ret = ad5758_set_dc_dc_conv_mode(st, st->dc_dc_mode); + if (ret < 0) + return ret; + + /* Configure the output range */ + ret = ad5758_set_out_range(st, st->out_range.reg); + if (ret < 0) + return ret; + + /* Enable Slew Rate Control, set the slew rate clock and step */ + if (st->slew_time) { + ret = ad5758_slew_rate_config(st); + if (ret < 0) + return ret; + } + + /* Enable the VIOUT fault protection switch (FPS is closed) */ + ret = ad5758_fault_prot_switch_en(st, 1); + if (ret < 0) + return ret; + + /* Power up the DAC and internal (INT) amplifiers */ + ret = ad5758_internal_buffers_en(st, 1); + if (ret < 0) + return ret; + + /* Enable VIOUT */ + return ad5758_spi_write_mask(st, AD5758_DAC_CONFIG, + AD5758_DAC_CONFIG_OUT_EN_MSK, + AD5758_DAC_CONFIG_OUT_EN_MODE(1)); +} + +static int ad5758_probe(struct spi_device *spi) +{ + struct ad5758_state *st; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + spi_set_drvdata(spi, indio_dev); + + st->spi = spi; + + mutex_init(&st->lock); + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->info = &ad5758_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->num_channels = 1; + + ret = ad5758_parse_dt(st); + if (ret < 0) + return ret; + + if (st->dc_dc_mode == AD5758_DCDC_MODE_DPC_VOLTAGE) + indio_dev->channels = ad5758_voltage_ch; + else + indio_dev->channels = ad5758_current_ch; + + ret = ad5758_init(st); + if (ret < 0) { + dev_err(&spi->dev, "AD5758 init failed\n"); + return ret; + } + + return devm_iio_device_register(&st->spi->dev, indio_dev); +} + +static const struct spi_device_id ad5758_id[] = { + { "ad5758", 0 }, + {} +}; +MODULE_DEVICE_TABLE(spi, ad5758_id); + +static struct spi_driver ad5758_driver = { + .driver = { + .name = KBUILD_MODNAME, + }, + .probe = ad5758_probe, + .id_table = ad5758_id, +}; + +module_spi_driver(ad5758_driver); + +MODULE_AUTHOR("Stefan Popa "); +MODULE_DESCRIPTION("Analog Devices AD5758 DAC"); +MODULE_LICENSE("GPL v2"); From 777baca07ef179301e363b10a14c428e5ebbd6a6 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Wed, 4 Jul 2018 17:32:53 +0300 Subject: [PATCH 284/903] dt-bindings: iio: dac: Add docs for AD5758 DAC Signed-off-by: Stefan Popa Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/dac/ad5758.txt | 78 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/ad5758.txt diff --git a/Documentation/devicetree/bindings/iio/dac/ad5758.txt b/Documentation/devicetree/bindings/iio/dac/ad5758.txt new file mode 100644 index 000000000000..bba01a5cab1b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/ad5758.txt @@ -0,0 +1,78 @@ +Analog Devices AD5758 DAC device driver + +Required properties for the AD5758: + - compatible: Must be "adi,ad5758" + - reg: SPI chip select number for the device + - spi-max-frequency: Max SPI frequency to use (< 50000000) + - spi-cpha: is the only mode that is supported + +Required properties: + + - adi,dc-dc-mode: Mode of operation of the dc-to-dc converter + Dynamic Power Control (DPC) + In this mode, the AD5758 circuitry senses the output + voltage and dynamically regulates the supply voltage, + VDPC+, to meet compliance requirements plus an optimized + headroom voltage for the output buffer. + + Programmable Power Control (PPC) + In this mode, the VDPC+ voltage is user-programmable to + a fixed level that needs to accommodate the maximum output + load required. + + The output of the DAC core is either converted to a + current or voltage output at the VIOUT pin. Only one mode + can be enabled at any one time. + + The following values are currently supported: + * 1: DPC current mode + * 2: DPC voltage mode + * 3: PPC current mode + + Depending on the selected output mode (voltage or current) one of the + two properties must + be present: + + - adi,range-microvolt: Voltage output range + The array of voltage output ranges must contain two fields: + * <0 5000000>: 0 V to 5 V voltage range + * <0 10000000>: 0 V to 10 V voltage range + * <(-5000000) 5000000>: ±5 V voltage range + * <(-10000000) 10000000>: ±10 V voltage range + - adi,range-microamp: Current output range + The array of current output ranges must contain two fields: + * <0 20000>: 0 mA to 20 mA current range + * <0 24000>: 0 mA to 24 mA current range + * <4 24000>: 4 mA to 20 mA current range + * <(-20000) 20000>: ±20 mA current range + * <(-24000) 24000>: ±24 mA current range + * <(-1000) 22000>: −1 mA to +22 mA current range + +Optional properties: + + - adi,dc-dc-ilim-microamp: The dc-to-dc converter current limit + The following values are currently supported [uA]: + * 150000 + * 200000 + * 250000 + * 300000 + * 350000 + * 400000 + + - adi,slew-time-us: The time it takes for the output to reach the + full scale [uS] + The supported range is between 133us up to 1023984375us + +AD5758 Example: + + dac@0 { + compatible = "adi,ad5758"; + reg = <0>; + spi-max-frequency = <1000000>; + spi-cpha; + + adi,dc-dc-mode = <2>; + adi,range-microvolt = <0 10000000>; + adi,dc-dc-ilim-microamp = <200000>; + adi,slew-time-us = <125000>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 728ae34b7b32..83a439c65925 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -802,6 +802,7 @@ L: linux-iio@vger.kernel.org W: http://ez.analog.com/community/linux-device-drivers S: Supported F: drivers/iio/dac/ad5758.c +F: Documentation/devicetree/bindings/iio/dac/ad5758.txt ANALOG DEVICES INC AD5686 DRIVER M: Stefan Popa From 794ac821cc44e4d148df36eb330a7e9729c06a82 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 21 May 2018 11:49:09 +0200 Subject: [PATCH 285/903] iio: adc: max1363: merge calls to of_match_device and of_device_get_match_data Drop call to of_match_device, which is subsumed by the subsequent call to of_device_get_match_data. The code becomes simpler, and a temporary variable can be dropped. The semantic match that makes this change is as follows: (http://coccinelle.lip6.fr/) // @r@ local idexpression match; identifier i; expression x, dev, e, e1; @@ - match@i = of_match_device(x, dev); - if (match) e = of_device_get_match_data(dev); - else e = e1; + e = of_device_get_match_data(dev); + if (!e) e = e1; @@ identifier r.i; @@ - const struct of_device_id *i; ... when != i // Signed-off-by: Julia Lawall Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max1363.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 7fb4f525714a..a8d35aebee80 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1577,7 +1577,6 @@ static int max1363_probe(struct i2c_client *client, struct max1363_state *st; struct iio_dev *indio_dev; struct regulator *vref; - const struct of_device_id *match; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(struct max1363_state)); @@ -1604,11 +1603,8 @@ static int max1363_probe(struct i2c_client *client, /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); - match = of_match_device(of_match_ptr(max1363_of_match), - &client->dev); - if (match) - st->chip_info = of_device_get_match_data(&client->dev); - else + st->chip_info = of_device_get_match_data(&client->dev); + if (!st->chip_info) st->chip_info = &max1363_chip_info_tbl[id->driver_data]; st->client = client; From 854727247ab9fb3547d39b9b3610b682223b9bf2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 7 Jul 2018 15:55:02 +0100 Subject: [PATCH 286/903] staging:rtl8192u: rename HT_CHANNEL_WIDTH -> enum ht_channel_width remove the typedef HT_CHANNEL_WIDTH and replace with 'enum ht_channel_width' Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++-- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 6 +++--- drivers/staging/rtl8192u/r8190_rtl8256.c | 2 +- drivers/staging/rtl8192u/r8190_rtl8256.h | 2 +- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- drivers/staging/rtl8192u/r819xU_phy.h | 3 ++- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 3addaa65085a..8ca24c10c28e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -2002,7 +2002,7 @@ struct ieee80211_device { short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); //added by wb for HT related // void (*SwChnlByTimerHandler)(struct net_device *dev, int channel); - void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); + void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); // void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate); bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); @@ -2358,7 +2358,7 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); void HTSetConnectBwMode(struct ieee80211_device *ieee, - HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); + enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); void HTUpdateDefaultSetting(struct ieee80211_device *ieee); void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 isEncrypt); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 21bd0dc40888..804d628ed9eb 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -303,7 +303,7 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); short chan; HT_EXTCHNL_OFFSET chan_offset = 0; - HT_CHANNEL_WIDTH bandwidth = 0; + enum ht_channel_width bandwidth = 0; int b40M = 0; chan = ieee->current_network.channel; @@ -320,7 +320,7 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) { b40M = 1; chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset; - bandwidth = (HT_CHANNEL_WIDTH)ieee->pHTInfo->bCurBW40MHz; + bandwidth = (enum ht_channel_width)ieee->pHTInfo->bCurBW40MHz; printk("Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth); ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h index 6abf32b142ef..c13ca7f0f4dd 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h @@ -27,10 +27,10 @@ // // Represent Channel Width in HT Capabilities // -typedef enum _HT_CHANNEL_WIDTH { +enum ht_channel_width { HT_CHANNEL_WIDTH_20 = 0, HT_CHANNEL_WIDTH_20_40 = 1, -}HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH; +}; // // Represent Extension Channel Offset in HT Capabilities diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index abf55877331e..86c63b217d3b 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -894,7 +894,7 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, return true; } -void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTSetConnectBwMode(struct ieee80211_device *ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); void HTOnAssocRsp(struct ieee80211_device *ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -936,7 +936,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE)); // Config Supported Channel Width setting // - HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); + HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1); @@ -1290,7 +1290,7 @@ u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame) /* * This function set bandwidth mode in protocol layer. */ -void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) +void HTSetConnectBwMode(struct ieee80211_device *ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; // u32 flags = 0; diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c index e54f6fad2e68..02bdd933f05b 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.c +++ b/drivers/staging/rtl8192u/r8190_rtl8256.c @@ -23,7 +23,7 @@ * Note: 8226 support both 20M and 40 MHz *-------------------------------------------------------------------------- */ -void PHY_SetRF8256Bandwidth(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth) +void PHY_SetRF8256Bandwidth(struct net_device *dev, enum ht_channel_width Bandwidth) { u8 eRFPath; struct r8192_priv *priv = ieee80211_priv(dev); diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.h b/drivers/staging/rtl8192u/r8190_rtl8256.h index 5c325ce9d631..29b926cad14b 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.h +++ b/drivers/staging/rtl8192u/r8190_rtl8256.h @@ -14,7 +14,7 @@ #define RTL8225H #define RTL819X_TOTAL_RF_PATH 2 /* for 8192U */ -void PHY_SetRF8256Bandwidth(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth); +void PHY_SetRF8256Bandwidth(struct net_device *dev, enum ht_channel_width Bandwidth); void PHY_RF8256_Config(struct net_device *dev); void phy_RF8256_Config_ParaFile(struct net_device *dev); void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel); diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 215f618c6760..37aa36126d19 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -996,7 +996,7 @@ typedef struct r8192_priv { u8 SwChnlStage; u8 SwChnlStep; u8 SetBWModeInProgress; - HT_CHANNEL_WIDTH CurrentChannelBW; + enum ht_channel_width CurrentChannelBW; u8 ChannelPlan; /* 8190 40MHz mode */ /* Control channel sub-carrier */ diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 12750671c860..8bb14cc79d8a 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1663,7 +1663,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) * notice: I doubt whether SetBWModeInProgress flag is necessary as we can * test whether current work in the queue or not.//do I? *****************************************************************************/ -void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH bandwidth, +void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width bandwidth, HT_EXTCHNL_OFFSET offset) { struct r8192_priv *priv = ieee80211_priv(dev); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 0a42a6092ea9..ea0032643620 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -79,7 +79,8 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, RF90_RADIO_PATH_E eRFPath); u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); -void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH bandwidth, +void rtl8192_SetBWMode(struct net_device *dev, + enum ht_channel_width bandwidth, HT_EXTCHNL_OFFSET offset); void rtl8192_SwChnl_WorkItem(struct net_device *dev); void rtl8192_SetBWModeWorkItem(struct net_device *dev); From c01bd60e758fb0711744167519ac5ff604631cae Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 7 Jul 2018 15:55:03 +0100 Subject: [PATCH 287/903] staging:rtl8192u: Add space required before '(' - Style Simple addition of the coding style required space before '('. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 174 +++++++++--------- 1 file changed, 86 insertions(+), 88 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 5895d6e5eb67..1f6d0fb3c5bd 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -109,7 +109,7 @@ static void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) *tag++ = 0x00; *tag++ = 0x01; #ifdef SUPPORT_USPD - if(ieee->current_network.wmm_info & 0x80) { + if (ieee->current_network.wmm_info & 0x80) { *tag++ = 0x0f|MAX_SP_Len; } else { *tag++ = MAX_SP_Len; @@ -163,7 +163,7 @@ static struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) { struct sk_buff *ret; - if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) + if (ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; @@ -185,16 +185,16 @@ static u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee) u8 rate; /* 2008/01/25 MH For broadcom, MGNT frame set as OFDM 6M. */ - if(pHTInfo->IOTAction & HT_IOT_ACT_MGNT_USE_CCK_6M) + if (pHTInfo->IOTAction & HT_IOT_ACT_MGNT_USE_CCK_6M) rate = 0x0c; else rate = ieee->basic_rate & 0x7f; if (rate == 0) { /* 2005.01.26, by rcnjko. */ - if(ieee->mode == IEEE_A || - ieee->mode == IEEE_N_5G || - (ieee->mode == IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) + if (ieee->mode == IEEE_A || + ieee->mode == IEEE_N_5G || + (ieee->mode == IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) rate = 0x0c; else rate = 0x02; @@ -235,8 +235,8 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee tcb_desc->bTxDisableRateFallBack = 1; tcb_desc->bTxUseDriverAssingedRate = 1; - if(single){ - if(ieee->queue_stop){ + if (single){ + if (ieee->queue_stop){ enqueue_mgmt(ieee, skb); }else{ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); @@ -265,9 +265,9 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee ieee->seq_ctrl[0]++; /* check whether the managed packet queued greater than 5 */ - if(!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||\ - (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) ||\ - (ieee->queue_stop) ) { + if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||\ + (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) || \ + (ieee->queue_stop) ) { /* insert the skb packet to the management queue */ /* as for the completion function, it does not need * to check it any more. @@ -289,7 +289,7 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *)skb->data; - if(single){ + if (single){ header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -358,7 +358,7 @@ static void ieee80211_send_beacon(struct ieee80211_device *ieee) { struct sk_buff *skb; - if(!ieee->ieee_up) + if (!ieee->ieee_up) return; //unsigned long flags; skb = ieee80211_get_beacon_(ieee); @@ -423,13 +423,13 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); mutex_lock(&ieee->scan_mutex); - while(1) + while (1) { do{ ch++; if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - }while(!channel_map[ch]); + }while (!channel_map[ch]); /* this function can be called in two situations * 1- We have switched to ad-hoc mode and we are @@ -453,7 +453,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) if (ieee->state == IEEE80211_LINKED) goto out; ieee->set_chan(ieee->dev, ch); - if(channel_map[ch] == 1) + if (channel_map[ch] == 1) ieee80211_send_probe_requests(ieee); /* this prevent excessive time wait when we @@ -465,13 +465,13 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) msleep_interruptible(IEEE80211_SOFTMAC_SCAN_TIME); } out: - if(ieee->state < IEEE80211_LINKED){ + if (ieee->state < IEEE80211_LINKED){ ieee->actscanning = false; mutex_unlock(&ieee->scan_mutex); } else{ ieee->sync_scan_hurryup = 0; - if(IS_DOT11D_ENABLE(ieee)) + if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); mutex_unlock(&ieee->scan_mutex); } @@ -486,7 +486,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) u8 channel_map[MAX_CHANNEL_NUMBER+1]; memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); - if(!ieee->ieee_up) + if (!ieee->ieee_up) return; mutex_lock(&ieee->scan_mutex); do{ @@ -500,11 +500,11 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) goto out; /* no good chans */ } } - }while(!channel_map[ieee->current_network.channel]); + }while (!channel_map[ieee->current_network.channel]); if (ieee->scanning == 0 ) goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); - if(channel_map[ieee->current_network.channel] == 1) + if (channel_map[ieee->current_network.channel] == 1) ieee80211_send_probe_requests(ieee); schedule_delayed_work(&ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -512,7 +512,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) mutex_unlock(&ieee->scan_mutex); return; out: - if(IS_DOT11D_ENABLE(ieee)) + if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); ieee->actscanning = false; watchdog = 0; @@ -545,7 +545,7 @@ static void ieee80211_beacons_stop(struct ieee80211_device *ieee) void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) { - if(ieee->stop_send_beacons) + if (ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) ieee80211_beacons_stop(ieee); @@ -554,9 +554,9 @@ EXPORT_SYMBOL(ieee80211_stop_send_beacons); void ieee80211_start_send_beacons(struct ieee80211_device *ieee) { - if(ieee->start_send_beacons) + if (ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev, ieee->basic_rate); - if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) + if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) ieee80211_beacons_start(ieee); } EXPORT_SYMBOL(ieee80211_start_send_beacons); @@ -653,11 +653,11 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); //auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; - if(ieee->auth_mode == 0) + if (ieee->auth_mode == 0) auth->algorithm = WLAN_AUTH_OPEN; - else if(ieee->auth_mode == 1) + else if (ieee->auth_mode == 1) auth->algorithm = cpu_to_le16(WLAN_AUTH_SHARED_KEY); - else if(ieee->auth_mode == 2) + else if (ieee->auth_mode == 2) auth->algorithm = WLAN_AUTH_OPEN; /* 0x80; */ printk("=================>%s():auth->algorithm is %d\n", __func__, auth->algorithm); auth->transaction = cpu_to_le16(ieee->associate_seq); @@ -693,14 +693,14 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d u8 *tmp_generic_ie_buf = NULL; u8 tmp_generic_ie_len = 0; - if(rate_ex_len > 0) rate_ex_len+=2; + if (rate_ex_len > 0) rate_ex_len+=2; - if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) + if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - if(ieee80211_is_54g(&ieee->current_network)) + if (ieee80211_is_54g(&ieee->current_network)) erp_len = 3; else erp_len = 0; @@ -754,7 +754,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d beacon_buf->capability |= cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); /* add short preamble here */ - if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) + if (ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); crypt = ieee->crypt[ieee->tx_keyidx]; @@ -844,7 +844,7 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - if(ieee->short_slot) + if (ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); if (ieee->host_encrypt) @@ -1059,7 +1059,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); //add short_preamble here - if(ieee->short_slot) + if (ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); if (wmm_info_len) //QOS hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS); @@ -1156,7 +1156,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, #endif if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { - if(ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) + if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_GENERIC; @@ -1293,9 +1293,8 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) { struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(&ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + if (ieee80211_is_54g(&ieee->current_network) && + (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 108; printk(KERN_INFO"Using G rates:%d\n", ieee->rate); }else{ @@ -1432,7 +1431,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee /* Join the network for the first time */ ieee->AsocRetryCount = 0; //for HT by amy 080514 - if((ieee->current_network.qos_data.supported == 1) && + if ((ieee->current_network.qos_data.supported == 1) && // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT)) ieee->current_network.bssht.bdSupportHT) /*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/ @@ -1448,8 +1447,8 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee ieee->state = IEEE80211_ASSOCIATING; schedule_work(&ieee->associate_procedure_wq); }else{ - if(ieee80211_is_54g(&ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ + if (ieee80211_is_54g(&ieee->current_network) && + (ieee->modulation & IEEE80211_OFDM_MODULATION)){ ieee->rate = 108; ieee->SetWirelessMode(ieee->dev, IEEE_G); printk(KERN_INFO"Using G rates\n"); @@ -1600,14 +1599,14 @@ static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb *aid = le16_to_cpu(response_head->aid) & 0x3fff; status_code = le16_to_cpu(response_head->status); - if((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || \ - status_code == WLAN_STATUS_CAPS_UNSUPPORTED)&& - ((ieee->mode == IEEE_G) && - (ieee->current_network.mode == IEEE_N_24G) && - (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { - ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; + if ((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || \ + status_code == WLAN_STATUS_CAPS_UNSUPPORTED)&& + ((ieee->mode == IEEE_G) && + (ieee->current_network.mode == IEEE_N_24G) && + (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { + ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; }else { - ieee->AsocRetryCount = 0; + ieee->AsocRetryCount = 0; } return le16_to_cpu(response_head->status); @@ -1682,24 +1681,24 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, return 0; */ dtim = ieee->current_network.dtim_data; - if(!(dtim & IEEE80211_DTIM_VALID)) + if (!(dtim & IEEE80211_DTIM_VALID)) return 0; timeout = ieee->current_network.beacon_interval; //should we use ps_timeout value or beacon_interval ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) + if (dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) return 2; - if(!time_after(jiffies, - dev_trans_start(ieee->dev) + msecs_to_jiffies(timeout))) + if (!time_after(jiffies, + dev_trans_start(ieee->dev) + msecs_to_jiffies(timeout))) return 0; - if(!time_after(jiffies, - ieee->last_rx_ps_time + msecs_to_jiffies(timeout))) + if (!time_after(jiffies, + ieee->last_rx_ps_time + msecs_to_jiffies(timeout))) return 0; - if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && - (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) + if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && + (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; if (time_l) { @@ -1710,7 +1709,7 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, if (time_h) { *time_h = ieee->current_network.last_dtim_sta_time[1]; - if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) + if (time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } @@ -1740,18 +1739,18 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) sleep = ieee80211_sta_ps_sleep(ieee, &th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ - if(sleep == 0) + if (sleep == 0) goto out; - if(sleep == 1){ - if(ieee->sta_sleep == 1) + if (sleep == 1){ + if (ieee->sta_sleep == 1) ieee->enter_sleep_state(ieee->dev, th, tl); - else if(ieee->sta_sleep == 0){ + else if (ieee->sta_sleep == 0){ // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if(ieee->ps_is_queue_empty(ieee->dev)){ + if (ieee->ps_is_queue_empty(ieee->dev)){ ieee->sta_sleep = 2; ieee->ps_request_tx_ack(ieee->dev); @@ -1763,7 +1762,7 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - }else if(sleep == 2){ + }else if (sleep == 2){ //#warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); @@ -1786,7 +1785,7 @@ void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) return; } - if(ieee->sta_sleep == 1) + if (ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); ieee->sta_sleep = 0; @@ -1803,7 +1802,7 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) spin_lock_irqsave(&ieee->lock, flags); - if(ieee->sta_sleep == 2){ + if (ieee->sta_sleep == 2){ /* Null frame with PS bit set */ if (success) { ieee->sta_sleep = 1; @@ -1924,17 +1923,16 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_assoc_response_frame *assoc_resp; // struct ieee80211_info_element *info_element; - if(!ieee->proto_started) + if (!ieee->proto_started) return 0; - if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && - ieee->state == IEEE80211_LINKED)) - + if (ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && + ieee->iw_mode == IW_MODE_INFRA && + ieee->state == IEEE80211_LINKED)) tasklet_schedule(&ieee->ps_task); - if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && - WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) + if (WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP && + WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON) ieee->last_rx_ps_time = jiffies; switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { @@ -1981,7 +1979,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { + if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { schedule_work(&ieee->associate_procedure_wq); } else { ieee80211_associate_abort(ieee); @@ -2087,7 +2085,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * ieee->stats.multicast++; } /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ - for(i = 0; i < txb->nr_frags; i++) { + for (i = 0; i < txb->nr_frags; i++) { #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE if ((skb_queue_len(&ieee->skb_drv_aggQ[queue_index]) != 0) || #else @@ -2127,7 +2125,7 @@ EXPORT_SYMBOL(ieee80211_softmac_xmit); static void ieee80211_resume_tx(struct ieee80211_device *ieee) { int i; - for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { + for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { if (ieee->queue_stop){ ieee->tx_pending.frag = i; @@ -2301,10 +2299,10 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) /* the network definitively is not here.. create a new cell */ if (ieee->state == IEEE80211_NOLINK) { printk("creating new IBSS cell\n"); - if(!ieee->wap_set) + if (!ieee->wap_set) eth_random_addr(ieee->current_network.bssid); - if(ieee->modulation & IEEE80211_CCK_MODULATION){ + if (ieee->modulation & IEEE80211_CCK_MODULATION){ ieee->current_network.rates_len = 4; @@ -2315,7 +2313,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) }else ieee->current_network.rates_len = 0; - if(ieee->modulation & IEEE80211_OFDM_MODULATION){ + if (ieee->modulation & IEEE80211_OFDM_MODULATION){ ieee->current_network.rates_ex_len = 8; ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -2338,7 +2336,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->SetWirelessMode(ieee->dev, IEEE_G); ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; - if(ieee->short_slot) + if (ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; } @@ -2411,7 +2409,7 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - if(IS_DOT11D_ENABLE(ieee)) + if (IS_DOT11D_ENABLE(ieee)) Dot11d_Reset(ieee); ieee->state = IEEE80211_NOLINK; ieee->is_set_key = false; @@ -2428,10 +2426,10 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) unsigned long flags; mutex_lock(&ieee->wx_mutex); - if(!ieee->proto_started) + if (!ieee->proto_started) goto exit; - if(ieee->state != IEEE80211_ASSOCIATING_RETRY) + if (ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; /* until we do not set the state to IEEE80211_NOLINK @@ -2453,7 +2451,7 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) spin_lock_irqsave(&ieee->lock, flags); - if(ieee->state == IEEE80211_NOLINK) + if (ieee->state == IEEE80211_NOLINK) ieee80211_start_scan(ieee); spin_unlock_irqrestore(&ieee->lock, flags); @@ -2486,7 +2484,7 @@ struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) struct ieee80211_probe_response *b; skb = ieee80211_get_beacon_(ieee); - if(!skb) + if (!skb) return NULL; b = (struct ieee80211_probe_response *)skb->data; @@ -2551,7 +2549,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) ch++; if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - }while(!GET_DOT11D_INFO(ieee)->channel_map[ch]); + }while (!GET_DOT11D_INFO(ieee)->channel_map[ch]); ieee->current_network.channel = ch; } @@ -2560,7 +2558,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) // printk("===>%s(), chan:%d\n", __func__, ieee->current_network.channel); // ieee->set_chan(ieee->dev,ieee->current_network.channel); - for(i = 0; i < 17; i++) { + for (i = 0; i < 17; i++) { ieee->last_rxseq_num[i] = -1; ieee->last_rxfrag_num[i] = -1; ieee->last_packet_time[i] = 0; @@ -2582,7 +2580,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) else if (ieee->iw_mode == IW_MODE_MASTER) ieee80211_start_master_bss(ieee); - else if(ieee->iw_mode == IW_MODE_MONITOR) + else if (ieee->iw_mode == IW_MODE_MONITOR) ieee80211_start_monitor_mode(ieee); } @@ -2594,7 +2592,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { ieee->seq_ctrl[i] = 0; } ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_KERNEL); From de6610e27dd2e47aea09f1b1c70f1d1b531d2267 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 7 Jul 2018 15:55:05 +0100 Subject: [PATCH 288/903] staging:rtl8192u: Add spaces required around operators - Coding Style Added the spaces, required by coding style, around the various operators. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 1f6d0fb3c5bd..553e4aff235c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -110,7 +110,7 @@ static void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) *tag++ = 0x01; #ifdef SUPPORT_USPD if (ieee->current_network.wmm_info & 0x80) { - *tag++ = 0x0f|MAX_SP_Len; + *tag++ = 0x0f | MAX_SP_Len; } else { *tag++ = MAX_SP_Len; } @@ -144,7 +144,7 @@ static void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; - nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; + nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; /* * if the queue is full but we have newer frames then @@ -169,7 +169,7 @@ static struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; ieee->mgmt_queue_tail = - (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; + (ieee->mgmt_queue_tail + 1) % MGMT_QUEUE_NUM; return ret; } @@ -194,7 +194,7 @@ static u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee) /* 2005.01.26, by rcnjko. */ if (ieee->mode == IEEE_A || ieee->mode == IEEE_N_5G || - (ieee->mode == IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) + (ieee->mode == IEEE_N_24G && !pHTInfo->bCurSuppCCK)) rate = 0x0c; else rate = 0x02; @@ -239,7 +239,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee if (ieee->queue_stop){ enqueue_mgmt(ieee, skb); }else{ - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); + header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) ieee->seq_ctrl[0] = 0; @@ -376,7 +376,7 @@ static void ieee80211_send_beacon(struct ieee80211_device *ieee) // if(!timer_pending(&ieee->beacon_timer)) // add_timer(&ieee->beacon_timer); mod_timer(&ieee->beacon_timer, - jiffies + msecs_to_jiffies(ieee->current_network.beacon_interval-5)); + jiffies + msecs_to_jiffies(ieee->current_network.beacon_interval - 5)); } //spin_unlock_irqrestore(&ieee->beacon_lock,flags); } @@ -418,9 +418,9 @@ static void ieee80211_send_probe_requests(struct ieee80211_device *ieee) void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) { short ch = 0; - u8 channel_map[MAX_CHANNEL_NUMBER+1]; + u8 channel_map[MAX_CHANNEL_NUMBER + 1]; - memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); + memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER + 1); mutex_lock(&ieee->scan_mutex); while (1) @@ -483,9 +483,9 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) struct delayed_work *dwork = to_delayed_work(work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); static short watchdog; - u8 channel_map[MAX_CHANNEL_NUMBER+1]; + u8 channel_map[MAX_CHANNEL_NUMBER + 1]; - memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); + memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER + 1); if (!ieee->ieee_up) return; mutex_lock(&ieee->scan_mutex); @@ -680,7 +680,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; - int rate_len = ieee->current_network.rates_len+2; + int rate_len = ieee->current_network.rates_len + 2; int rate_ex_len = ieee->current_network.rates_ex_len; int wpa_ie_len = ieee->wpa_ie_len; u8 erpinfo_content = 0; @@ -693,7 +693,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d u8 *tmp_generic_ie_buf = NULL; u8 tmp_generic_ie_len = 0; - if (rate_ex_len > 0) rate_ex_len+=2; + if (rate_ex_len > 0) rate_ex_len += 2; if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; @@ -724,19 +724,19 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); } // printk("===============>tmp_ht_cap_len is %d,tmp_ht_info_len is %d, tmp_generic_ie_len is %d\n",tmp_ht_cap_len,tmp_ht_info_len,tmp_generic_ie_len); - beacon_size = sizeof(struct ieee80211_probe_response)+2+ - ssid_len - +3 //channel - +rate_len - +rate_ex_len - +atim_len - +erp_len - +wpa_ie_len - // +tmp_ht_cap_len - // +tmp_ht_info_len - // +tmp_generic_ie_len -// +wmm_len+2 - +ieee->tx_headroom; + beacon_size = sizeof(struct ieee80211_probe_response) + 2 + + ssid_len + + 3 //channel + + rate_len + + rate_ex_len + + atim_len + + erp_len + + wpa_ie_len + // + tmp_ht_cap_len + // + tmp_ht_info_len + // + tmp_generic_ie_len +// + wmm_len+2 + + ieee->tx_headroom; skb = dev_alloc_skb(beacon_size); if (!skb) return NULL; @@ -772,9 +772,9 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d tag += ssid_len; *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; - memcpy(tag, ieee->current_network.rates, rate_len-2); - tag+=rate_len-2; + *(tag++) = rate_len - 2; + memcpy(tag, ieee->current_network.rates, rate_len - 2); + tag += rate_len - 2; *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; @@ -786,7 +786,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d put_unaligned_le16(ieee->current_network.atim_window, tag); - tag+=2; + tag += 2; } if (erp_len) { @@ -796,9 +796,9 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d } if (rate_ex_len) { *(tag++) = MFIE_TYPE_RATES_EX; - *(tag++) = rate_ex_len-2; - memcpy(tag, ieee->current_network.rates_ex, rate_ex_len-2); - tag+=rate_ex_len-2; + *(tag++) = rate_ex_len - 2; + memcpy(tag, ieee->current_network.rates_ex, rate_ex_len - 2); + tag += rate_ex_len - 2; } if (wpa_ie_len) @@ -874,7 +874,7 @@ static struct sk_buff *ieee80211_auth_resp(struct ieee80211_device *ieee, { struct sk_buff *skb; struct ieee80211_authentication *auth; - int len = ieee->tx_headroom + sizeof(struct ieee80211_authentication)+1; + int len = ieee->tx_headroom + sizeof(struct ieee80211_authentication) + 1; skb = dev_alloc_skb(len); @@ -915,7 +915,7 @@ static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM:0)); + (pwr ? IEEE80211_FCTL_PM : 0)); return skb; } @@ -971,9 +971,9 @@ ieee80211_association_req(struct ieee80211_network *beacon, int encrypt; unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); - unsigned int wmm_info_len = beacon->qos_data.supported?9:0; + unsigned int wmm_info_len = beacon->qos_data.supported ? 9 : 0; #ifdef THOMAS_TURBO - unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; + unsigned int turbo_info_len = beacon->Turbo_Enable ? 9 : 0; #endif int len = 0; @@ -982,7 +982,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); /* Include High Throuput capability && Realtek proprietary */ - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); @@ -995,22 +995,22 @@ ieee80211_association_req(struct ieee80211_network *beacon, } } if (ieee->qos_support) { - wmm_info_len = beacon->qos_data.supported?9:0; + wmm_info_len = beacon->qos_data.supported ? 9 : 0; } if (beacon->bCkipSupported) { - ckip_ie_len = 30+2; + ckip_ie_len = 30 + 2; } if (beacon->bCcxRmEnable) { - ccxrm_ie_len = 6+2; + ccxrm_ie_len = 6 + 2; } if (beacon->BssCcxVerNumber >= 2) - cxvernum_ie_len = 5+2; + cxvernum_ie_len = 5 + 2; #ifdef THOMAS_TURBO - len = sizeof(struct ieee80211_assoc_request_frame)+ 2 + len = sizeof(struct ieee80211_assoc_request_frame) + 2 + beacon->ssid_len /* essid tagged val */ + rate_len /* rates tagged val */ + wpa_ie_len @@ -1023,7 +1023,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, + cxvernum_ie_len + ieee->tx_headroom; #else - len = sizeof(struct ieee80211_assoc_request_frame)+ 2 + len = sizeof(struct ieee80211_assoc_request_frame) + 2 + beacon->ssid_len /* essid tagged val */ + rate_len /* rates tagged val */ + wpa_ie_len @@ -1093,7 +1093,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, // CCX1 spec V1.13, A01.1 CKIP Negotiation (page23): // "The CKIP negotiation is started with the associate request from the client to the access point, // containing an Aironet element with both the MIC and KP bits set." - osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ; + osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK | SUPPORT_CKIP_MIC) ; tag = skb_put(skb, ckip_ie_len); *tag++ = MFIE_TYPE_AIRONET; *tag++ = osCcxAironetIE.Length; @@ -1135,7 +1135,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, *tag++ = MFIE_TYPE_HT_CAP; *tag++ = ht_cap_len - 2; memcpy(tag, ht_cap_buf, ht_cap_len - 2); - tag += ht_cap_len -2; + tag += ht_cap_len - 2; } } @@ -1162,7 +1162,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, *tag++ = MFIE_TYPE_GENERIC; *tag++ = ht_cap_len - 2; memcpy(tag, ht_cap_buf, ht_cap_len - 2); - tag += ht_cap_len -2; + tag += ht_cap_len - 2; } if (ieee->pHTInfo->bCurrentRT2RTAggregation) { @@ -1250,11 +1250,11 @@ static void ieee80211_auth_challenge(struct ieee80211_device *ieee, ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - skb = ieee80211_authentication_req(beacon, ieee, chlen+2); + skb = ieee80211_authentication_req(beacon, ieee, chlen + 2); if (!skb) ieee80211_associate_abort(ieee); else{ - c = skb_put(skb, chlen+2); + c = skb_put(skb, chlen + 2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); @@ -1264,7 +1264,7 @@ static void ieee80211_auth_challenge(struct ieee80211_device *ieee, ieee80211_encrypt_fragment(ieee, skb, sizeof(struct rtl_80211_hdr_3addr )); softmac_mgmt_xmit(skb, ieee); - mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); + mod_timer(&ieee->associate_timer, jiffies + (HZ / 2)); //dev_kfree_skb_any(skb);//edit by thomas } kfree(challenge); @@ -1285,7 +1285,7 @@ static void ieee80211_associate_step2(struct ieee80211_device *ieee) ieee80211_associate_abort(ieee); else{ softmac_mgmt_xmit(skb, ieee); - mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); + mod_timer(&ieee->associate_timer, jiffies + (HZ / 2)); //dev_kfree_skb_any(skb);//edit by thomas } } @@ -1301,7 +1301,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) ieee->rate = 22; printk(KERN_INFO"Using B rates:%d\n", ieee->rate); } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { printk("Successfully associated, ht enabled\n"); HTOnAssocRsp(ieee); @@ -1312,7 +1312,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) memset(ieee->dot11HTOperationalRateSet, 0, 16); //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); } - ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); + ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval / 500); // To prevent the immediately calling watch_dog after association. if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { @@ -1366,7 +1366,7 @@ static void ieee80211_associate_procedure_wq(struct work_struct *work) inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) { - u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; + u8 tmp_ssid[IW_ESSID_MAX_SIZE + 1]; int tmp_ssid_len = 0; short apset, ssidset, ssidbroad, apmatch, ssidmatch; @@ -1392,8 +1392,8 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee ssidset = ieee->ssid_set;//ieee->current_network.ssid[0] != '\0'; ssidbroad = !(net->ssid_len == 0 || net->ssid[0] == '\0'); apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN) == 0); - ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); + ssidmatch = (ieee->current_network.ssid_len == net->ssid_len) && + (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); if ( /* if the user set the AP check if match. * if the network does not broadcast essid we check the user supplyed ANY essid @@ -1549,10 +1549,10 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, tag = skb->data + sizeof (struct rtl_80211_hdr_3addr ); - while (tag+1 < skbend){ + while (tag + 1 < skbend){ if (*tag == 0) { - ssid = tag+2; - ssidlen = *(tag+1); + ssid = tag + 2; + ssidlen = *(tag + 1); break; } tag++; /* point to the len field */ @@ -1599,11 +1599,11 @@ static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb *aid = le16_to_cpu(response_head->aid) & 0x3fff; status_code = le16_to_cpu(response_head->status); - if ((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || \ - status_code == WLAN_STATUS_CAPS_UNSUPPORTED)&& + if ((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || + status_code == WLAN_STATUS_CAPS_UNSUPPORTED) && ((ieee->mode == IEEE_G) && (ieee->current_network.mode == IEEE_N_24G) && - (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { + (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT - 1)))) { ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; }else { ieee->AsocRetryCount = 0; @@ -1686,7 +1686,7 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, timeout = ieee->current_network.beacon_interval; //should we use ps_timeout value or beacon_interval ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - if (dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) + if (dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST) & ieee->ps)) return 2; if (!time_after(jiffies, From 0bde13ed847923dfb55185c5280b7390f627dc80 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 7 Jul 2018 15:55:07 +0100 Subject: [PATCH 289/903] staging:rtl8192u: rename HT_EXTCHNL_OFFSET -> enum ht_extension_chan_width remove the typedef of enumerated type HT_EXTCHNL_OFFSET and replace it with 'enum ht_extension_chan_offset' Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++-- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 6 +++--- drivers/staging/rtl8192u/r819xU_phy.c | 5 +++-- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 8ca24c10c28e..3b7968681f77 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -2002,7 +2002,7 @@ struct ieee80211_device { short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); //added by wb for HT related // void (*SwChnlByTimerHandler)(struct net_device *dev, int channel); - void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); + void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset); // void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate); bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); @@ -2358,7 +2358,7 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); void HTSetConnectBwMode(struct ieee80211_device *ieee, - enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); + enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset); void HTUpdateDefaultSetting(struct ieee80211_device *ieee); void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 isEncrypt); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 804d628ed9eb..81020fbcdc20 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -302,7 +302,7 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) { struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); short chan; - HT_EXTCHNL_OFFSET chan_offset = 0; + enum ht_extension_chan_offset chan_offset = 0; enum ht_channel_width bandwidth = 0; int b40M = 0; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h index c13ca7f0f4dd..7d54a7cd9514 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h @@ -36,12 +36,12 @@ enum ht_channel_width { // Represent Extension Channel Offset in HT Capabilities // This is available only in 40Mhz mode. // -typedef enum _HT_EXTCHNL_OFFSET { +enum ht_extension_chan_offset { HT_EXTCHNL_OFFSET_NO_EXT = 0, HT_EXTCHNL_OFFSET_UPPER = 1, HT_EXTCHNL_OFFSET_NO_DEF = 2, HT_EXTCHNL_OFFSET_LOWER = 3, -}HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET; +}; typedef enum _CHNLOP { CHNLOP_NONE = 0, // No Action now @@ -237,7 +237,7 @@ typedef struct _RT_HIGH_THROUGHPUT { u8 PeerMimoPs; // 40MHz Channel Offset settings. - HT_EXTCHNL_OFFSET CurSTAExtChnlOffset; + enum ht_extension_chan_offset CurSTAExtChnlOffset; u8 bCurTxBW40MHz; // If we use 40 MHz to Tx u8 PeerBandwidth; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 86c63b217d3b..264d15fbcc6b 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -894,7 +894,7 @@ static u8 HTFilterMCSRate(struct ieee80211_device *ieee, u8 *pSupportMCS, return true; } -void HTSetConnectBwMode(struct ieee80211_device *ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTSetConnectBwMode(struct ieee80211_device *ieee, enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset); void HTOnAssocRsp(struct ieee80211_device *ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -936,7 +936,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTInfo, sizeof(HT_INFORMATION_ELE)); // Config Supported Channel Width setting // - HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); + HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extension_chan_offset)(pPeerHTInfo->ExtChlOffset)); pHTInfo->bCurTxBW40MHz = (pPeerHTInfo->RecommemdedTxWidth == 1); @@ -1290,7 +1290,7 @@ u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame) /* * This function set bandwidth mode in protocol layer. */ -void HTSetConnectBwMode(struct ieee80211_device *ieee, enum ht_channel_width Bandwidth, HT_EXTCHNL_OFFSET Offset) +void HTSetConnectBwMode(struct ieee80211_device *ieee, enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; // u32 flags = 0; diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 8bb14cc79d8a..98cfc222e241 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1663,8 +1663,9 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) * notice: I doubt whether SetBWModeInProgress flag is necessary as we can * test whether current work in the queue or not.//do I? *****************************************************************************/ -void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width bandwidth, - HT_EXTCHNL_OFFSET offset) +void rtl8192_SetBWMode(struct net_device *dev, + enum ht_channel_width bandwidth, + enum ht_extension_chan_offset offset) { struct r8192_priv *priv = ieee80211_priv(dev); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index ea0032643620..d2e69228ac8a 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -81,7 +81,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width bandwidth, - HT_EXTCHNL_OFFSET offset); + enum ht_extension_chan_offset offset); void rtl8192_SwChnl_WorkItem(struct net_device *dev); void rtl8192_SetBWModeWorkItem(struct net_device *dev); bool rtl8192_SetRFPowerState(struct net_device *dev, From 058f285ed43c71565d19cc009c281e74a57fe75e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 12:38:50 +0200 Subject: [PATCH 290/903] staging: rtl8723bs: replace while with shorter for loop Simplify rtw_get_rateset_len() by replacing the while loop with a shorter for loop. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 8e0025e1ff14..9b60e0214bd8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -298,17 +298,11 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode) uint rtw_get_rateset_len(u8 *rateset) { - uint i = 0; + uint i; - while (1) { - if ((rateset[i]) == 0) + for (i = 0; i < 13; i++) + if (rateset[i] == 0) break; - - if (i > 12) - break; - - i++; - } return i; } From c9ed0be8ca3a8fa11435eb5117b18f24f599ce10 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 12:38:51 +0200 Subject: [PATCH 291/903] staging: rtl8723bs: replace tab with space Replace tabs with spaces in some function definitions. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 9b60e0214bd8..429ec929fa1a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -67,7 +67,7 @@ int rtw_get_bit_value_from_ieee_value(u8 val) return 0; } -uint rtw_is_cckrates_included(u8 *rate) +uint rtw_is_cckrates_included(u8 *rate) { u32 i = 0; @@ -81,7 +81,7 @@ uint rtw_is_cckrates_included(u8 *rate) return false; } -uint rtw_is_cckratesonly_included(u8 *rate) +uint rtw_is_cckratesonly_included(u8 *rate) { u32 i = 0; @@ -296,7 +296,7 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode) } } -uint rtw_get_rateset_len(u8 *rateset) +uint rtw_get_rateset_len(u8 *rateset) { uint i; From 3ba461286835e0c66c540c871fb7f67d6108e7f9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 12:38:52 +0200 Subject: [PATCH 292/903] staging: rtl8723bs: fix indentation Remove unrequired extra indentations. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 429ec929fa1a..adf216de113b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -69,16 +69,16 @@ int rtw_get_bit_value_from_ieee_value(u8 val) uint rtw_is_cckrates_included(u8 *rate) { - u32 i = 0; + u32 i = 0; - while (rate[i] != 0) { - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) - return true; - i++; - } + while (rate[i] != 0) { + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + return true; + i++; + } - return false; + return false; } uint rtw_is_cckratesonly_included(u8 *rate) From 5d109ed610415b1ddfe741d7a7f60f5eff0b9cd2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 12:38:53 +0200 Subject: [PATCH 293/903] staging: rtl8723bs: remove blank lines Remove unrequired blank lines as reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_ieee80211.c | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index adf216de113b..ab1174f7c83a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -53,11 +53,9 @@ static u8 WIFI_OFDMRATES[] = { IEEE80211_OFDM_RATE_54MB }; - int rtw_get_bit_value_from_ieee_value(u8 val) { unsigned char dot11_rate_table[] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; /* last element must be zero!! */ - int i = 0; while (dot11_rate_table[i] != 0) { if (dot11_rate_table[i] == val) @@ -85,7 +83,6 @@ uint rtw_is_cckratesonly_included(u8 *rate) { u32 i = 0; - while (rate[i] != 0) { if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) @@ -111,7 +108,6 @@ int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) else return WIRELESS_11G; } - } u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, @@ -191,7 +187,6 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u uint cnt; u8 *target_ie = NULL; - if (ielen) *ielen = 0; @@ -215,7 +210,6 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u } else{ cnt += in_ie[cnt+1]+2; /* goto next */ } - } return target_ie; @@ -292,7 +286,6 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode) memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); break; - } } @@ -363,7 +356,6 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) /* DS parameter set */ ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz); - /* IBSS Parameter Set */ ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); @@ -398,10 +390,8 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new); if (pbuf) { - /* check if oui matches... */ if (memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type))) { - goto check_next_ie; } @@ -417,7 +407,6 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) return pbuf; } else{ - *wpa_ie_len = 0; return NULL; } @@ -430,20 +419,16 @@ check_next_ie: break; pbuf += (2 + len); - } *wpa_ie_len = 0; return NULL; - } unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) { - return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit); - } int rtw_get_wpa_cipher_suite(u8 *s) @@ -478,7 +463,6 @@ int rtw_get_wpa2_cipher_suite(u8 *s) return 0; } - int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) { int i, ret = _SUCCESS; @@ -491,7 +475,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis return _FAIL; } - if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) { return _FAIL; @@ -502,10 +485,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis pos += 8; left = wpa_ie_len - 8; - /* group_cipher */ if (left >= WPA_SELECTOR_LEN) { - *group_cipher = rtw_get_wpa_cipher_suite(pos); pos += WPA_SELECTOR_LEN; @@ -517,7 +498,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis return _FAIL; } - /* pairwise_cipher */ if (left >= 2) { /* count = le16_to_cpu(*(u16*)pos); */ @@ -554,7 +534,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis } return ret; - } int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) @@ -569,7 +548,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi return _FAIL; } - if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) { return _FAIL; } @@ -580,7 +558,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi /* group_cipher */ if (left >= RSN_SELECTOR_LEN) { - *group_cipher = rtw_get_wpa2_cipher_suite(pos); pos += RSN_SELECTOR_LEN; @@ -628,7 +605,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi } return ret; - } /* ifdef CONFIG_WAPI_SUPPORT */ @@ -730,7 +706,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, cnt += in_ie[cnt+1]+2; /* get next */ } } - } return (*rsn_len + *wpa_len); @@ -795,7 +770,6 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) } else{ cnt += in_ie[cnt+1]+2; /* goto next */ } - } return wpsie_ptr; @@ -848,7 +822,6 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att } else{ attr_ptr += attr_len; /* goto next */ } - } return target_attr_ptr; @@ -981,7 +954,6 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, } return 0; - } /** @@ -1128,7 +1100,6 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, return ParseFailed; return unknown ? ParseUnknown : ParseOK; - } void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) @@ -1173,7 +1144,6 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) if (pbuf && (wpa_ielen > 0)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen)); if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { - pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; pnetwork->BcnInfo.group_cipher = group_cipher; pnetwork->BcnInfo.is_8021x = is8021x; @@ -1182,7 +1152,6 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) ret = _SUCCESS; } } else { - pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); if (pbuf && (wpa_ielen > 0)) { From bea378608b75116277804c260cff8438681f5ac0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 12:38:54 +0200 Subject: [PATCH 294/903] staging: rtl8723bs: add missing blank lines Add missing blank lines after declarations as reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index ab1174f7c83a..a4f9e2b90b08 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -57,6 +57,7 @@ int rtw_get_bit_value_from_ieee_value(u8 val) { unsigned char dot11_rate_table[] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; /* last element must be zero!! */ int i = 0; + while (dot11_rate_table[i] != 0) { if (dot11_rate_table[i] == val) return BIT(i); @@ -1139,6 +1140,7 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) unsigned char *pbuf; int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; int ret = _FAIL; + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); if (pbuf && (wpa_ielen > 0)) { From 86ef7175e317f78f16013f023065dbb7993e7ecf Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 12:38:55 +0200 Subject: [PATCH 295/903] staging: rtl8723bs: remove braces from single if statement Remove braces from single if statement to follow kernel coding style. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index a4f9e2b90b08..3f1c7bb0eb9f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -149,9 +149,8 @@ u8 *rtw_get_ie(u8 *pbuf, sint index, sint *len, sint limit) sint tmp, i; u8 *p; - if (limit < 1) { + if (limit < 1) return NULL; - } p = pbuf; i = 0; From 4f98cf805d42c652b0c0e6737d8e025de881e293 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 13:58:11 +0200 Subject: [PATCH 296/903] staging: rtl8188eu: refactor rtw_macaddr_cfg() Use ether_addr_copy() instead of memcpy() to copy the mac address. Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of testing each byte of the mac[] array for 0xff and 0x00 shortens the code and improves readability. Instead of a fixed default mac address use a random one to reduce the likelihood of mac address collision. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_ieee80211.c | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 711ebb0ad640..e6dff44e00fd 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -917,25 +917,15 @@ void rtw_macaddr_cfg(u8 *mac_addr) if (rtw_initmac && mac_pton(rtw_initmac, mac)) { /* Users specify the mac address */ - memcpy(mac_addr, mac, ETH_ALEN); + ether_addr_copy(mac_addr, mac); } else { /* Use the mac address stored in the Efuse */ - memcpy(mac, mac_addr, ETH_ALEN); + ether_addr_copy(mac, mac_addr); } - if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) && - (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || - ((mac[0] == 0x0) && (mac[1] == 0x0) && (mac[2] == 0x0) && - (mac[3] == 0x0) && (mac[4] == 0x0) && (mac[5] == 0x0))) { - mac[0] = 0x00; - mac[1] = 0xe0; - mac[2] = 0x4c; - mac[3] = 0x87; - mac[4] = 0x00; - mac[5] = 0x00; - /* use default mac address */ - memcpy(mac_addr, mac, ETH_ALEN); - DBG_88E("MAC Address from efuse error, assign default one !!!\n"); + if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) { + eth_random_addr(mac_addr); + DBG_88E("MAC Address from efuse error, assign random one !!!\n"); } DBG_88E("%s MAC Address = %pM\n", __func__, (mac_addr)); From 7a7a7e0ec450fbde6dd814054001fe231f1af4b5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 8 Jul 2018 13:58:12 +0200 Subject: [PATCH 297/903] staging: rtl8188eu: replace tabs with spaces Replace tabs with spaces in some function definitions and variable declarations. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index e6dff44e00fd..fed33d9acf60 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -73,9 +73,9 @@ int rtw_get_bit_value_from_ieee_value(u8 val) return 0; } -uint rtw_is_cckrates_included(u8 *rate) +uint rtw_is_cckrates_included(u8 *rate) { - u32 i = 0; + u32 i = 0; while (rate[i] != 0) { if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || @@ -86,7 +86,7 @@ uint rtw_is_cckrates_included(u8 *rate) return false; } -uint rtw_is_cckratesonly_included(u8 *rate) +uint rtw_is_cckratesonly_included(u8 *rate) { u32 i = 0; @@ -212,9 +212,9 @@ uint rtw_get_rateset_len(u8 *rateset) int rtw_generate_ie(struct registry_priv *pregistrypriv) { - u8 wireless_mode; - int rateLen; - uint sz = 0; + u8 wireless_mode; + int rateLen; + uint sz = 0; struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *ie = pdev_network->ies; From 466bcdc1fa303be175c45d054bb00effc575033a Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Mon, 9 Jul 2018 10:01:07 -0500 Subject: [PATCH 298/903] staging: fsl-dpaa2/eth: Fix DMA mapping direction We are using DMA_FROM_DEVICE when mapping RX frame buffers, but DMA_BIDIRECTIONAL for unmap. Fix the direction for DMA unmapping operation. Fixes: 87eb55e418b7 ("staging: fsl-dpaa2/eth: Fix potential endless loop") Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 396371728aa1..537d5bb5e294 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -767,7 +767,7 @@ static void free_bufs(struct dpaa2_eth_priv *priv, u64 *buf_array, int count) for (i = 0; i < count; i++) { vaddr = dpaa2_iova_to_virt(priv->iommu_domain, buf_array[i]); dma_unmap_single(dev, buf_array[i], DPAA2_ETH_RX_BUF_SIZE, - DMA_BIDIRECTIONAL); + DMA_FROM_DEVICE); skb_free_frag(vaddr); } } From e0cfb8f2d515312853ade9616248bc62575c61a6 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Mon, 9 Jul 2018 10:01:08 -0500 Subject: [PATCH 299/903] staging: fsl-dpaa2/eth: Remove obsolete reference Commit 2b7c86eb7bf3 ("staging: fsl-dpaa2/eth: Don't enable FAS on Tx") removed the status field from the TX confirm frame annotation, but a reference to it remained in the description of free_tx_fd(). Remove it. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 537d5bb5e294..6331e8debd33 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -522,8 +522,6 @@ static int build_single_fd(struct dpaa2_eth_priv *priv, * back-pointed to is also freed. * This can be called either from dpaa2_eth_tx_conf() or on the error path of * dpaa2_eth_tx(). - * Optionally, return the frame annotation status word (FAS), which needs - * to be checked if we're on the confirmation path. */ static void free_tx_fd(const struct dpaa2_eth_priv *priv, const struct dpaa2_fd *fd) From 0c047227578f64d96d12df0f93c2e53e67272278 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Mon, 9 Jul 2018 10:01:09 -0500 Subject: [PATCH 300/903] staging: fsl-dpaa2/eth: Remove pointless instruction We don't need to call dev_set_drvdata(dev, NULL) on driver remove since core kernel code also performs this step. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 6331e8debd33..439b260a58bf 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -2676,7 +2676,6 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev) fsl_mc_portal_free(priv->mc_io); - dev_set_drvdata(dev, NULL); free_netdev(net_dev); dev_dbg(net_dev->dev.parent, "Removed interface %s\n", net_dev->name); From 3ccc8d475f9e29b87a8f0d114994a7a01c415ce4 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Mon, 9 Jul 2018 10:01:10 -0500 Subject: [PATCH 301/903] staging: fsl-dpaa2/eth: MTU cleanup Don't set the lower MTU limit explicitly, since we use the default value anyway. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 439b260a58bf..24e069c574b0 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -2383,8 +2383,7 @@ static int netdev_init(struct net_device *net_dev) return err; } - /* Set MTU limits */ - net_dev->min_mtu = 68; + /* Set MTU upper limit; lower limit is 68B (default value) */ net_dev->max_mtu = DPAA2_ETH_MAX_MTU; /* Set actual number of queues in the net device */ From 00fee00245e2f2d0ce9376ced63c0f20c406aa62 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Mon, 9 Jul 2018 10:01:11 -0500 Subject: [PATCH 302/903] staging: fsl-dpaa2/eth: Remove Rx frame size check Most Ethernet drivers don't enforce the MTU value as upper limit for ingress frames. We too support receiving frames larger than MTU, so allow that. Remove our ndo_change_mtu implementation, letting the default stack implementation handle things. Also, set the max frame length allowed by hardware only once at probe time, with the largest possible value. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- .../staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 24e069c574b0..4ae2371940bc 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -1243,25 +1243,6 @@ static void dpaa2_eth_get_stats(struct net_device *net_dev, } } -static int dpaa2_eth_change_mtu(struct net_device *net_dev, int mtu) -{ - struct dpaa2_eth_priv *priv = netdev_priv(net_dev); - int err; - - /* Set the maximum Rx frame length to match the transmit side; - * account for L2 headers when computing the MFL - */ - err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token, - (u16)DPAA2_ETH_L2_MAX_FRM(mtu)); - if (err) { - netdev_err(net_dev, "dpni_set_max_frame_length() failed\n"); - return err; - } - - net_dev->mtu = mtu; - return 0; -} - /* Copy mac unicast addresses from @net_dev to @priv. * Its sole purpose is to make dpaa2_eth_set_rx_mode() more readable. */ @@ -1469,7 +1450,6 @@ static const struct net_device_ops dpaa2_eth_ops = { .ndo_init = dpaa2_eth_init, .ndo_set_mac_address = dpaa2_eth_set_addr, .ndo_get_stats64 = dpaa2_eth_get_stats, - .ndo_change_mtu = dpaa2_eth_change_mtu, .ndo_set_rx_mode = dpaa2_eth_set_rx_mode, .ndo_set_features = dpaa2_eth_set_features, .ndo_do_ioctl = dpaa2_eth_ioctl, @@ -2385,6 +2365,12 @@ static int netdev_init(struct net_device *net_dev) /* Set MTU upper limit; lower limit is 68B (default value) */ net_dev->max_mtu = DPAA2_ETH_MAX_MTU; + err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token, + (u16)DPAA2_ETH_MFL); + if (err) { + dev_err(dev, "dpni_set_max_frame_length() failed\n"); + return err; + } /* Set actual number of queues in the net device */ num_queues = dpaa2_eth_queue_count(priv); From 0be0debe4a8a6ff0c7b79ca7c16a656204651a69 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 9 Jul 2018 06:52:45 +0200 Subject: [PATCH 303/903] staging: mt7621-pinctrl: init *map to NULL for correct memory assignation pinctrl_utils_reserve_map() calls krealloc() on *map. Because of this *map need to be initialized to NULL before calling it. Fixes: 62b6215c11ea ("staging: mt7621-pinctrl: make use of pinctrl_utils_reserve_map") Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 70259425e7e9..c223ecb3ad3f 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -88,6 +88,7 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, for_each_node_with_property(np_config, "group") ngroups++; + *map = NULL; ret = pinctrl_utils_reserve_map(pctrldev, map, &reserved_maps, num_maps, ngroups); if (ret) { From 1d2d116a93f0e9bf0bca72da76a96edef8a1d36d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 9 Jul 2018 13:28:30 +0200 Subject: [PATCH 304/903] Revert "staging: mt7621-pinctrl: replace core_initcall_sync with builtin_platform_driver" That patch causes the network interface on the device to stop working. device_initcall() is called much later than core_initcall_sync() and that seem to be a problem. Revert it to get a correct behaviour. Reported-by: NeilBrown Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index c223ecb3ad3f..b8566ed898f1 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -423,4 +423,9 @@ static struct platform_driver rt2880_pinmux_driver = { }, }; -builtin_platform_driver(rt2880_pinmux_driver); +int __init rt2880_pinmux_init(void) +{ + return platform_driver_register(&rt2880_pinmux_driver); +} + +core_initcall_sync(rt2880_pinmux_init); From 1cb5c5596b2621b5f5457d2f35048b7ee020ff5c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Jul 2018 15:50:39 +0200 Subject: [PATCH 305/903] staging: rtl8723bs: use mac_pton() Use mac_pton() instead of custom approach. Remove the now unused hex2num_i() and hwaddr_aton_i(). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 7dd9521fedfb..ceb2b10fa0b2 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -39,44 +39,6 @@ static const char * const iw_operation_mode[] = { "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor" }; -static int hex2num_i(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - return -1; -} - -/** - * hwaddr_aton - Convert ASCII string to MAC address - * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") - * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) - * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) - */ -static int hwaddr_aton_i(const char *txt, u8 *addr) -{ - int i; - - for (i = 0; i < 6; i++) { - int a, b; - - a = hex2num_i(*txt++); - if (a < 0) - return -1; - b = hex2num_i(*txt++); - if (b < 0) - return -1; - *addr++ = (a << 4) | b; - if (i < 5 && *txt++ != ':') - return -1; - } - - return 0; -} - void indicate_wx_scan_complete_event(struct adapter *padapter) { union iwreq_data wrqu; @@ -2567,8 +2529,7 @@ static int rtw_get_ap_info(struct net_device *dev, pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - /* if (hwaddr_aton_i(pdata->pointer, bssid)) */ - if (hwaddr_aton_i(data, bssid)) { + if (!mac_pton(data, bssid)) { DBG_871X("Invalid BSSID '%s'.\n", (u8 *)data); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); return -EINVAL; From 7c478d6a22392dd60f4e312a13f69fb620c27c83 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 9 Jul 2018 18:05:48 +0200 Subject: [PATCH 306/903] staging: mt7621-gpio: remove driver from staging Remove driver from staging. It has been accepted in the linux-gpio tree. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/mt7621-gpio/Kconfig | 8 - drivers/staging/mt7621-gpio/Makefile | 3 - drivers/staging/mt7621-gpio/TODO | 3 - drivers/staging/mt7621-gpio/gpio-mt7621.c | 331 ------------------ .../mt7621-gpio/mediatek,mt7621-gpio.txt | 35 -- 7 files changed, 383 deletions(-) delete mode 100644 drivers/staging/mt7621-gpio/Kconfig delete mode 100644 drivers/staging/mt7621-gpio/Makefile delete mode 100644 drivers/staging/mt7621-gpio/TODO delete mode 100644 drivers/staging/mt7621-gpio/gpio-mt7621.c delete mode 100644 drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 6f578551d8e3..3fa39109bd75 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -112,8 +112,6 @@ source "drivers/staging/pi433/Kconfig" source "drivers/staging/mt7621-pinctrl/Kconfig" -source "drivers/staging/mt7621-gpio/Kconfig" - source "drivers/staging/mt7621-spi/Kconfig" source "drivers/staging/mt7621-dma/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 3872351cf63e..7a0ff10f5ebb 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -47,7 +47,6 @@ obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/ obj-$(CONFIG_PI433) += pi433/ obj-$(CONFIG_SOC_MT7621) += mt7621-pci/ obj-$(CONFIG_SOC_MT7621) += mt7621-pinctrl/ -obj-$(CONFIG_SOC_MT7621) += mt7621-gpio/ obj-$(CONFIG_SOC_MT7621) += mt7621-spi/ obj-$(CONFIG_SOC_MT7621) += mt7621-dma/ obj-$(CONFIG_SOC_MT7621) += mt7621-mmc/ diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig deleted file mode 100644 index 5485dd2d9b61..000000000000 --- a/drivers/staging/mt7621-gpio/Kconfig +++ /dev/null @@ -1,8 +0,0 @@ -config GPIO_MT7621 - bool "Mediatek MT7621 GPIO Support" - depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST - select GPIO_GENERIC - select GPIOLIB_IRQCHIP - select ARCH_REQUIRE_GPIOLIB - help - Say yes here to support the Mediatek MT7621 SoC GPIO device diff --git a/drivers/staging/mt7621-gpio/Makefile b/drivers/staging/mt7621-gpio/Makefile deleted file mode 100644 index e269ab1b8717..000000000000 --- a/drivers/staging/mt7621-gpio/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o - -ccflags-y += -I$(srctree)/$(src)/include diff --git a/drivers/staging/mt7621-gpio/TODO b/drivers/staging/mt7621-gpio/TODO deleted file mode 100644 index 674930a10716..000000000000 --- a/drivers/staging/mt7621-gpio/TODO +++ /dev/null @@ -1,3 +0,0 @@ -- general code review and clean up - -Cc: NeilBrown diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c deleted file mode 100644 index d7256b56e621..000000000000 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ /dev/null @@ -1,331 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (C) 2009-2011 Gabor Juhos - * Copyright (C) 2013 John Crispin - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MTK_BANK_CNT 3 -#define MTK_BANK_WIDTH 32 - -#define GPIO_BANK_WIDE 0x04 -#define GPIO_REG_CTRL 0x00 -#define GPIO_REG_POL 0x10 -#define GPIO_REG_DATA 0x20 -#define GPIO_REG_DSET 0x30 -#define GPIO_REG_DCLR 0x40 -#define GPIO_REG_REDGE 0x50 -#define GPIO_REG_FEDGE 0x60 -#define GPIO_REG_HLVL 0x70 -#define GPIO_REG_LLVL 0x80 -#define GPIO_REG_STAT 0x90 -#define GPIO_REG_EDGE 0xA0 - -struct mtk_gc { - struct gpio_chip chip; - spinlock_t lock; - int bank; - u32 rising; - u32 falling; - u32 hlevel; - u32 llevel; -}; - -/** - * struct mtk_data - state container for - * data of the platform driver. It is 3 - * separate gpio-chip each one with its - * own irq_chip. - * @dev: device instance - * @gpio_membase: memory base address - * @gpio_irq: irq number from the device tree - * @gc_map: array of the gpio chips - */ -struct mtk_data { - struct device *dev; - void __iomem *gpio_membase; - int gpio_irq; - struct mtk_gc gc_map[MTK_BANK_CNT]; -}; - -static inline struct mtk_gc * -to_mediatek_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct mtk_gc, chip); -} - -static inline void -mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val) -{ - struct gpio_chip *gc = &rg->chip; - struct mtk_data *gpio_data = gpiochip_get_data(gc); - - offset = (rg->bank * GPIO_BANK_WIDE) + offset; - gc->write_reg(gpio_data->gpio_membase + offset, val); -} - -static inline u32 -mtk_gpio_r32(struct mtk_gc *rg, u32 offset) -{ - struct gpio_chip *gc = &rg->chip; - struct mtk_data *gpio_data = gpiochip_get_data(gc); - - offset = (rg->bank * GPIO_BANK_WIDE) + offset; - return gc->read_reg(gpio_data->gpio_membase + offset); -} - -static irqreturn_t -mediatek_gpio_irq_handler(int irq, void *data) -{ - struct gpio_chip *gc = data; - struct mtk_gc *rg = to_mediatek_gpio(gc); - irqreturn_t ret = IRQ_NONE; - unsigned long pending; - int bit; - - pending = mtk_gpio_r32(rg, GPIO_REG_STAT); - - for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) { - u32 map = irq_find_mapping(gc->irq.domain, bit); - - generic_handle_irq(map); - mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit)); - ret |= IRQ_HANDLED; - } - - return ret; -} - -static void -mediatek_gpio_irq_unmask(struct irq_data *d) -{ - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct mtk_gc *rg = to_mediatek_gpio(gc); - int pin = d->hwirq; - unsigned long flags; - u32 rise, fall, high, low; - - spin_lock_irqsave(&rg->lock, flags); - rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); - fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); - high = mtk_gpio_r32(rg, GPIO_REG_HLVL); - low = mtk_gpio_r32(rg, GPIO_REG_LLVL); - mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (BIT(pin) & rg->rising)); - mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (BIT(pin) & rg->falling)); - mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (BIT(pin) & rg->hlevel)); - mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (BIT(pin) & rg->llevel)); - spin_unlock_irqrestore(&rg->lock, flags); -} - -static void -mediatek_gpio_irq_mask(struct irq_data *d) -{ - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct mtk_gc *rg = to_mediatek_gpio(gc); - int pin = d->hwirq; - unsigned long flags; - u32 rise, fall, high, low; - - spin_lock_irqsave(&rg->lock, flags); - rise = mtk_gpio_r32(rg, GPIO_REG_REDGE); - fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE); - high = mtk_gpio_r32(rg, GPIO_REG_HLVL); - low = mtk_gpio_r32(rg, GPIO_REG_LLVL); - mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~BIT(pin)); - mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~BIT(pin)); - mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin)); - mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin)); - spin_unlock_irqrestore(&rg->lock, flags); -} - -static int -mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) -{ - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct mtk_gc *rg = to_mediatek_gpio(gc); - int pin = d->hwirq; - u32 mask = BIT(pin); - - if (type == IRQ_TYPE_PROBE) { - if ((rg->rising | rg->falling | - rg->hlevel | rg->llevel) & mask) - return 0; - - type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; - } - - rg->rising &= ~mask; - rg->falling &= ~mask; - rg->hlevel &= ~mask; - rg->llevel &= ~mask; - - switch (type & IRQ_TYPE_SENSE_MASK) { - case IRQ_TYPE_EDGE_BOTH: - rg->rising |= mask; - rg->falling |= mask; - break; - case IRQ_TYPE_EDGE_RISING: - rg->rising |= mask; - break; - case IRQ_TYPE_EDGE_FALLING: - rg->falling |= mask; - break; - case IRQ_TYPE_LEVEL_HIGH: - rg->hlevel |= mask; - break; - case IRQ_TYPE_LEVEL_LOW: - rg->llevel |= mask; - break; - } - - return 0; -} - -static struct irq_chip mediatek_gpio_irq_chip = { - .irq_unmask = mediatek_gpio_irq_unmask, - .irq_mask = mediatek_gpio_irq_mask, - .irq_mask_ack = mediatek_gpio_irq_mask, - .irq_set_type = mediatek_gpio_irq_type, -}; - -static int -mediatek_gpio_xlate(struct gpio_chip *chip, - const struct of_phandle_args *spec, u32 *flags) -{ - int gpio = spec->args[0]; - struct mtk_gc *rg = to_mediatek_gpio(chip); - - if (rg->bank != gpio / MTK_BANK_WIDTH) - return -EINVAL; - - if (flags) - *flags = spec->args[1]; - - return gpio % MTK_BANK_WIDTH; -} - -static int -mediatek_gpio_bank_probe(struct platform_device *pdev, - struct device_node *node, int bank) -{ - struct mtk_data *gpio = dev_get_drvdata(&pdev->dev); - struct mtk_gc *rg; - void __iomem *dat, *set, *ctrl, *diro; - int ret; - - rg = &gpio->gc_map[bank]; - memset(rg, 0, sizeof(*rg)); - - spin_lock_init(&rg->lock); - rg->chip.of_node = node; - rg->bank = bank; - - dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE); - set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE); - ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE); - diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE); - - ret = bgpio_init(&rg->chip, &pdev->dev, 4, - dat, set, ctrl, diro, NULL, 0); - if (ret) { - dev_err(&pdev->dev, "bgpio_init() failed\n"); - return ret; - } - - rg->chip.of_gpio_n_cells = 2; - rg->chip.of_xlate = mediatek_gpio_xlate; - rg->chip.label = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-bank%d", - dev_name(&pdev->dev), bank); - - ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio); - if (ret < 0) { - dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n", - rg->chip.ngpio, ret); - return ret; - } - - if (gpio->gpio_irq) { - /* - * Manually request the irq here instead of passing - * a flow-handler to gpiochip_set_chained_irqchip, - * because the irq is shared. - */ - ret = devm_request_irq(&pdev->dev, gpio->gpio_irq, - mediatek_gpio_irq_handler, IRQF_SHARED, - rg->chip.label, &rg->chip); - - if (ret) { - dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n", - gpio->gpio_irq, ret); - return ret; - } - - ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip, - 0, handle_simple_irq, IRQ_TYPE_NONE); - if (ret) { - dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n"); - return ret; - } - - gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip, - gpio->gpio_irq, NULL); - } - - /* set polarity to low for all gpios */ - mtk_gpio_w32(rg, GPIO_REG_POL, 0); - - dev_info(&pdev->dev, "registering %d gpios\n", rg->chip.ngpio); - - return 0; -} - -static int -mediatek_gpio_probe(struct platform_device *pdev) -{ - struct device_node *np = pdev->dev.of_node; - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - struct mtk_data *gpio_data; - int i; - - gpio_data = devm_kzalloc(&pdev->dev, sizeof(*gpio_data), GFP_KERNEL); - if (!gpio_data) - return -ENOMEM; - - gpio_data->gpio_membase = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(gpio_data->gpio_membase)) - return PTR_ERR(gpio_data->gpio_membase); - - gpio_data->gpio_irq = irq_of_parse_and_map(np, 0); - gpio_data->dev = &pdev->dev; - platform_set_drvdata(pdev, gpio_data); - mediatek_gpio_irq_chip.name = dev_name(&pdev->dev); - - for (i = 0; i < MTK_BANK_CNT; i++) - mediatek_gpio_bank_probe(pdev, np, i); - - return 0; -} - -static const struct of_device_id mediatek_gpio_match[] = { - { .compatible = "mediatek,mt7621-gpio" }, - {}, -}; -MODULE_DEVICE_TABLE(of, mediatek_gpio_match); - -static struct platform_driver mediatek_gpio_driver = { - .probe = mediatek_gpio_probe, - .driver = { - .name = "mt7621_gpio", - .of_match_table = mediatek_gpio_match, - }, -}; - -builtin_platform_driver(mediatek_gpio_driver); diff --git a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt deleted file mode 100644 index ba455589f869..000000000000 --- a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt +++ /dev/null @@ -1,35 +0,0 @@ -Mediatek MT7621 SoC GPIO controller bindings - -The IP core used inside these SoCs has 3 banks of 32 GPIOs each. -The registers of all the banks are interwoven inside one single IO range. -We load one GPIO controller instance per bank. Also the GPIO controller can receive -interrupts on any of the GPIOs, either edge or level. It then interrupts the CPU -using GIC INT12. - -Required properties for the top level node: -- #gpio-cells : Should be two. The first cell is the GPIO pin number and the - second cell specifies GPIO flags, as defined in . - Only the GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported. -- #interrupt-cells : Specifies the number of cells needed to encode an - interrupt. Should be 2. The first cell defines the interrupt number, - the second encodes the triger flags encoded as described in - Documentation/devicetree/bindings/interrupt-controller/interrupts.txt -- compatible: - - "mediatek,mt7621-gpio" for Mediatek controllers -- reg : Physical base address and length of the controller's registers -- interrupt-parent : phandle of the parent interrupt controller. -- interrupts : Interrupt specifier for the controllers interrupt. -- interrupt-controller : Mark the device node as an interrupt controller. -- gpio-controller : Marks the device node as a GPIO controller. - -Example: - gpio@600 { - #gpio-cells = <2>; - #interrupt-cells = <2>; - compatible = "mediatek,mt7621-gpio"; - gpio-controller; - interrupt-controller; - reg = <0x600 0x100>; - interrupt-parent = <&gic>; - interrupts = ; - }; From fc4afdfea0428f8a564b62a6d668da95935b6cbf Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 9 Jul 2018 22:21:03 +0200 Subject: [PATCH 307/903] staging: mt7621-pci: remove unused macro MV_READ_DATA This macro is not being used at all along the code. Just remove it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index c12447dfbc0f..89a57a02ae57 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -117,9 +117,6 @@ *(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data) #define MV_READ(ofs, data) \ *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs))) -#define MV_READ_DATA(ofs) \ - le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs))) - #define MV_WRITE_16(ofs, data) \ *(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data) #define MV_READ_16(ofs, data) \ From 2427d174a476199111a20e74f76fda21296134f7 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 9 Jul 2018 22:21:04 +0200 Subject: [PATCH 308/903] staging: mt7621-pci: factor out mt7621_pci_get_cfgaddr function To get config address the same pattern is repeated in some functions along the code. Factor out a new mt7621_pci_get_cfgaddr for calculate it and use it in convenient places. Adjust types to match to u32 where is neccesary. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 89a57a02ae57..4f568401b37e 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -177,19 +177,26 @@ static int pcie_link_status = 0; #define PCI_ACCESS_WRITE_2 4 #define PCI_ACCESS_WRITE_4 5 +static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot, + unsigned int func, unsigned int where) +{ + return (((where & 0xF00) >> 8) << 24) | (bus << 16) | (slot << 11) | + (func << 8) | (where & 0xfc) | 0x80000000; +} + static int config_access(unsigned char access_type, struct pci_bus *bus, unsigned int devfn, unsigned int where, u32 *data) { unsigned int slot = PCI_SLOT(devfn); u8 func = PCI_FUNC(devfn); - uint32_t address_reg, data_reg; + u32 address_reg, data_reg; unsigned int address; address_reg = RALINK_PCI_CONFIG_ADDR; data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG; - address = (((where&0xF00)>>8)<<24) |(bus->number << 16) | (slot << 11) | - (func << 8) | (where & 0xfc) | 0x80000000; + address = mt7621_pci_get_cfgaddr(bus->number, slot, func, where); + MV_WRITE(address_reg, address); switch (access_type) { @@ -305,11 +312,11 @@ static struct pci_controller mt7621_controller = { static void read_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned long reg, unsigned long *val) { - unsigned int address_reg, data_reg, address; + u32 address_reg, data_reg, address; address_reg = RALINK_PCI_CONFIG_ADDR; data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG; - address = (((reg & 0xF00)>>8)<<24) | (bus << 16) | (dev << 11) | (func << 8) | (reg & 0xfc) | 0x80000000 ; + address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); MV_WRITE(address_reg, address); MV_READ(data_reg, val); return; @@ -318,11 +325,11 @@ read_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned l static void write_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned long reg, unsigned long val) { - unsigned int address_reg, data_reg, address; + u32 address_reg, data_reg, address; address_reg = RALINK_PCI_CONFIG_ADDR; data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG; - address = (((reg & 0xF00)>>8)<<24) | (bus << 16) | (dev << 11) | (func << 8) | (reg & 0xfc) | 0x80000000 ; + address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); MV_WRITE(address_reg, address); MV_WRITE(data_reg, val); return; From 63688e61d5629c3b931562315bd0373335269880 Mon Sep 17 00:00:00 2001 From: Sophie Matter Date: Wed, 11 Jul 2018 11:45:51 +0200 Subject: [PATCH 309/903] staging: pi433: Comply with 80 character column limit Lines have been split where it makes sense to shorten them in order to comply with the coding standards and fix checkpatch.pl warnings. There are still lines left that are too long, however breaking those would impair readability. Changes in v2: - now working on staging-next branch of the staging tree - the changes to the defines previously made are deleted due to readability Signed-off-by: Sophie Matter Signed-off-by: Rico Schrage Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 13 ++++++++++--- drivers/staging/pi433/pi433_if.h | 6 ++++-- drivers/staging/pi433/rf69.c | 10 +++++++--- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 293602d87c0f..cced28afe454 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -826,11 +826,15 @@ pi433_write(struct file *filp, const char __user *buf, instance = filp->private_data; device = instance->device; - /* check, whether internal buffer (tx thread) is big enough for requested size */ + /* + * check, whether internal buffer (tx thread) is big enough + * for requested size + */ if (count > MAX_MSG_SIZE) return -EMSGSIZE; - /* write the following sequence into fifo: + /* + * write the following sequence into fifo: * - tx_cfg * - size of message * - message @@ -1116,7 +1120,10 @@ static int pi433_probe(struct spi_device *spi) /* setup spi parameters */ spi->mode = 0x00; spi->bits_per_word = 8; - /* spi->max_speed_hz = 10000000; 1MHz already set by device tree overlay */ + /* + * spi->max_speed_hz = 10000000; + * 1MHz already set by device tree overlay + */ retval = spi_setup(spi); if (retval) { diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index 0e0c1b0ab1a6..2d4fa77c793e 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -43,7 +43,8 @@ enum option_on_off { /* IOCTL structs and commands */ /** - * struct pi433_tx_config - describes the configuration of the radio module for sending + * struct pi433_tx_config + * describes the configuration of the radio module for sending * @frequency: * @bit_rate: * @modulation: @@ -90,7 +91,8 @@ struct pi433_tx_cfg { }; /** - * struct pi433_rx_config - describes the configuration of the radio module for sending + * struct pi433_rx_config + * describes the configuration of the radio module for sending * @frequency: * @bit_rate: * @modulation: diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 724c24ce1428..77e0a677ea96 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -128,9 +128,13 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, mode_map[mode]); - // we are using packet mode, so this check is not really needed - // but waiting for mode ready is necessary when going from sleep because the FIFO may not be immediately available from previous mode - //while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady + /* + * we are using packet mode, so this check is not really needed + * but waiting for mode ready is necessary when going from sleep + * because the FIFO may not be immediately available from previous mode + * while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & + RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady + */ } int rf69_set_data_mode(struct spi_device *spi, u8 data_mode) From 368928160477d7315a2b06cf640e34374aa36fcb Mon Sep 17 00:00:00 2001 From: Sophie Matter Date: Wed, 11 Jul 2018 11:45:52 +0200 Subject: [PATCH 310/903] staging: pi433: Use preferred commenting style For multi-line comments, the preferred commenting style from the coding style Documentation was applied to the comments, meaning almost blank lines at the beginning and end of the comment. One changed comment includes a line over 80 characters, causing checkpatch.pl to complain, however breaking this line would not make much sense, so it is kept like it is. Signed-off-by: Sophie Matter Signed-off-by: Rico Schrage Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 30 ++++++++++++++++++++---------- drivers/staging/pi433/rf69.c | 15 ++++++++++----- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index cced28afe454..511b2b531732 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -66,10 +66,12 @@ static DEFINE_MUTEX(minor_lock); /* Protect idr accesses */ static struct class *pi433_class; /* mainly for udev to create /dev/pi433 */ -/* tx config is instance specific +/* + * tx config is instance specific * so with each open a new tx config struct is needed */ -/* rx config is device specific +/* + * rx config is device specific * so we have just one rx config, ebedded in device struct */ struct pi433_device { @@ -584,7 +586,8 @@ pi433_tx_thread(void *data) if (kthread_should_stop()) return 0; - /* get data from fifo in the following order: + /* + * get data from fifo in the following order: * - tx_cfg * - size of message * - message @@ -639,7 +642,8 @@ pi433_tx_thread(void *data) dev_dbg(device->dev, "read %d message byte(s) from fifo queue.", retval); - /* if rx is active, we need to interrupt the waiting for + /* + * if rx is active, we need to interrupt the waiting for * incoming telegrams, to be able to send something. * We are only allowed, if currently no reception takes * place otherwise we need to wait for the incoming telegram @@ -649,14 +653,16 @@ pi433_tx_thread(void *data) !device->rx_active || device->interrupt_rx_allowed); - /* prevent race conditions + /* + * prevent race conditions * irq will be reenabled after tx config is set */ disable_irq(device->irq_num[DIO0]); device->tx_active = true; if (device->rx_active && !rx_interrupted) { - /* rx is currently waiting for a telegram; + /* + * rx is currently waiting for a telegram; * we need to set the radio module to standby */ retval = rf69_set_mode(device->spi, standby); @@ -1097,7 +1103,8 @@ static void pi433_free_minor(struct pi433_device *dev) static const struct file_operations pi433_fops = { .owner = THIS_MODULE, - /* REVISIT switch to aio primitives, so that userspace + /* + * REVISIT switch to aio primitives, so that userspace * gets more complete API coverage. It'll simplify things * too, except for the locking. */ @@ -1316,7 +1323,8 @@ static struct spi_driver pi433_spi_driver = { .probe = pi433_probe, .remove = pi433_remove, - /* NOTE: suspend/resume methods are not necessary here. + /* + * NOTE: suspend/resume methods are not necessary here. * We don't do anything except pass the requests to/from * the underlying controller. The refrigerator handles * most issues; the controller driver handles the rest. @@ -1329,13 +1337,15 @@ static int __init pi433_init(void) { int status; - /* If MAX_MSG_SIZE is smaller then FIFO_SIZE, the driver won't + /* + * If MAX_MSG_SIZE is smaller then FIFO_SIZE, the driver won't * work stable - risk of buffer overflow */ if (MAX_MSG_SIZE < FIFO_SIZE) return -EINVAL; - /* Claim device numbers. Then register a class + /* + * Claim device numbers. Then register a class * that will key udev/mdev to add/remove /dev nodes. Last, register * Last, register the driver which manages those device numbers. */ diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 77e0a677ea96..2dcda814fce0 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -42,7 +42,8 @@ static u8 rf69_read_reg(struct spi_device *spi, u8 addr) #ifdef DEBUG_VALUES if (retval < 0) - /* should never happen, since we already checked, + /* + * should never happen, since we already checked, * that module is connected. Therefore no error * handling, just an optional error message... */ @@ -66,7 +67,8 @@ static int rf69_write_reg(struct spi_device *spi, u8 addr, u8 value) #ifdef DEBUG_VALUES if (retval < 0) - /* should never happen, since we already checked, + /* + * should never happen, since we already checked, * that module is connected. Therefore no error * handling, just an optional error message... */ @@ -576,8 +578,10 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag) return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH); case fifo_full: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_FULL); -/* case fifo_not_empty: - * return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); */ +/* + * case fifo_not_empty: + * return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); + */ case fifo_empty: return !(rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); case fifo_level_below_threshold: @@ -773,7 +777,8 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold) if (retval) return retval; - /* access the fifo to activate new threshold + /* + * access the fifo to activate new threshold * retval (mis-) used as buffer here */ return rf69_read_fifo(spi, (u8 *)&retval, 1); From 75971225d8700ce968fe876a971d714913b845c7 Mon Sep 17 00:00:00 2001 From: Sophie Matter Date: Wed, 11 Jul 2018 11:45:53 +0200 Subject: [PATCH 311/903] staging: pi433: Make only one statement per line Lines containing multiple statements were broken into multiple lines, increasing readability and complying with the coding standard. This also fixes several checkpatch.pl errors complaining about the lines being too long. Signed-off-by: Sophie Matter Signed-off-by: Rico Schrage Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/rf69.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 2dcda814fce0..085272fb393f 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -525,22 +525,34 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value) switch (dio_number) { case 0: - mask = MASK_DIO0; shift = SHIFT_DIO0; dio_addr = REG_DIOMAPPING1; + mask = MASK_DIO0; + shift = SHIFT_DIO0; + dio_addr = REG_DIOMAPPING1; break; case 1: - mask = MASK_DIO1; shift = SHIFT_DIO1; dio_addr = REG_DIOMAPPING1; + mask = MASK_DIO1; + shift = SHIFT_DIO1; + dio_addr = REG_DIOMAPPING1; break; case 2: - mask = MASK_DIO2; shift = SHIFT_DIO2; dio_addr = REG_DIOMAPPING1; + mask = MASK_DIO2; + shift = SHIFT_DIO2; + dio_addr = REG_DIOMAPPING1; break; case 3: - mask = MASK_DIO3; shift = SHIFT_DIO3; dio_addr = REG_DIOMAPPING1; + mask = MASK_DIO3; + shift = SHIFT_DIO3; + dio_addr = REG_DIOMAPPING1; break; case 4: - mask = MASK_DIO4; shift = SHIFT_DIO4; dio_addr = REG_DIOMAPPING2; + mask = MASK_DIO4; + shift = SHIFT_DIO4; + dio_addr = REG_DIOMAPPING2; break; case 5: - mask = MASK_DIO5; shift = SHIFT_DIO5; dio_addr = REG_DIOMAPPING2; + mask = MASK_DIO5; + shift = SHIFT_DIO5; + dio_addr = REG_DIOMAPPING2; break; default: dev_dbg(&spi->dev, "set: illegal input param"); From c833223652cf5ee0440413831d679419b69a1b7b Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 11 Jul 2018 11:32:29 +0100 Subject: [PATCH 312/903] staging: comedi: remove redundant variable segpos Variable segpos is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'segpos' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 4 ++-- drivers/staging/comedi/drivers/pcl818.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index d722079f3327..d87cf6d4a161 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -282,7 +282,7 @@ static int check_channel_list(struct comedi_device *dev, unsigned int chanlen) { unsigned int chansegment[16]; - unsigned int i, nowmustbechan, seglen, segpos; + unsigned int i, nowmustbechan, seglen; /* correct channel and range number check itself comedi/range.c */ if (chanlen < 1) { @@ -312,7 +312,7 @@ static int check_channel_list(struct comedi_device *dev, } /* check whole chanlist */ - for (i = 0, segpos = 0; i < chanlen; i++) { + for (i = 0; i < chanlen; i++) { if (chanlist[i] != chansegment[i % seglen]) { dev_dbg(dev->class_dev, "bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index eebb49751713..0af5315d4357 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -573,7 +573,7 @@ static int check_channel_list(struct comedi_device *dev, unsigned int *chanlist, unsigned int n_chan) { unsigned int chansegment[16]; - unsigned int i, nowmustbechan, seglen, segpos; + unsigned int i, nowmustbechan, seglen; /* correct channel and range number check itself comedi/range.c */ if (n_chan < 1) { @@ -605,7 +605,7 @@ static int check_channel_list(struct comedi_device *dev, } /* check whole chanlist */ - for (i = 0, segpos = 0; i < n_chan; i++) { + for (i = 0; i < n_chan; i++) { if (chanlist[i] != chansegment[i % seglen]) { dev_dbg(dev->class_dev, "bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", From 5a2c3ebe749d91136e4fe7a6a51f10f2d0703665 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 11 Jul 2018 11:40:05 +0100 Subject: [PATCH 313/903] staging: gasket: remove redundant pointer bar_data Pointer bar_data is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'bar_data' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index ad9442a5bb9d..45914ebc8f44 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1610,7 +1610,6 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) bool is_coherent_region; const struct gasket_driver_desc *driver_desc; struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data; - struct gasket_bar_data *bar_data; const struct gasket_bar_desc *bar_desc; struct gasket_mappable_region *map_regions = NULL; int num_map_regions = 0; @@ -1673,8 +1672,6 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) * Subtract the base of the bar from the raw offset to get the * memory location within the bar to map. */ - bar_data = &gasket_dev->bar_data[bar_index]; - bar_desc = &driver_desc->bar_descriptions[bar_index]; permissions = bar_desc->permissions; if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) { From d8353a75005d518293307b3da7c919b08a778864 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 11 Jul 2018 11:49:21 +0100 Subject: [PATCH 314/903] staging: gdm724x: redundant variables idProduct and idVendor Variable idProduct and idVendor are being assigned but are never used hence they are redundant and can be removed. Cleans up clang warnings: warning: variable 'idProduct' set but not used [-Wunused-but-set-variable] warning: variable 'idVendor' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_usb.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c index 0218782d1a08..dc4da66c3695 100644 --- a/drivers/staging/gdm724x/gdm_usb.c +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -879,14 +879,9 @@ static void gdm_usb_disconnect(struct usb_interface *intf) { struct phy_dev *phy_dev; struct lte_udev *udev; - u16 idVendor, idProduct; struct usb_device *usbdev; usbdev = interface_to_usbdev(intf); - - idVendor = __le16_to_cpu(usbdev->descriptor.idVendor); - idProduct = __le16_to_cpu(usbdev->descriptor.idProduct); - phy_dev = usb_get_intfdata(intf); udev = phy_dev->priv_dev; From 15fc3e4a08872dafe0e4f32a8fda5694ee3a6f03 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 11 Jul 2018 11:59:11 +0100 Subject: [PATCH 315/903] staging: ks7010: remove redundant variable eth_proto Variable eth_proto is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'eth_proto' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 0ecffab52ec2..a85975f63d26 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -354,7 +354,6 @@ void hostif_data_indication(struct ks_wlan_private *priv) u16 auth_type; unsigned char temp[256]; struct ether_hdr *eth_hdr; - unsigned short eth_proto; struct ieee802_1x_hdr *aa1x_hdr; size_t size; int ret; @@ -369,7 +368,6 @@ void hostif_data_indication(struct ks_wlan_private *priv) get_word(priv); /* Reserve Area */ eth_hdr = (struct ether_hdr *)(priv->rxp); - eth_proto = ntohs(eth_hdr->h_proto); /* source address check */ if (ether_addr_equal(&priv->eth_addr[0], eth_hdr->h_source)) { From de6171cdb082ecf71e37ddd7782b33b2019b0df2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:16 +0100 Subject: [PATCH 316/903] staging:rtl8192u: Remove blank lines before '}' and after '{' characters Coding style change to simply remove the unrequired blanks lines before a closing brace or after an opening brace. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 553e4aff235c..b971c404f152 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -78,7 +78,6 @@ static void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) u8 *tag = *tag_p; if (ieee->modulation & IEEE80211_OFDM_MODULATION) { - *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -89,7 +88,6 @@ static void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; - } /* We may add an option for custom rates that specific HW might support */ @@ -301,7 +299,6 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) netif_trans_update(ieee->dev); ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); }else{ - header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -1473,7 +1470,6 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(target, &ieee->network_list, list) { - /* if the state become different that NOLINK means * we had found what we are searching for */ @@ -1573,7 +1569,6 @@ static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - sizeof(struct ieee80211_info_element))) { - IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); return -1; } @@ -1640,7 +1635,6 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) ieee80211_resp_to_auth(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); - } static inline void @@ -1665,7 +1659,6 @@ static void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } /* EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); */ @@ -1728,7 +1721,6 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) if ((ieee->ps == IEEE80211_PS_DISABLED || ieee->iw_mode != IW_MODE_INFRA || ieee->state != IEEE80211_LINKED)){ - // #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); @@ -2000,7 +1992,6 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA) { - IEEE80211_DEBUG_MGMT("Received auth response"); ieee80211_check_auth_response(ieee, skb); } else if (ieee->iw_mode == IW_MODE_MASTER) { @@ -2026,7 +2017,6 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA){ - ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; @@ -2117,7 +2107,6 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * //exit: spin_unlock_irqrestore(&ieee->lock, flags); - } EXPORT_SYMBOL(ieee80211_softmac_xmit); @@ -2126,12 +2115,10 @@ static void ieee80211_resume_tx(struct ieee80211_device *ieee) { int i; for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - if (ieee->queue_stop){ ieee->tx_pending.frag = i; return; }else{ - ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev, ieee->rate); @@ -2173,7 +2160,6 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - header = (struct rtl_80211_hdr_3addr *)skb->data; header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -2243,7 +2229,6 @@ void ieee80211_start_master_bss(struct ieee80211_device *ieee) static void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) { if (ieee->raw_tx) { - if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -2303,7 +2288,6 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) eth_random_addr(ieee->current_network.bssid); if (ieee->modulation & IEEE80211_CCK_MODULATION){ - ieee->current_network.rates_len = 4; ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; @@ -2338,7 +2322,6 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->current_network.capability = WLAN_CAPABILITY_IBSS; if (ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - } ieee->state = IEEE80211_LINKED; @@ -3054,7 +3037,6 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_poin } switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, param->u.wpa_param.value); From eb2cbcc37763b6b401a3c9252c174e235c7396c3 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:17 +0100 Subject: [PATCH 317/903] staging:rtl8192u: Correct indentation and spacing for braces of code blocks Simple style change to fix the indentaiton and spacing of the braces around multiline code blocks. Braces removed from code block with a single line. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 254 ++++++++---------- 1 file changed, 107 insertions(+), 147 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index b971c404f152..16500a7e7b4e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -107,11 +107,10 @@ static void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) *tag++ = 0x00; *tag++ = 0x01; #ifdef SUPPORT_USPD - if (ieee->current_network.wmm_info & 0x80) { + if (ieee->current_network.wmm_info & 0x80) *tag++ = 0x0f | MAX_SP_Len; - } else { + else *tag++ = MAX_SP_Len; - } #else *tag++ = MAX_SP_Len; #endif @@ -200,8 +199,7 @@ static u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee) /* // Data rate of ProbeReq is already decided. Annie, 2005-03-31 - if( pMgntInfo->bScanInProgress || (pMgntInfo->bDualModeScanStep!=0) ) - { + if( pMgntInfo->bScanInProgress || (pMgntInfo->bDualModeScanStep!=0) ) { if(pMgntInfo->dot11CurrentWirelessMode==WIRELESS_MODE_A) rate = 0x0c; else @@ -233,10 +231,10 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee tcb_desc->bTxDisableRateFallBack = 1; tcb_desc->bTxUseDriverAssingedRate = 1; - if (single){ - if (ieee->queue_stop){ + if (single) { + if (ieee->queue_stop) { enqueue_mgmt(ieee, skb); - }else{ + } else { header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -251,7 +249,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee } spin_unlock_irqrestore(&ieee->lock, flags); - }else{ + } else { spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); @@ -287,7 +285,7 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *)skb->data; - if (single){ + if (single) { header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -298,7 +296,7 @@ softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) /* avoid watchdog triggers */ netif_trans_update(ieee->dev); ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); - }else{ + } else { header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -420,13 +418,12 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER + 1); mutex_lock(&ieee->scan_mutex); - while (1) - { - do{ + while (1) { + do { ch++; if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - }while (!channel_map[ch]); + } while (!channel_map[ch]); /* this function can be called in two situations * 1- We have switched to ad-hoc mode and we are @@ -462,16 +459,15 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) msleep_interruptible(IEEE80211_SOFTMAC_SCAN_TIME); } out: - if (ieee->state < IEEE80211_LINKED){ + if (ieee->state < IEEE80211_LINKED) { ieee->actscanning = false; mutex_unlock(&ieee->scan_mutex); + } else { + ieee->sync_scan_hurryup = 0; + if (IS_DOT11D_ENABLE(ieee)) + DOT11D_ScanComplete(ieee); + mutex_unlock(&ieee->scan_mutex); } - else{ - ieee->sync_scan_hurryup = 0; - if (IS_DOT11D_ENABLE(ieee)) - DOT11D_ScanComplete(ieee); - mutex_unlock(&ieee->scan_mutex); -} } EXPORT_SYMBOL(ieee80211_softmac_scan_syncro); @@ -486,18 +482,17 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) if (!ieee->ieee_up) return; mutex_lock(&ieee->scan_mutex); - do{ + do { ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (watchdog++ > MAX_CHANNEL_NUMBER) - { + if (watchdog++ > MAX_CHANNEL_NUMBER) { //if current channel is not in channel map, set to default channel. if (!channel_map[ieee->current_network.channel]) { ieee->current_network.channel = 6; goto out; /* no good chans */ } } - }while (!channel_map[ieee->current_network.channel]); + } while (!channel_map[ieee->current_network.channel]); if (ieee->scanning == 0 ) goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); @@ -589,31 +584,26 @@ EXPORT_SYMBOL(ieee80211_stop_scan); /* called with ieee->lock held */ static void ieee80211_start_scan(struct ieee80211_device *ieee) { - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee) ) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { if (ieee->scanning == 0) { ieee->scanning = 1; schedule_delayed_work(&ieee->softmac_scan_wq, 0); } - }else + } else { ieee->start_scan(ieee->dev); + } } /* called with wx_mutex held */ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) { - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee) ) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } ieee->sync_scan_hurryup = 0; if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) @@ -714,8 +704,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len, encrypt); HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len, encrypt); - if (pHTInfo->bRegRT2RTAggregation) - { + if (pHTInfo->bRegRT2RTAggregation) { tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); @@ -798,10 +787,9 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d tag += rate_ex_len - 2; } - if (wpa_ie_len) - { - if (ieee->iw_mode == IW_MODE_ADHOC) - {//as Windows will set pairwise key same as the group key which is not allowed in Linux, so set this for IOT issue. WB 2008.07.07 + if (wpa_ie_len) { + if (ieee->iw_mode == IW_MODE_ADHOC) { + //as Windows will set pairwise key same as the group key which is not allowed in Linux, so set this for IOT issue. WB 2008.07.07 memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); } memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); @@ -979,30 +967,25 @@ ieee80211_association_req(struct ieee80211_network *beacon, encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); /* Include High Throuput capability && Realtek proprietary */ - if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt); - if (ieee->pHTInfo->bCurrentRT2RTAggregation) - { + if (ieee->pHTInfo->bCurrentRT2RTAggregation) { realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); } } - if (ieee->qos_support) { + if (ieee->qos_support) wmm_info_len = beacon->qos_data.supported ? 9 : 0; - } if (beacon->bCkipSupported) - { ckip_ie_len = 30 + 2; - } + if (beacon->bCcxRmEnable) - { ccxrm_ie_len = 6 + 2; - } + if (beacon->BssCcxVerNumber >= 2) cxvernum_ie_len = 5 + 2; @@ -1098,8 +1081,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, tag += osCcxAironetIE.Length; } - if (beacon->bCcxRmEnable) - { + if (beacon->bCcxRmEnable) { static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; OCTET_STRING osCcxRmCap; @@ -1126,8 +1108,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, } //HT cap element if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { - if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_HT_CAP; *tag++ = ht_cap_len - 2; @@ -1137,9 +1118,8 @@ ieee80211_association_req(struct ieee80211_network *beacon, } //choose what wpa_supplicant gives to associate. - if (wpa_ie_len) { + if (wpa_ie_len) skb_put_data(skb, ieee->wpa_ie, wpa_ie_len); - } if (wmm_info_len) { tag = skb_put(skb, wmm_info_len); @@ -1153,8 +1133,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, #endif if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { - if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = ht_cap_len - 2; @@ -1187,10 +1166,10 @@ void ieee80211_associate_abort(struct ieee80211_device *ieee) * Here we will check if there are good nets to associate * with, so we retry or just get back to NO_LINK and scanning */ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING) { IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; - }else{ + } else { IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } @@ -1220,9 +1199,9 @@ static void ieee80211_associate_step1(struct ieee80211_device *ieee) ieee->softmac_stats.tx_auth_rq++; skb = ieee80211_authentication_req(beacon, ieee, 0); - if (!skb) + if (!skb) { ieee80211_associate_abort(ieee); - else{ + } else { ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); @@ -1248,9 +1227,9 @@ static void ieee80211_auth_challenge(struct ieee80211_device *ieee, ieee->softmac_stats.tx_auth_rq++; skb = ieee80211_authentication_req(beacon, ieee, chlen + 2); - if (!skb) + if (!skb) { ieee80211_associate_abort(ieee); - else{ + } else { c = skb_put(skb, chlen + 2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; @@ -1278,9 +1257,9 @@ static void ieee80211_associate_step2(struct ieee80211_device *ieee) ieee->softmac_stats.tx_ass_rq++; skb = ieee80211_association_req(beacon, ieee); - if (!skb) + if (!skb) { ieee80211_associate_abort(ieee); - else{ + } else { softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ / 2)); //dev_kfree_skb_any(skb);//edit by thomas @@ -1291,28 +1270,24 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); printk(KERN_INFO "Associated successfully\n"); if (ieee80211_is_54g(&ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ + (ieee->modulation & IEEE80211_OFDM_MODULATION)) { ieee->rate = 108; printk(KERN_INFO"Using G rates:%d\n", ieee->rate); - }else{ + } else { ieee->rate = 22; printk(KERN_INFO"Using B rates:%d\n", ieee->rate); } - if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { printk("Successfully associated, ht enabled\n"); HTOnAssocRsp(ieee); - } - else - { + } else { printk("Successfully associated, ht not enabled(%d, %d)\n", ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT); memset(ieee->dot11HTOperationalRateSet, 0, 16); //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); } ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval / 500); // To prevent the immediately calling watch_dog after association. - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) - { + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } @@ -1403,7 +1378,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee * and the network does broadcast and that those two bssid matches */ (!apset && ssidset && ssidbroad && ssidmatch) - ){ + ) { /* if the essid is hidden replace it with the * essid provided by the user. */ @@ -1424,32 +1399,29 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee //ieee->pHTInfo->IOTAction = 0; HTResetIOTSetting(ieee->pHTInfo); - if (ieee->iw_mode == IW_MODE_INFRA){ + if (ieee->iw_mode == IW_MODE_INFRA) { /* Join the network for the first time */ ieee->AsocRetryCount = 0; //for HT by amy 080514 if ((ieee->current_network.qos_data.supported == 1) && - // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT)) - ieee->current_network.bssht.bdSupportHT) + // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT)) + ieee->current_network.bssht.bdSupportHT) { /*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/ - { // ieee->pHTInfo->bCurrentHTSupport = true; HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); - } - else - { + } else { ieee->pHTInfo->bCurrentHTSupport = false; } ieee->state = IEEE80211_ASSOCIATING; schedule_work(&ieee->associate_procedure_wq); - }else{ + } else { if (ieee80211_is_54g(&ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ + (ieee->modulation & IEEE80211_OFDM_MODULATION)) { ieee->rate = 108; ieee->SetWirelessMode(ieee->dev, IEEE_G); printk(KERN_INFO"Using G rates\n"); - }else{ + } else { ieee->rate = 22; ieee->SetWirelessMode(ieee->dev, IEEE_B); printk(KERN_INFO"Using B rates\n"); @@ -1545,7 +1517,7 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, tag = skb->data + sizeof (struct rtl_80211_hdr_3addr ); - while (tag + 1 < skbend){ + while (tag + 1 < skbend) { if (*tag == 0) { ssid = tag + 2; ssidlen = *(tag + 1); @@ -1600,7 +1572,7 @@ static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb (ieee->current_network.mode == IEEE_N_24G) && (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT - 1)))) { ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; - }else { + } else { ieee->AsocRetryCount = 0; } @@ -1631,9 +1603,8 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) ieee->softmac_stats.rx_auth_rq++; status = auth_rq_parse(skb, dest); - if (status != -1) { + if (status != -1) ieee80211_resp_to_auth(ieee, status, dest); - } //DMESG("Dest is "MACSTR, MAC2STR(dest)); } @@ -1644,9 +1615,8 @@ ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) //unsigned long flags; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb, dest) != -1) { + if (assoc_rq_parse(skb, dest) != -1) ieee80211_resp_to_assoc_rq(ieee, dest); - } printk(KERN_INFO"New client associated: %pM\n", dest); //FIXME @@ -1720,7 +1690,7 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) if ((ieee->ps == IEEE80211_PS_DISABLED || ieee->iw_mode != IW_MODE_INFRA || - ieee->state != IEEE80211_LINKED)){ + ieee->state != IEEE80211_LINKED)) { // #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); @@ -1734,15 +1704,14 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) if (sleep == 0) goto out; - if (sleep == 1){ - if (ieee->sta_sleep == 1) + if (sleep == 1) { + if (ieee->sta_sleep == 1) { ieee->enter_sleep_state(ieee->dev, th, tl); - - else if (ieee->sta_sleep == 0){ + } else if (ieee->sta_sleep == 0) { // printk("send null 1\n"); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->ps_is_queue_empty(ieee->dev)){ + if (ieee->ps_is_queue_empty(ieee->dev)) { ieee->sta_sleep = 2; ieee->ps_request_tx_ack(ieee->dev); @@ -1754,7 +1723,7 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - }else if (sleep == 2){ + } else if (sleep == 2) { //#warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); @@ -1794,7 +1763,7 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) spin_lock_irqsave(&ieee->lock, flags); - if (ieee->sta_sleep == 2){ + if (ieee->sta_sleep == 2) { /* Null frame with PS bit set */ if (success) { ieee->sta_sleep = 1; @@ -1803,9 +1772,8 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) /* if the card report not success we can't be sure the AP * has not RXed so we can't assume the AP believe us awake */ - } - /* 21112005 - tx again null without PS bit if lost */ - else { + } else { + /* 21112005 - tx again null without PS bit if lost */ if ((ieee->sta_sleep == 0) && !success) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); ieee80211_sta_ps_send_null_frame(ieee, 0); @@ -1823,8 +1791,7 @@ static void ieee80211_process_action(struct ieee80211_device *ieee, u8 *act = ieee80211_get_payload(header); u8 tmp = 0; // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - if (act == NULL) - { + if (act == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "error to get payload of action frame\n"); return; } @@ -1890,9 +1857,9 @@ static void ieee80211_check_auth_response(struct ieee80211_device *ieee, bHalfSupportNmode) { netdev_dbg(ieee->dev, "enter half N mode\n"); ieee->bHalfWirelessN24GMode = true; - } else + } else { ieee->bHalfWirelessN24GMode = false; - + } ieee80211_associate_step2(ieee); } else { ieee80211_auth_challenge(ieee, challenge, chlen); @@ -1933,8 +1900,8 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && - ieee->iw_mode == IW_MODE_INFRA){ + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->iw_mode == IW_MODE_INFRA) { struct ieee80211_network network_resp; struct ieee80211_network *network = &network_resp; @@ -1950,11 +1917,10 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, memset(network, 0, sizeof(*network)); if (ieee80211_parse_info_param(ieee, assoc_resp->info_element,\ rx_stats->len - sizeof(*assoc_resp),\ - network, rx_stats)){ + network, rx_stats)) { return 1; - } - else - { //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network. + } else { + //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network. memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); } @@ -1971,11 +1937,10 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { + if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) schedule_work(&ieee->associate_procedure_wq); - } else { + else ieee80211_associate_abort(ieee); - } } } break; @@ -2004,7 +1969,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && - ieee->state == IEEE80211_LINKED)){ + ieee->state == IEEE80211_LINKED)) { ieee80211_rx_probe_rq(ieee, skb); } break; @@ -2016,7 +1981,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == IEEE80211_LINKED && - ieee->iw_mode == IW_MODE_INFRA){ + ieee->iw_mode == IW_MODE_INFRA) { ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; @@ -2071,9 +2036,9 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * ieee->stats.tx_bytes += le16_to_cpu(txb->payload_size); ieee->stats.tx_packets++; tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); - if (tcb_desc->bMulticast) { + if (tcb_desc->bMulticast) ieee->stats.multicast++; - } + /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ for (i = 0; i < txb->nr_frags; i++) { #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE @@ -2094,7 +2059,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * #else skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); #endif - }else{ + } else { ieee->softmac_data_hard_start_xmit( txb->fragments[i], ieee->dev, ieee->rate); @@ -2115,10 +2080,10 @@ static void ieee80211_resume_tx(struct ieee80211_device *ieee) { int i; for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - if (ieee->queue_stop){ + if (ieee->queue_stop) { ieee->tx_pending.frag = i; return; - }else{ + } else { ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], ieee->dev, ieee->rate); @@ -2159,7 +2124,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) ieee->queue_stop = 0; if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))) { header = (struct rtl_80211_hdr_3addr *)skb->data; header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -2287,17 +2252,17 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) if (!ieee->wap_set) eth_random_addr(ieee->current_network.bssid); - if (ieee->modulation & IEEE80211_CCK_MODULATION){ + if (ieee->modulation & IEEE80211_CCK_MODULATION) { ieee->current_network.rates_len = 4; ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - }else + } else { ieee->current_network.rates_len = 0; - - if (ieee->modulation & IEEE80211_OFDM_MODULATION){ + } + if (ieee->modulation & IEEE80211_OFDM_MODULATION) { ieee->current_network.rates_ex_len = 8; ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -2310,7 +2275,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; ieee->rate = 108; - }else{ + } else { ieee->current_network.rates_ex_len = 0; ieee->rate = 22; } @@ -2353,12 +2318,9 @@ void ieee80211_start_bss(struct ieee80211_device *ieee) // Ref: 802.11d 11.1.3.3 // STA shall not start a BSS unless properly formed Beacon frame including a Country IE. // - if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) - { + if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) { if (! ieee->bGlobalDomain) - { return; - } } /* check if we have already found the net we * are interested in (if any). @@ -2528,11 +2490,11 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) ieee->proto_started = 1; if (ieee->current_network.channel == 0) { - do{ + do { ch++; if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - }while (!GET_DOT11D_INFO(ieee)->channel_map[ch]); + } while (!GET_DOT11D_INFO(ieee)->channel_map[ch]); ieee->current_network.channel = ch; } @@ -2575,9 +2537,9 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; - for (i = 0; i < 5; i++) { - ieee->seq_ctrl[i] = 0; - } + for (i = 0; i < 5; i++) + ieee->seq_ctrl[i] = 0; + ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_KERNEL); if (!ieee->pDot11dInfo) IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n"); @@ -2732,12 +2694,11 @@ static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) sec.auth_mode = WLAN_AUTH_SHARED_KEY; ieee->open_wep = 0; ieee->auth_mode = 1; - } else if (value & AUTH_ALG_OPEN_SYSTEM){ + } else if (value & AUTH_ALG_OPEN_SYSTEM) { sec.auth_mode = WLAN_AUTH_OPEN; ieee->open_wep = 1; ieee->auth_mode = 0; - } - else if (value & IW_AUTH_ALG_LEAP){ + } else if (value & IW_AUTH_ALG_LEAP) { sec.auth_mode = WLAN_AUTH_LEAP; ieee->open_wep = 1; ieee->auth_mode = 2; @@ -2788,8 +2749,7 @@ static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 v if (!value) { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_0; - } - else { + } else { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; } @@ -2935,9 +2895,9 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, ieee->tx_keyidx = param->u.crypt.idx; sec.active_key = param->u.crypt.idx; sec.flags |= SEC_ACTIVE_KEY; - } else + } else { sec.flags &= ~SEC_ACTIVE_KEY; - + } memcpy(sec.keys[param->u.crypt.idx], param->u.crypt.key, param->u.crypt.key_len); From 591968b2f404913eb14417a142b3a261562048cd Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:18 +0100 Subject: [PATCH 318/903] staging:rtl8192u: Correct spacing before and after parenthesis - Style Corrected coding style issues aroung opening and closed parenthesis. Spaces, or blank line, removed from after '(' or before ')' Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 78 +++++++++---------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 16500a7e7b4e..7bec24d0a234 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -263,7 +263,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee /* check whether the managed packet queued greater than 5 */ if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||\ (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) || \ - (ieee->queue_stop) ) { + (ieee->queue_stop)) { /* insert the skb packet to the management queue */ /* as for the completion function, it does not need * to check it any more. @@ -493,7 +493,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) } } } while (!channel_map[ieee->current_network.channel]); - if (ieee->scanning == 0 ) + if (ieee->scanning == 0) goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); if (channel_map[ieee->current_network.channel] == 1) @@ -584,7 +584,7 @@ EXPORT_SYMBOL(ieee80211_stop_scan); /* called with ieee->lock held */ static void ieee80211_start_scan(struct ieee80211_device *ieee) { - if (IS_DOT11D_ENABLE(ieee) ) { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) RESET_CIE_WATCHDOG(ieee); } @@ -601,7 +601,7 @@ static void ieee80211_start_scan(struct ieee80211_device *ieee) /* called with wx_mutex held */ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) { - if (IS_DOT11D_ENABLE(ieee) ) { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) RESET_CIE_WATCHDOG(ieee); } @@ -728,9 +728,9 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d return NULL; skb_reserve(skb, ieee->tx_headroom); beacon_buf = skb_put(skb, (beacon_size - ieee->tx_headroom)); - memcpy (beacon_buf->header.addr1, dest, ETH_ALEN); - memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(beacon_buf->header.addr1, dest, ETH_ALEN); + memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; /* FIXME */ beacon_buf->beacon_interval = @@ -973,7 +973,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt); if (ieee->pHTInfo->bCurrentRT2RTAggregation) { realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); + realtek_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); } } @@ -1033,7 +1033,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN);//for HW security, John hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) @@ -1237,7 +1237,7 @@ static void ieee80211_auth_challenge(struct ieee80211_device *ieee, IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct rtl_80211_hdr_3addr )); + ieee80211_encrypt_fragment(ieee, skb, sizeof(struct rtl_80211_hdr_3addr)); softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ / 2)); @@ -1287,7 +1287,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) } ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval / 500); // To prevent the immediately calling watch_dog after association. - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } @@ -1367,13 +1367,13 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee ssidmatch = (ieee->current_network.ssid_len == net->ssid_len) && (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - if ( /* if the user set the AP check if match. - * if the network does not broadcast essid we check the user supplyed ANY essid - * if the network does broadcast and the user does not set essid it is OK - * if the network does broadcast and the user did set essid chech if essid match - */ - (apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || + /* if the user set the AP check if match. + * if the network does not broadcast essid we check the user supplyed ANY essid + * if the network does broadcast and the user does not set essid it is OK + * if the network does broadcast and the user did set essid chech if essid match + */ + if ((apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || /* if the ap is not set, check that the user set the bssid * and the network does broadcast and that those two bssid matches */ @@ -1508,14 +1508,14 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *)skb->data; - if (skb->len < sizeof (struct rtl_80211_hdr_3addr )) + if (skb->len < sizeof(struct rtl_80211_hdr_3addr)) return -1; /* corrupted */ memcpy(src, header->addr2, ETH_ALEN); skbend = (u8 *)skb->data + skb->len; - tag = skb->data + sizeof (struct rtl_80211_hdr_3addr ); + tag = skb->data + sizeof(struct rtl_80211_hdr_3addr); while (tag + 1 < skbend) { if (*tag == 0) { @@ -1660,7 +1660,7 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, ieee->last_rx_ps_time + msecs_to_jiffies(timeout))) return 0; - if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && + if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; @@ -1931,12 +1931,10 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, } else { /* aid could not been allocated */ ieee->softmac_stats.rx_ass_err++; - printk( - "Association response status code 0x%x\n", - errcode); - IEEE80211_DEBUG_MGMT( - "Association response status code 0x%x\n", - errcode); + printk("Association response status code 0x%x\n", + errcode); + IEEE80211_DEBUG_MGMT("Association response status code 0x%x\n", + errcode); if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) schedule_work(&ieee->associate_procedure_wq); else @@ -2060,9 +2058,8 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); #endif } else { - ieee->softmac_data_hard_start_xmit( - txb->fragments[i], - ieee->dev, ieee->rate); + ieee->softmac_data_hard_start_xmit(txb->fragments[i], + ieee->dev, ieee->rate); //ieee->stats.tx_packets++; //ieee->stats.tx_bytes += txb->fragments[i]->len; //ieee->dev->trans_start = jiffies; @@ -2084,10 +2081,9 @@ static void ieee80211_resume_tx(struct ieee80211_device *ieee) ieee->tx_pending.frag = i; return; } else { - ieee->softmac_data_hard_start_xmit( - ieee->tx_pending.txb->fragments[i], - ieee->dev, ieee->rate); - //(i+1)tx_pending.txb->nr_frags); + ieee->softmac_data_hard_start_xmit(ieee->tx_pending.txb->fragments[i], + ieee->dev, ieee->rate); + //(i+1)tx_pending.txb->nr_frags); ieee->stats.tx_packets++; netif_trans_update(ieee->dev); } @@ -2935,10 +2931,9 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, return ret; } -static inline struct sk_buff *ieee80211_disassociate_skb( - struct ieee80211_network *beacon, - struct ieee80211_device *ieee, - u8 asRsn) +static inline struct sk_buff *ieee80211_disassociate_skb(struct ieee80211_network *beacon, + struct ieee80211_device *ieee, + u8 asRsn) { struct sk_buff *skb; struct ieee80211_disassoc *disass; @@ -2960,10 +2955,9 @@ static inline struct sk_buff *ieee80211_disassociate_skb( } void -SendDisassociation( - struct ieee80211_device *ieee, - u8 *asSta, - u8 asRsn +SendDisassociation(struct ieee80211_device *ieee, + u8 *asSta, + u8 asRsn ) { struct ieee80211_network *beacon = &ieee->current_network; From 3e824ba0c1e679cb80e1caf0bbe270e45bc3af12 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:19 +0100 Subject: [PATCH 319/903] staging:rtl8192u: Remove prohibited spaces - Coding Style Simple removal of spaces prohibited by the coding standard. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 7bec24d0a234..64d7980e7e13 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1073,7 +1073,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, // CCX1 spec V1.13, A01.1 CKIP Negotiation (page23): // "The CKIP negotiation is started with the associate request from the client to the access point, // containing an Aironet element with both the MIC and KP bits set." - osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK | SUPPORT_CKIP_MIC) ; + osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK | SUPPORT_CKIP_MIC); tag = skb_put(skb, ckip_ie_len); *tag++ = MFIE_TYPE_AIRONET; *tag++ = osCcxAironetIE.Length; @@ -1202,7 +1202,7 @@ static void ieee80211_associate_step1(struct ieee80211_device *ieee) if (!skb) { ieee80211_associate_abort(ieee); } else { - ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; + ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); //BUGON when you try to add_timer twice, using mod_timer may be better, john0709 @@ -1796,7 +1796,7 @@ static void ieee80211_process_action(struct ieee80211_device *ieee, return; } tmp = *act; - act ++; + act++; switch (tmp) { case ACT_CAT_BA: if (*act == ACT_ADDBAREQ) @@ -2115,7 +2115,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) struct rtl_80211_hdr_3addr *header; spin_lock_irqsave(&ieee->lock, flags); - if (! ieee->queue_stop) goto exit; + if (!ieee->queue_stop) goto exit; ieee->queue_stop = 0; @@ -2141,7 +2141,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } -exit : +exit: spin_unlock_irqrestore(&ieee->lock, flags); } EXPORT_SYMBOL(ieee80211_wake_queue); @@ -2315,7 +2315,7 @@ void ieee80211_start_bss(struct ieee80211_device *ieee) // STA shall not start a BSS unless properly formed Beacon frame including a Country IE. // if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) { - if (! ieee->bGlobalDomain) + if (!ieee->bGlobalDomain) return; } /* check if we have already found the net we From 546f080527af7724faa2e60178b3781fe5b277ec Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:20 +0100 Subject: [PATCH 320/903] staging:rtl8192u: Move trailing conditional statement to the following line Coding standard requires that the conditional statement is not on the same line as the 'if' or 'else' but on the following line. Statements moved accordingly. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 64d7980e7e13..d916cc5b97db 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -622,7 +622,8 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, int len = sizeof(struct ieee80211_authentication) + challengelen + ieee->tx_headroom; skb = dev_alloc_skb(len); - if (!skb) return NULL; + if (!skb) + return NULL; skb_reserve(skb, ieee->tx_headroom); auth = skb_put(skb, sizeof(struct ieee80211_authentication)); @@ -680,7 +681,8 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d u8 *tmp_generic_ie_buf = NULL; u8 tmp_generic_ie_len = 0; - if (rate_ex_len > 0) rate_ex_len += 2; + if (rate_ex_len > 0) + rate_ex_len += 2; if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; @@ -834,7 +836,8 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; - else crypt = NULL; + else + crypt = NULL; encrypt = crypt && crypt->ops; @@ -843,8 +846,10 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); - if (ieee->assoc_id == 0x2007) ieee->assoc_id = 0; - else ieee->assoc_id++; + if (ieee->assoc_id == 0x2007) + ieee->assoc_id = 0; + else + ieee->assoc_id++; tag = skb_put(skb, rate_len); @@ -1529,9 +1534,12 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, } //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); - if (ssidlen == 0) return 1; + if (ssidlen == 0) + return 1; + + if (!ssid) + return 1; /* ssid not found in tagged param */ - if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); } @@ -2115,7 +2123,8 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) struct rtl_80211_hdr_3addr *header; spin_lock_irqsave(&ieee->lock, flags); - if (!ieee->queue_stop) goto exit; + if (!ieee->queue_stop) + goto exit; ieee->queue_stop = 0; From e4c8f0638ae9ea921f1edba788f120948c2999e2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:21 +0100 Subject: [PATCH 321/903] staging:rtl8192u: Remove unnecessary parentheses - Coding Style checkpatch.pl flags unnecessary parentheses, so removed from code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index d916cc5b97db..023f23d2eb67 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -699,9 +699,9 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); /* HT ralated element */ - tmp_ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); + tmp_ht_cap_buf = (u8 *)&ieee->pHTInfo->SelfHTCap; tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - tmp_ht_info_buf = (u8 *)&(ieee->pHTInfo->SelfHTInfo); + tmp_ht_info_buf = (u8 *)&ieee->pHTInfo->SelfHTInfo; tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len, encrypt); HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len, encrypt); @@ -973,7 +973,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, /* Include High Throuput capability && Realtek proprietary */ if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { - ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); + ht_cap_buf = (u8 *)&ieee->pHTInfo->SelfHTCap; ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt); if (ieee->pHTInfo->bCurrentRT2RTAggregation) { @@ -1413,7 +1413,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee ieee->current_network.bssht.bdSupportHT) { /*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/ // ieee->pHTInfo->bCurrentHTSupport = true; - HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); + HTResetSelfAndSavePeerSetting(ieee, &ieee->current_network); } else { ieee->pHTInfo->bCurrentHTSupport = false; } From deb379066d376deec5a76ba9af705598f61ba67b Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:22 +0100 Subject: [PATCH 322/903] staging:rtl8192u: Correct indentation of ieee80211_softmac_new_net() Coding style change to correct the indentation of the function ieee80211_softmac_new_net(). A large proportion of the function's if statements were incorrectly indented. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 99 +++++++++---------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 023f23d2eb67..6507b6101342 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1378,63 +1378,62 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee * if the network does broadcast and the user did set essid chech if essid match */ if ((apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || - /* if the ap is not set, check that the user set the bssid - * and the network does broadcast and that those two bssid matches + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || + /* if the ap is not set, check that the user set the bssid + * and the network does broadcast and that those two bssid matches + */ + (!apset && ssidset && ssidbroad && ssidmatch)) { + /* if the essid is hidden replace it with the + * essid provided by the user. */ - (!apset && ssidset && ssidbroad && ssidmatch) - ) { - /* if the essid is hidden replace it with the - * essid provided by the user. - */ - if (!ssidbroad) { - strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); - tmp_ssid_len = ieee->current_network.ssid_len; - } - memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); + if (!ssidbroad) { + strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); + tmp_ssid_len = ieee->current_network.ssid_len; + } + memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = tmp_ssid_len; - printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d\n", - ieee->current_network.ssid, - ieee->current_network.channel, - ieee->current_network.qos_data.supported, - ieee->pHTInfo->bEnableHT, - ieee->current_network.bssht.bdSupportHT); + strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); + ieee->current_network.ssid_len = tmp_ssid_len; + printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d\n", + ieee->current_network.ssid, + ieee->current_network.channel, + ieee->current_network.qos_data.supported, + ieee->pHTInfo->bEnableHT, + ieee->current_network.bssht.bdSupportHT); - //ieee->pHTInfo->IOTAction = 0; - HTResetIOTSetting(ieee->pHTInfo); - if (ieee->iw_mode == IW_MODE_INFRA) { - /* Join the network for the first time */ - ieee->AsocRetryCount = 0; - //for HT by amy 080514 - if ((ieee->current_network.qos_data.supported == 1) && - // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT)) - ieee->current_network.bssht.bdSupportHT) { + //ieee->pHTInfo->IOTAction = 0; + HTResetIOTSetting(ieee->pHTInfo); + if (ieee->iw_mode == IW_MODE_INFRA) { + /* Join the network for the first time */ + ieee->AsocRetryCount = 0; + //for HT by amy 080514 + if ((ieee->current_network.qos_data.supported == 1) && + // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT)) + ieee->current_network.bssht.bdSupportHT) { /*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/ // ieee->pHTInfo->bCurrentHTSupport = true; - HTResetSelfAndSavePeerSetting(ieee, &ieee->current_network); - } else { - ieee->pHTInfo->bCurrentHTSupport = false; - } - - ieee->state = IEEE80211_ASSOCIATING; - schedule_work(&ieee->associate_procedure_wq); + HTResetSelfAndSavePeerSetting(ieee, &ieee->current_network); } else { - if (ieee80211_is_54g(&ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)) { - ieee->rate = 108; - ieee->SetWirelessMode(ieee->dev, IEEE_G); - printk(KERN_INFO"Using G rates\n"); - } else { - ieee->rate = 22; - ieee->SetWirelessMode(ieee->dev, IEEE_B); - printk(KERN_INFO"Using B rates\n"); - } - memset(ieee->dot11HTOperationalRateSet, 0, 16); - //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - ieee->state = IEEE80211_LINKED; + ieee->pHTInfo->bCurrentHTSupport = false; } + + ieee->state = IEEE80211_ASSOCIATING; + schedule_work(&ieee->associate_procedure_wq); + } else { + if (ieee80211_is_54g(&ieee->current_network) && + (ieee->modulation & IEEE80211_OFDM_MODULATION)) { + ieee->rate = 108; + ieee->SetWirelessMode(ieee->dev, IEEE_G); + printk(KERN_INFO"Using G rates\n"); + } else { + ieee->rate = 22; + ieee->SetWirelessMode(ieee->dev, IEEE_B); + printk(KERN_INFO"Using B rates\n"); + } + memset(ieee->dot11HTOperationalRateSet, 0, 16); + //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); + ieee->state = IEEE80211_LINKED; + } } } } From 74463b19f4d5190b3cbbe6137fbc1fd2c2505733 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 10 Jul 2018 16:05:23 +0100 Subject: [PATCH 323/903] staging:rtl8192u: Correction of indentation issues - Coding Style Simple changes to correct indentation issues. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 76 +++++++++---------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 6507b6101342..fe61451f6c14 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -46,7 +46,6 @@ static unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) rate_len = IEEE80211_CCK_RATE_LEN + 2; if (ieee->modulation & IEEE80211_OFDM_MODULATION) - rate_len += IEEE80211_OFDM_RATE_LEN + 2; return rate_len; @@ -77,7 +76,7 @@ static void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & IEEE80211_OFDM_MODULATION) { + if (ieee->modulation & IEEE80211_OFDM_MODULATION) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -261,7 +260,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee ieee->seq_ctrl[0]++; /* check whether the managed packet queued greater than 5 */ - if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||\ + if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) || \ (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) || \ (ieee->queue_stop)) { /* insert the skb packet to the management queue */ @@ -630,7 +629,7 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, if (challengelen) auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH - | IEEE80211_FCTL_WEP); + | IEEE80211_FCTL_WEP); else auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); @@ -904,8 +903,8 @@ static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN); hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | - (pwr ? IEEE80211_FCTL_PM : 0)); + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS | + (pwr ? IEEE80211_FCTL_PM : 0)); return skb; } @@ -1182,7 +1181,7 @@ void ieee80211_associate_abort(struct ieee80211_device *ieee) ieee->state = IEEE80211_ASSOCIATING_RETRY; schedule_delayed_work(&ieee->associate_retry_wq, \ - IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); + IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); spin_unlock_irqrestore(&ieee->lock, flags); } @@ -1674,7 +1673,7 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, if (time_l) { *time_l = ieee->current_network.last_dtim_sta_time[0] + (ieee->current_network.beacon_interval - * ieee->current_network.dtim_period) * 1000; + * ieee->current_network.dtim_period) * 1000; } if (time_h) { @@ -1696,9 +1695,9 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) spin_lock_irqsave(&ieee->lock, flags); if ((ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != IEEE80211_LINKED)) { - // #warning CHECK_LOCK_HERE + ieee->iw_mode != IW_MODE_INFRA || + ieee->state != IEEE80211_LINKED)) { + // #warning CHECK_LOCK_HERE spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); ieee80211_sta_wakeup(ieee, 1); @@ -1880,8 +1879,8 @@ static void ieee80211_check_auth_response(struct ieee80211_device *ieee, inline int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats, u16 type, - u16 stype) + struct ieee80211_rx_stats *rx_stats, u16 type, + u16 stype) { struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *)skb->data; u16 errcode; @@ -1923,8 +1922,8 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, assoc_resp = (struct ieee80211_assoc_response_frame *)skb->data; memset(network, 0, sizeof(*network)); if (ieee80211_parse_info_param(ieee, assoc_resp->info_element,\ - rx_stats->len - sizeof(*assoc_resp),\ - network, rx_stats)) { + rx_stats->len - sizeof(*assoc_resp), \ + network, rx_stats)) { return 1; } else { //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network. @@ -1953,15 +1952,14 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->iw_mode == IW_MODE_MASTER) - + ieee->iw_mode == IW_MODE_MASTER) ieee80211_rx_assoc_rq(ieee, skb); break; case IEEE80211_STYPE_AUTH: if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING - && ieee->iw_mode == IW_MODE_INFRA) { + && ieee->iw_mode == IW_MODE_INFRA) { IEEE80211_DEBUG_MGMT("Received auth response"); ieee80211_check_auth_response(ieee, skb); } else if (ieee->iw_mode == IW_MODE_MASTER) { @@ -1972,9 +1970,9 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, case IEEE80211_STYPE_PROBE_REQ: if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || - ieee->iw_mode == IW_MODE_MASTER) && - ieee->state == IEEE80211_LINKED)) { + ((ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) && + ieee->state == IEEE80211_LINKED)) { ieee80211_rx_probe_rq(ieee, skb); } break; @@ -1985,8 +1983,8 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, * both for disassociation and deauthentication */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && - ieee->iw_mode == IW_MODE_INFRA) { + ieee->state == IEEE80211_LINKED && + ieee->iw_mode == IW_MODE_INFRA) { ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; @@ -2051,8 +2049,8 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * #else if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) || #endif - (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) || \ - (ieee->queue_stop)) { + (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) || \ + (ieee->queue_stop)) { /* insert the skb packet to the wait queue */ /* as for the completion function, it does not need * to check it any more. @@ -2354,10 +2352,10 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) { netif_carrier_off(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) - ieee80211_reset_queue(ieee); + ieee80211_reset_queue(ieee); if (ieee->data_hard_stop) - ieee->data_hard_stop(ieee->dev); + ieee->data_hard_stop(ieee->dev); if (IS_DOT11D_ENABLE(ieee)) Dot11d_Reset(ieee); ieee->state = IEEE80211_NOLINK; @@ -2508,9 +2506,9 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) // ieee->set_chan(ieee->dev,ieee->current_network.channel); for (i = 0; i < 17; i++) { - ieee->last_rxseq_num[i] = -1; - ieee->last_rxfrag_num[i] = -1; - ieee->last_packet_time[i] = 0; + ieee->last_rxseq_num[i] = -1; + ieee->last_rxfrag_num[i] = -1; + ieee->last_packet_time[i] = 0; } ieee->init_wmmparam_flag = 0;//reinitialize AC_xx_PARAM registers. @@ -2598,8 +2596,8 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) spin_lock_init(&ieee->beacon_lock); tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, - (unsigned long)ieee); + (void(*)(unsigned long)) ieee80211_sta_ps, + (unsigned long)ieee); } void ieee80211_softmac_free(struct ieee80211_device *ieee) @@ -2968,14 +2966,14 @@ SendDisassociation(struct ieee80211_device *ieee, u8 asRsn ) { - struct ieee80211_network *beacon = &ieee->current_network; - struct sk_buff *skb; + struct ieee80211_network *beacon = &ieee->current_network; + struct sk_buff *skb; - skb = ieee80211_disassociate_skb(beacon, ieee, asRsn); - if (skb) { - softmac_mgmt_xmit(skb, ieee); - //dev_kfree_skb_any(skb);//edit by thomas - } + skb = ieee80211_disassociate_skb(beacon, ieee, asRsn); + if (skb) { + softmac_mgmt_xmit(skb, ieee); + //dev_kfree_skb_any(skb);//edit by thomas + } } EXPORT_SYMBOL(SendDisassociation); From eff2eb5bd57f3ddda47bedd87662d8cd9bd8b2a0 Mon Sep 17 00:00:00 2001 From: Ivan Bornyakov Date: Wed, 11 Jul 2018 14:13:34 +0300 Subject: [PATCH 324/903] staging: gasket: fix plain integer as NULL pointer warning Trivial fix to remove sparse warnings: drivers/staging/gasket/gasket_page_table.c:884:40: warning: Using plain integer as NULL pointer drivers/staging/gasket/gasket_page_table.c:1743:57: warning: Using plain integer as NULL pointer drivers/staging/gasket/gasket_page_table.c:1768:57: warning: Using plain integer as NULL pointer Signed-off-by: Ivan Bornyakov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index c5390a860f86..5d3d33cac12f 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -881,7 +881,7 @@ static int gasket_perform_mapping( u64 off = (u64)host_addr - (u64)pg_tbl->coherent_pages[0].user_virt; - ptes[i].page = 0; + ptes[i].page = NULL; ptes[i].offset = offset; ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + off + i * PAGE_SIZE; @@ -1740,7 +1740,7 @@ int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size, gasket_dev->coherent_buffer.virt_base, gasket_dev->coherent_buffer.phys_base); gasket_dev->coherent_buffer.length_bytes = 0; - gasket_dev->coherent_buffer.virt_base = 0; + gasket_dev->coherent_buffer.virt_base = NULL; gasket_dev->coherent_buffer.phys_base = 0; } return 0; @@ -1765,7 +1765,7 @@ void gasket_free_coherent_memory_all( gasket_dev->coherent_buffer.virt_base, gasket_dev->coherent_buffer.phys_base); gasket_dev->coherent_buffer.length_bytes = 0; - gasket_dev->coherent_buffer.virt_base = 0; + gasket_dev->coherent_buffer.virt_base = NULL; gasket_dev->coherent_buffer.phys_base = 0; } } From 58ca6cec54b571f61cfb85f72a3c8be7c9eaf702 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 11 Jul 2018 12:35:23 +0100 Subject: [PATCH 325/903] staging: sm750fb: remove redundant pointer 'output' Pointer 'output' is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'output' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 67207b0554cd..846d7d243994 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -512,12 +512,10 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var, { struct lynxfb_par *par; struct lynxfb_crtc *crtc; - struct lynxfb_output *output; resource_size_t request; par = info->par; crtc = &par->crtc; - output = &par->output; pr_debug("check var:%dx%d-%d\n", var->xres, From 75ad9a33da2362868beb9c071d7f18020deac9ab Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 11 Jul 2018 12:26:07 +0100 Subject: [PATCH 326/903] staging: speakup: remove redundant variable l Variable l is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'l' set but not used [-Wunused-but-set-variable Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/varhandlers.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c index 54a76b6752ad..1b545152cc49 100644 --- a/drivers/staging/speakup/varhandlers.c +++ b/drivers/staging/speakup/varhandlers.c @@ -179,7 +179,6 @@ int spk_set_num_var(int input, struct st_var_header *var, int how) { int val; int *p_val = var->p_val; - int l; char buf[32]; char *cp; struct var_t *var_data = var->data; @@ -237,9 +236,9 @@ int spk_set_num_var(int input, struct st_var_header *var, int how) else cp = buf; if (!var_data->u.n.out_str) - l = sprintf(cp, var_data->u.n.synth_fmt, (int)val); + sprintf(cp, var_data->u.n.synth_fmt, (int)val); else - l = sprintf(cp, var_data->u.n.synth_fmt, var_data->u.n.out_str[val]); + sprintf(cp, var_data->u.n.synth_fmt, var_data->u.n.out_str[val]); synth_printf("%s", cp); return 0; } From 6efc7e57e3430f1f67b3e917cfecfbb3c1392248 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 13:23:26 +0200 Subject: [PATCH 327/903] staging: rtl8723bs: add spaces around '|' Add spaces around '|' to follow kernel coding style. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 2b3eb6f8ddc5..7216466f89e2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -42,13 +42,13 @@ extern unsigned char WPA_TKIP_CIPHER[4]; #define DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD 3 static u8 rtw_basic_rate_cck[4] = { - IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_ofdm[3] = { - IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; int cckrates_included(unsigned char *rate, int ratelen) From a35115f3c2127ca094319895c530c2f728998825 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 13:23:27 +0200 Subject: [PATCH 328/903] staging: rtl8723bs: fix lines over 80 characters Fix lines over 80 characters by adding appropriate line breaks. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 7216466f89e2..234e741c87e8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -42,12 +42,15 @@ extern unsigned char WPA_TKIP_CIPHER[4]; #define DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD 3 static u8 rtw_basic_rate_cck[4] = { - IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_ofdm[3] = { - IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; From 525cc4f9091f86d045ff23c17d5c0818cada1a2b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 13:23:28 +0200 Subject: [PATCH 329/903] staging: rtl8723bs: remove blank lines Remove unrequired blank lines as reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_wlan_util.c | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 234e741c87e8..106b4f13efc7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -65,7 +65,6 @@ int cckrates_included(unsigned char *rate, int ratelen) } return false; - } int cckratesonly_included(unsigned char *rate, int ratelen) @@ -134,10 +133,8 @@ u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta) default: raid = RATEID_IDX_BGN_40M_2SS; break; - } return raid; - } unsigned char ratetbl_val_2wifirate(unsigned char rate); @@ -193,11 +190,9 @@ unsigned char ratetbl_val_2wifirate(unsigned char rate) case 11: val = IEEE80211_OFDM_RATE_54MB; break; - } return val; - } int is_basicrate(struct adapter *padapter, unsigned char rate); @@ -292,7 +287,6 @@ void UpdateBrateTbl(struct adapter *Adapter, u8 *mBratesOS) break; } } - } void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) @@ -311,7 +305,6 @@ void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) break; } } - } void Save_DM_Func_Flag(struct adapter *padapter) @@ -499,7 +492,6 @@ u16 get_beacon_interval(struct wlan_bssid_ex *bss) memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->IEs), 2); return le16_to_cpu(val); - } int is_client_associated_to_ap(struct adapter *padapter) @@ -542,7 +534,6 @@ int is_IBSS_empty(struct adapter *padapter) } return true; - } unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval) @@ -854,7 +845,6 @@ void flush_all_cam_entry(struct adapter *padapter) rtw_hal_set_hwreg(padapter, HW_VAR_SEC_DK_CFG, (u8 *)false); memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); - } int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) @@ -1068,7 +1058,6 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; } - if ((new_bwmode != pmlmeext->cur_bwmode) || (new_ch_offset != pmlmeext->cur_ch_offset)) { pmlmeinfo->bwmode_updated = true; @@ -1080,7 +1069,6 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ } else pmlmeinfo->bwmode_updated = false; - if (true == pmlmeinfo->bwmode_updated) { struct sta_info *psta; struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); @@ -1088,7 +1076,6 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ - /* update ap's stainfo */ psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); if (psta) { @@ -1208,7 +1195,6 @@ void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) if (phtpriv->ht_option == false) return; - if (pIE->Length > sizeof(struct HT_info_element)) return; @@ -1620,7 +1606,6 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) return false; } else return false; - } int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps, u8 bwmode) @@ -1772,7 +1757,6 @@ void update_IOT_info(struct adapter *padapter) pmlmeinfo->turboMode_rtsen = 1; break; } - } void update_capinfo(struct adapter *Adapter, u16 updateCap) @@ -1785,7 +1769,6 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) /* Mark to update preamble value forever, 2008.03.18 by lanhsin */ /* if (pMgntInfo->RegPreambleMode == PREAMBLE_AUTO) */ { - if (updateCap & cShortPreamble) { /* Short Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ @@ -1823,7 +1806,6 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) } rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); - } void update_wireless_mode(struct adapter *padapter) @@ -1908,7 +1890,6 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); return _SUCCESS; - } void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) @@ -1943,7 +1924,6 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) preorder_ctrl->enable = pmlmeinfo->accept_addba_req; } - } void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) @@ -1975,7 +1955,6 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) u32 delay_ms; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - pmlmeext->bcn_cnt++; pIE = pframe + sizeof(struct ieee80211_hdr_3addr); @@ -2025,7 +2004,6 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) for (i = 0; i < 9; i++) { pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i] * 100) / pmlmeext->bcn_cnt; - DBG_871X("%s():bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d]=%d\n", __func__, i, pmlmeext->bcn_delay_cnt[i], i, pmlmeext->bcn_delay_ratio[i]); @@ -2052,10 +2030,8 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) pmlmeext->bcn_cnt = 0; } - } - void beacon_timing_control(struct adapter *padapter) { rtw_hal_bcn_related_reg_setting(padapter); @@ -2067,7 +2043,6 @@ void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta) u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); - if (!memcmp(psta->hwaddr, bc_addr, ETH_ALEN)) return; @@ -2092,7 +2067,6 @@ void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta) psta->mac_id = i; DBG_871X("%s = %d\n", __func__, psta->mac_id); } - } void rtw_release_macid(struct adapter *padapter, struct sta_info *psta) @@ -2100,7 +2074,6 @@ void rtw_release_macid(struct adapter *padapter, struct sta_info *psta) u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); - if (!memcmp(psta->hwaddr, bc_addr, ETH_ALEN)) return; @@ -2114,10 +2087,8 @@ void rtw_release_macid(struct adapter *padapter, struct sta_info *psta) pdvobj->macid[psta->mac_id] = false; psta->mac_id = NUM_STA; } - } spin_unlock_bh(&pdvobj->lock); - } /* For 8188E RA */ u8 rtw_search_max_mac_id(struct adapter *padapter) @@ -2134,7 +2105,6 @@ u8 rtw_search_max_mac_id(struct adapter *padapter) spin_unlock_bh(&pdvobj->lock); return max_mac_id; - } struct adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj) From c9d19e68a7963f33466d84302b18793c0e549f61 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 13:23:29 +0200 Subject: [PATCH 330/903] staging: rtl8723bs: fix comparsions to NULL Fix comparsions to NULL to follow kernel coding style. x == NULL -> !x x != NULL -> x Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 106b4f13efc7..fef04310ccd8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1106,7 +1106,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (pIE == NULL) + if (!pIE) return; if (phtpriv->ht_option == false) @@ -1189,7 +1189,7 @@ void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (pIE == NULL) + if (!pIE) return; if (phtpriv->ht_option == false) @@ -1341,7 +1341,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } bssid = rtw_zmalloc(sizeof(struct wlan_bssid_ex)); - if (bssid == NULL) { + if (!bssid) { DBG_871X("%s rtw_zmalloc fail !!!\n", __func__); return true; } @@ -1416,7 +1416,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* checking SSID */ p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); - if (p == NULL) { + if (!p) { DBG_871X("%s marc: cannot find SSID for survey event\n", __func__); hidden_ssid = true; } else { @@ -1879,7 +1879,7 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); - if (pIE == NULL) + if (!pIE) return _FAIL; memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); @@ -2219,9 +2219,9 @@ void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip) if ((pmlmeinfo->state & WIFI_FW_LINKING_STATE) || pmlmeinfo->state & WIFI_FW_AP_STATE) { - if (my_ip_ptr != NULL) { + if (my_ip_ptr) { struct in_ifaddr *my_ifa_list = my_ip_ptr->ifa_list; - if (my_ifa_list != NULL) { + if (my_ifa_list) { ipaddress[0] = my_ifa_list->ifa_address & 0xFF; ipaddress[1] = (my_ifa_list->ifa_address >> 8) & 0xFF; ipaddress[2] = (my_ifa_list->ifa_address >> 16) & 0xFF; From f0de833a603d114332563ae995624c000916d8b5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 13:23:30 +0200 Subject: [PATCH 331/903] staging: rtl8723bs: simplify ratetbl_val_2wifirate() Simplify ratetbl_val_2wifirate() by not using extra variable for the return value. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_wlan_util.c | 53 +++++-------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index fef04310ccd8..2c65af319a60 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -140,59 +140,34 @@ u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta) unsigned char ratetbl_val_2wifirate(unsigned char rate); unsigned char ratetbl_val_2wifirate(unsigned char rate) { - unsigned char val = 0; - switch (rate & 0x7f) { case 0: - val = IEEE80211_CCK_RATE_1MB; - break; - + return IEEE80211_CCK_RATE_1MB; case 1: - val = IEEE80211_CCK_RATE_2MB; - break; - + return IEEE80211_CCK_RATE_2MB; case 2: - val = IEEE80211_CCK_RATE_5MB; - break; - + return IEEE80211_CCK_RATE_5MB; case 3: - val = IEEE80211_CCK_RATE_11MB; - break; - + return IEEE80211_CCK_RATE_11MB; case 4: - val = IEEE80211_OFDM_RATE_6MB; - break; - + return IEEE80211_OFDM_RATE_6MB; case 5: - val = IEEE80211_OFDM_RATE_9MB; - break; - + return IEEE80211_OFDM_RATE_9MB; case 6: - val = IEEE80211_OFDM_RATE_12MB; - break; - + return IEEE80211_OFDM_RATE_12MB; case 7: - val = IEEE80211_OFDM_RATE_18MB; - break; - + return IEEE80211_OFDM_RATE_18MB; case 8: - val = IEEE80211_OFDM_RATE_24MB; - break; - + return IEEE80211_OFDM_RATE_24MB; case 9: - val = IEEE80211_OFDM_RATE_36MB; - break; - + return IEEE80211_OFDM_RATE_36MB; case 10: - val = IEEE80211_OFDM_RATE_48MB; - break; - + return IEEE80211_OFDM_RATE_48MB; case 11: - val = IEEE80211_OFDM_RATE_54MB; - break; + return IEEE80211_OFDM_RATE_54MB; + default: + return 0; } - - return val; } int is_basicrate(struct adapter *padapter, unsigned char rate); From e5ce09aa442bacbd43d0cdf50ada2e01286ca51e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 14:27:13 +0200 Subject: [PATCH 332/903] staging: rtl8188eu: add spaces around '|' Add spaces around '|' to follow kernel coding style. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 93d8fa66be7a..54a48ccfcb0d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -34,20 +34,20 @@ unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; #define WAIT_FOR_BCN_TO_MAX (20000) static u8 rtw_basic_rate_cck[4] = { - IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_ofdm[3] = { - IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_mix[7] = { - IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; int cckrates_included(unsigned char *rate, int ratelen) From fecb45a07bec36f9b57b4f0385a0565db48f4547 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 14:27:14 +0200 Subject: [PATCH 333/903] staging: rtl8188eu: fix lines over 80 characters Fix lines over 80 characters by adding appropriate line breaks. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 54a48ccfcb0d..1aed507dd7cb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -34,19 +34,25 @@ unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; #define WAIT_FOR_BCN_TO_MAX (20000) static u8 rtw_basic_rate_cck[4] = { - IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_ofdm[3] = { - IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_mix[7] = { - IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; From e63a46fa5ba76097233edb7643777069d7cc4d72 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 11 Jul 2018 14:27:15 +0200 Subject: [PATCH 334/903] staging: rtl8188eu: remove blank lines Remove unrequired blank lines as reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 6 ------ drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index be1e8bf41e00..454a975a14f2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -626,7 +626,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) else psta->ieee8021x_blocked = false; - /* update sta's cap */ /* ERP */ @@ -725,7 +724,6 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) cur_bwmode = HT_CHANNEL_WIDTH_20; cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - /* check if there is wps ie, * if there is wpsie in beacon, the hostapd will update * beacon twice when stating hostapd, and at first time the @@ -875,7 +873,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return _FAIL; - if (len < 0 || len > MAX_IE_SZ) return _FAIL; @@ -885,7 +882,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) memcpy(ie, pbuf, pbss_network->ie_length); - if (pbss_network->InfrastructureMode != Ndis802_11APMode) return _FAIL; @@ -1681,7 +1677,6 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, /* clear cam entry / key */ rtw_clearstakey_cmd(padapter, (u8 *)psta, (u8)(psta->mac_id + 3), true); - spin_lock_bh(&psta->lock); psta->state &= ~_FW_LINKED; spin_unlock_bh(&psta->lock); @@ -1730,7 +1725,6 @@ int rtw_sta_flush(struct adapter *padapter) } spin_unlock_bh(&pstapriv->asoc_list_lock); - issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); associated_clients_update(padapter, true); diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 1aed507dd7cb..5c4f3f8d013f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1308,7 +1308,6 @@ void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode) else memcpy(supported_rates, rtw_basic_rate_ofdm, 3); - if (wirelessmode & WIRELESS_11B) update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); else From d6ff1b52b569dc12ba5be027bc6c22f4ac0f4ce1 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 11 Jul 2018 12:47:28 +0100 Subject: [PATCH 335/903] staging: vt6655: remove some redundant variables Variables rx_sts, sq, frame and is_pspoll are being assigned but are never used hence they are redundant and can be removed. Cleans up clang warnings: warning: variable 'sq' set but not used [-Wunused-but-set-variable] warning: variable 'rx_sts' set but not used [-Wunused-but-set-variable] warning: variable 'frame' set but not used [-Wunused-but-set-variable] warning: variable 'is_pspoll' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.c | 4 +--- drivers/staging/vt6656/dpc.c | 4 +--- drivers/staging/vt6656/rxtx.c | 5 +---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 088d2d9dbc21..52214a30e9b6 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -34,7 +34,7 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb, __le64 *tsf_time; u16 frame_size; int ii, r; - u8 *rx_sts, *rx_rate, *sq; + u8 *rx_rate; u8 *skb_data; u8 rate_idx = 0; u8 rate[MAX_RATE] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108}; @@ -49,7 +49,6 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb, skb_data = (u8 *)skb->data; - rx_sts = skb_data; rx_rate = skb_data + 1; sband = hw->wiphy->bands[hw->conf.chandef.chan->band]; @@ -74,7 +73,6 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb, } tsf_time = (__le64 *)(skb_data + bytes_received - 12); - sq = skb_data + bytes_received - 4; new_rsr = skb_data + bytes_received - 3; rssi = skb_data + bytes_received - 2; rsr = skb_data + bytes_received - 1; diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index c3b5b1431048..3b94e80f1d5e 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -32,7 +32,7 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb *ptr_rcb, struct ieee80211_rx_status rx_status = { 0 }; struct ieee80211_hdr *hdr; __le16 fc; - u8 *rsr, *new_rsr, *rssi, *frame; + u8 *rsr, *new_rsr, *rssi; __le64 *tsf_time; u32 frame_size; int ii, r; @@ -133,8 +133,6 @@ int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb *ptr_rcb, priv->bb_pre_ed_rssi = (u8)rx_dbm + 1; priv->current_rssi = priv->bb_pre_ed_rssi; - frame = skb_data + 8; - skb_pull(skb, 8); skb_trim(skb, frame_size); diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 26ca3fa29301..9def0748ffee 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -797,7 +797,7 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) unsigned long flags; u16 tx_bytes, tx_header_size, tx_body_size, current_rate, duration_id; u8 pkt_type, fb_option = AUTO_FB_NONE; - bool need_rts = false, is_pspoll = false; + bool need_rts = false; bool need_mic = false; hdr = (struct ieee80211_hdr *)(skb->data); @@ -888,9 +888,6 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) if (ieee80211_has_a4(hdr->frame_control)) tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD); - if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) - is_pspoll = true; - tx_buffer_head->frag_ctl = cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb) << 10); From 2dec0644e0c8083e0a9d3bbdd11aad2d850859e9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 11 Jul 2018 13:39:10 +0200 Subject: [PATCH 336/903] staging: gasket: add SPDX identifiers to all files. It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Fix up the all of the staging gasket files to have a proper SPDX identifier, based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex.h | 1 + drivers/staging/gasket/apex_driver.c | 1 + drivers/staging/gasket/gasket.h | 1 + drivers/staging/gasket/gasket_constants.h | 1 + drivers/staging/gasket/gasket_core.c | 1 + drivers/staging/gasket/gasket_core.h | 1 + drivers/staging/gasket/gasket_interrupt.c | 1 + drivers/staging/gasket/gasket_interrupt.h | 1 + drivers/staging/gasket/gasket_ioctl.c | 1 + drivers/staging/gasket/gasket_ioctl.h | 1 + drivers/staging/gasket/gasket_logging.h | 1 + drivers/staging/gasket/gasket_page_table.c | 1 + drivers/staging/gasket/gasket_page_table.h | 1 + drivers/staging/gasket/gasket_sysfs.c | 1 + drivers/staging/gasket/gasket_sysfs.h | 1 + 15 files changed, 15 insertions(+) diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h index f2600aa05191..1d1f34d53c77 100644 --- a/drivers/staging/gasket/apex.h +++ b/drivers/staging/gasket/apex.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Apex kernel-userspace interface definition(s). * diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 395256704428..670ada307c3c 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* Driver for the Apex chip. * * Copyright (C) 2018 Google, Inc. diff --git a/drivers/staging/gasket/gasket.h b/drivers/staging/gasket/gasket.h index 593d50820c65..c0ea9ad7c187 100644 --- a/drivers/staging/gasket/gasket.h +++ b/drivers/staging/gasket/gasket.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* Common Gasket device kernel and user space declarations. * * Copyright (C) 2018 Google, Inc. diff --git a/drivers/staging/gasket/gasket_constants.h b/drivers/staging/gasket/gasket_constants.h index b39e3e3f7d2c..e70c2220f3d8 100644 --- a/drivers/staging/gasket/gasket_constants.h +++ b/drivers/staging/gasket/gasket_constants.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (C) 2018 Google, Inc. * * This software is licensed under the terms of the GNU General Public diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 45914ebc8f44..a09f491296fb 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* Gasket generic driver framework. This file contains the implementation * for the Gasket generic driver framework - the functionality that is common * across Gasket devices. diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 5d6535a0f254..be25d9389237 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* Gasket generic driver. Defines the set of data types and functions necessary * to define a driver using the Gasket generic driver framework. * diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index d1461b36f091..28bb80de22bf 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2018 Google, Inc. * * This software is licensed under the terms of the GNU General Public diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h index 3a8afae6487a..2220ca4d89e4 100644 --- a/drivers/staging/gasket/gasket_interrupt.h +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Gasket common interrupt module. Defines functions for enabling * eventfd-triggered interrupts between a Gasket device and a host process. diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 4758083fb19b..c5d7beefc3ff 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2018 Google, Inc. * * This software is licensed under the terms of the GNU General Public diff --git a/drivers/staging/gasket/gasket_ioctl.h b/drivers/staging/gasket/gasket_ioctl.h index df868000c803..457b3165defd 100644 --- a/drivers/staging/gasket/gasket_ioctl.h +++ b/drivers/staging/gasket/gasket_ioctl.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (C) 2018 Google, Inc. * * This software is licensed under the terms of the GNU General Public diff --git a/drivers/staging/gasket/gasket_logging.h b/drivers/staging/gasket/gasket_logging.h index fa17b4ae455a..e288da6caa1d 100644 --- a/drivers/staging/gasket/gasket_logging.h +++ b/drivers/staging/gasket/gasket_logging.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* Common logging utilities for the Gasket driver framework. * * Copyright (C) 2018 Google, Inc. diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 5d3d33cac12f..e86c160c167b 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* Implementation of Gasket page table support. * * Copyright (C) 2018 Google, Inc. diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index f2f519a3022d..2074239a763e 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* Gasket Page Table functionality. This file describes the address * translation/paging functionality supported by the Gasket driver framework. * As much as possible, internal details are hidden to simplify use - diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index a3705d6e088a..b16ecac87cee 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2018 Google, Inc. * * This software is licensed under the terms of the GNU General Public diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h index df9360ecab31..26aa091c76d5 100644 --- a/drivers/staging/gasket/gasket_sysfs.h +++ b/drivers/staging/gasket/gasket_sysfs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* Set of common sysfs utilities. * * Copyright (C) 2018 Google, Inc. From bf9c7a8673831acd67ad4a92b6acd85ffcde174c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 11 Jul 2018 13:39:11 +0200 Subject: [PATCH 337/903] staging: gasket: remove redundant license information Now that the SPDX tag is in all gasket files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex.h | 9 --------- drivers/staging/gasket/apex_driver.c | 12 ++---------- drivers/staging/gasket/gasket.h | 12 ++---------- drivers/staging/gasket/gasket_constants.h | 12 +----------- drivers/staging/gasket/gasket_core.c | 12 ++---------- drivers/staging/gasket/gasket_core.h | 12 ++---------- drivers/staging/gasket/gasket_interrupt.c | 12 +----------- drivers/staging/gasket/gasket_interrupt.h | 9 --------- drivers/staging/gasket/gasket_ioctl.c | 12 +----------- drivers/staging/gasket/gasket_ioctl.h | 12 +----------- drivers/staging/gasket/gasket_logging.h | 12 ++---------- drivers/staging/gasket/gasket_page_table.c | 12 ++---------- drivers/staging/gasket/gasket_page_table.h | 12 ++---------- drivers/staging/gasket/gasket_sysfs.c | 12 +----------- drivers/staging/gasket/gasket_sysfs.h | 12 ++---------- 15 files changed, 21 insertions(+), 153 deletions(-) diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h index 1d1f34d53c77..4ef264106f50 100644 --- a/drivers/staging/gasket/apex.h +++ b/drivers/staging/gasket/apex.h @@ -3,15 +3,6 @@ * Apex kernel-userspace interface definition(s). * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef __APEX_H__ #define __APEX_H__ diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 670ada307c3c..e2258e47d9fe 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -1,16 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -/* Driver for the Apex chip. +/* + * Driver for the Apex chip. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include diff --git a/drivers/staging/gasket/gasket.h b/drivers/staging/gasket/gasket.h index c0ea9ad7c187..9f709f0c5a2b 100644 --- a/drivers/staging/gasket/gasket.h +++ b/drivers/staging/gasket/gasket.h @@ -1,16 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Common Gasket device kernel and user space declarations. +/* + * Common Gasket device kernel and user space declarations. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef __GASKET_H__ #define __GASKET_H__ diff --git a/drivers/staging/gasket/gasket_constants.h b/drivers/staging/gasket/gasket_constants.h index e70c2220f3d8..82ed3f21e8ae 100644 --- a/drivers/staging/gasket/gasket_constants.h +++ b/drivers/staging/gasket/gasket_constants.h @@ -1,15 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +/* Copyright (C) 2018 Google, Inc. */ #ifndef __GASKET_CONSTANTS_H__ #define __GASKET_CONSTANTS_H__ diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index a09f491296fb..926113b7d6af 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1,18 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 -/* Gasket generic driver framework. This file contains the implementation +/* + * Gasket generic driver framework. This file contains the implementation * for the Gasket generic driver framework - the functionality that is common * across Gasket devices. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include "gasket_core.h" diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index be25d9389237..45013446b8c5 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -1,17 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Gasket generic driver. Defines the set of data types and functions necessary +/* + * Gasket generic driver. Defines the set of data types and functions necessary * to define a driver using the Gasket generic driver framework. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef __GASKET_CORE_H__ #define __GASKET_CORE_H__ diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 28bb80de22bf..faaabdce4720 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -1,15 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +/* Copyright (C) 2018 Google, Inc. */ #include "gasket_interrupt.h" diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h index 2220ca4d89e4..44ea98570844 100644 --- a/drivers/staging/gasket/gasket_interrupt.h +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -4,15 +4,6 @@ * eventfd-triggered interrupts between a Gasket device and a host process. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef __GASKET_INTERRUPT_H__ #define __GASKET_INTERRUPT_H__ diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index c5d7beefc3ff..3c54542610f7 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -1,15 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +/* Copyright (C) 2018 Google, Inc. */ #include "gasket.h" #include "gasket_ioctl.h" #include "gasket_constants.h" diff --git a/drivers/staging/gasket/gasket_ioctl.h b/drivers/staging/gasket/gasket_ioctl.h index 457b3165defd..461fab27a3e5 100644 --- a/drivers/staging/gasket/gasket_ioctl.h +++ b/drivers/staging/gasket/gasket_ioctl.h @@ -1,15 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +/* Copyright (C) 2018 Google, Inc. */ #ifndef __GASKET_IOCTL_H__ #define __GASKET_IOCTL_H__ diff --git a/drivers/staging/gasket/gasket_logging.h b/drivers/staging/gasket/gasket_logging.h index e288da6caa1d..54bbe516b071 100644 --- a/drivers/staging/gasket/gasket_logging.h +++ b/drivers/staging/gasket/gasket_logging.h @@ -1,16 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Common logging utilities for the Gasket driver framework. +/* + * Common logging utilities for the Gasket driver framework. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index e86c160c167b..f00a8f1d07e1 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1,16 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -/* Implementation of Gasket page table support. +/* + * Implementation of Gasket page table support. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ /* diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index 2074239a763e..d8d031cf16a2 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h @@ -1,20 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Gasket Page Table functionality. This file describes the address +/* + * Gasket Page Table functionality. This file describes the address * translation/paging functionality supported by the Gasket driver framework. * As much as possible, internal details are hidden to simplify use - * all calls are thread-safe (protected by an internal mutex) except where * indicated otherwise. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef __GASKET_ADDR_TRNSL_H__ diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index b16ecac87cee..94e55f19b43f 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -1,15 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +/* Copyright (C) 2018 Google, Inc. */ #include "gasket_sysfs.h" #include "gasket_core.h" diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h index 26aa091c76d5..40db5a063afd 100644 --- a/drivers/staging/gasket/gasket_sysfs.h +++ b/drivers/staging/gasket/gasket_sysfs.h @@ -1,16 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Set of common sysfs utilities. +/* + * Set of common sysfs utilities. * * Copyright (C) 2018 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ /* The functions described here are a set of utilities to allow each file in the From 191c6a97a742d19dc2f4689d43f45168573dbe5a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 11 Jul 2018 13:39:12 +0200 Subject: [PATCH 338/903] staging: gasket: remove TODO item about SPDX usage Now that the files are all properly tagged with SPDX lines, and the boilerplate license text is gone, remove the TODO item. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/TODO | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO index 0d8ee9602c80..d3c44ca4fda2 100644 --- a/drivers/staging/gasket/TODO +++ b/drivers/staging/gasket/TODO @@ -1,7 +1,5 @@ This is a list of things that need to be done to get this driver out of the staging directory. -- Use SPDX tags to show the license of the file, and no more "boiler-plate" - license text is needed. - Remove static function declarations. - Document sysfs files with Documentation/ABI/ entries. - Use misc interface instead of major number for driver version description. From 1ba60ad56c409f23ac244adb7734208e53f8a985 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Wed, 11 Jul 2018 13:15:54 +0000 Subject: [PATCH 339/903] staging: pi433: fix error return code in pi433_probe() Fix to return a negative error code from the kthread_run() error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 511b2b531732..c85a805a1243 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1249,6 +1249,7 @@ static int pi433_probe(struct spi_device *spi) device->minor); if (IS_ERR(device->tx_task_struct)) { dev_dbg(device->dev, "start of send thread failed"); + retval = PTR_ERR(device->tx_task_struct); goto send_thread_failed; } From 11ac66a379091ce425a456e1a714066f255f38f8 Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Wed, 11 Jul 2018 13:23:57 -0700 Subject: [PATCH 340/903] staging: goldfish: Remove references to the retired driver from README The goldfish nand driver was retired (not used). Signed-off-by: Roman Kiryanov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/README | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/goldfish/README b/drivers/staging/goldfish/README index 183af0053234..ed08c4d46e75 100644 --- a/drivers/staging/goldfish/README +++ b/drivers/staging/goldfish/README @@ -3,9 +3,3 @@ Audio - Move to using the ALSA framework not faking it - Fix the wrong user page DMA (moving to ALSA may fix that too) -NAND ----- -- 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) - From 683a060a1d975bb440d70662fbdb6f4879ad56ae Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Wed, 11 Jul 2018 16:36:28 -0700 Subject: [PATCH 341/903] staging: goldfish: fix whitespace in goldfish_audio Linux kernel coding style: spaces are never used for indentation. Signed-off-by: Roman Kiryanov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index b7004edd3ce2..1d80e3243297 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -43,13 +43,13 @@ struct goldfish_audio { wait_queue_head_t wait; char *buffer_virt; /* combined buffer virtual address */ - unsigned long buffer_phys; /* combined buffer physical address */ + unsigned long buffer_phys; /* combined buffer physical address */ char *write_buffer1; /* write buffer 1 virtual address */ char *write_buffer2; /* write buffer 2 virtual address */ char *read_buffer; /* read buffer virtual address */ int buffer_status; - int read_supported; /* true if we have audio input support */ + int read_supported; /* true if we have audio input support */ }; /* @@ -57,9 +57,9 @@ struct goldfish_audio { * Having two read buffers facilitate stereo -> mono conversion. * Having two write buffers facilitate interleaved IO. */ -#define READ_BUFFER_SIZE 16384 -#define WRITE_BUFFER_SIZE 16384 -#define COMBINED_BUFFER_SIZE ((2 * READ_BUFFER_SIZE) + \ +#define READ_BUFFER_SIZE 16384 +#define WRITE_BUFFER_SIZE 16384 +#define COMBINED_BUFFER_SIZE ((2 * READ_BUFFER_SIZE) + \ (2 * WRITE_BUFFER_SIZE)) /* @@ -99,9 +99,9 @@ enum { /* this bit set when it is safe to write more bytes to the buffer */ AUDIO_INT_WRITE_BUFFER_1_EMPTY = 1U << 0, AUDIO_INT_WRITE_BUFFER_2_EMPTY = 1U << 1, - AUDIO_INT_READ_BUFFER_FULL = 1U << 2, + AUDIO_INT_READ_BUFFER_FULL = 1U << 2, - AUDIO_INT_MASK = AUDIO_INT_WRITE_BUFFER_1_EMPTY | + AUDIO_INT_MASK = AUDIO_INT_WRITE_BUFFER_1_EMPTY | AUDIO_INT_WRITE_BUFFER_2_EMPTY | AUDIO_INT_READ_BUFFER_FULL, }; From 24daa451c2814e770c6d6b6c00a065cb5b8b22fd Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Wed, 11 Jul 2018 16:37:48 -0700 Subject: [PATCH 342/903] staging: goldfish: add a blank line into struct goldfish_audio To separate data members and the comment for better readability. Signed-off-by: Roman Kiryanov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 1d80e3243297..3a75df1d2a0a 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -38,6 +38,7 @@ MODULE_VERSION("1.0"); struct goldfish_audio { char __iomem *reg_base; int irq; + /* lock protects access to buffer_status and to device registers */ spinlock_t lock; wait_queue_head_t wait; From 5c60ce7b6ae9a056ddcdee318142b60c0e09aed1 Mon Sep 17 00:00:00 2001 From: Felix Siegel Date: Thu, 12 Jul 2018 21:27:13 +0200 Subject: [PATCH 343/903] staging: gasket: Move open-curly brace to match kernel code style Move open open-curly brace to the next line following function definition to match the kernel's coding style Signed-off-by: Felix Siegel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 926113b7d6af..5863a3f79ff4 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1895,7 +1895,8 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) EXPORT_SYMBOL(gasket_reset_nolock); gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( - struct gasket_dev *gasket_dev) { + struct gasket_dev *gasket_dev) +{ return gasket_dev->internal_desc->driver_desc->ioctl_permissions_cb; } EXPORT_SYMBOL(gasket_get_ioctl_permissions_cb); From e96a31cee962d766409d7da25d1831b3348b0a61 Mon Sep 17 00:00:00 2001 From: Felix Siegel Date: Thu, 12 Jul 2018 21:27:14 +0200 Subject: [PATCH 344/903] staging: gasket: fix multi line comments style This patch fixes checkpatch.pl warnings: WARNING: Block comments should align the * on each line Signed-off-by: Felix Siegel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 5863a3f79ff4..4ca6e53116ea 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1347,9 +1347,9 @@ static bool gasket_mm_get_mapping_addrs( *virt_offset = 0; if (bar_offset + requested_length < range_start) { /* - * If the requested region is completely below the range, - * there is nothing to map. - */ + * If the requested region is completely below the range, + * there is nothing to map. + */ return false; } else if (bar_offset <= range_start) { /* If the bar offset is below this range's start @@ -1507,7 +1507,7 @@ fail: * Calculates the offset where the VMA range begins in its containing BAR. * The offset is written into bar_offset on success. * Returns zero on success, anything else on error. -*/ + */ static int gasket_mm_vma_bar_offset( const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, ulong *bar_offset) From 792b260dafc33261444ca7d55bff30cf5e86a304 Mon Sep 17 00:00:00 2001 From: Felix Siegel Date: Fri, 13 Jul 2018 00:58:48 +0200 Subject: [PATCH 345/903] staging: gasket: remove "function entered" log messages Remove log messages that solely print the function's name everytime it is called. Signed-off-by: Felix Siegel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index e2258e47d9fe..161c48bcd616 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -341,8 +341,6 @@ static int apex_add_dev_cb(struct gasket_dev *gasket_dev) ulong page_table_ready, msix_table_ready; int retries = 0; - gasket_log_error(gasket_dev, "apex_add_dev_cb."); - apex_reset(gasket_dev, 0); while (retries < APEX_RESET_RETRY) { @@ -447,8 +445,6 @@ static int apex_reset(struct gasket_dev *gasket_dev, uint type) if (bypass_top_level) return 0; - gasket_log_debug(gasket_dev, "apex_reset."); - if (!is_gcb_in_reset(gasket_dev)) { /* We are not in reset - toggle the reset bit so as to force * re-init of custom block @@ -472,8 +468,6 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) if (bypass_top_level) return 0; - gasket_log_debug(gasket_dev, "apex_enter_reset."); - /* * Software reset: * Enable sleep mode @@ -534,8 +528,6 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) if (bypass_top_level) return 0; - gasket_log_debug(gasket_dev, "apex_quit_reset."); - /* * Disable sleep mode: * - Disable GCB memory shut down: From 948fd537bd3d6f347ff1c87b82479873d1fcc77f Mon Sep 17 00:00:00 2001 From: Felix Siegel Date: Fri, 13 Jul 2018 00:58:49 +0200 Subject: [PATCH 346/903] staging: gasket: Use __func__ instead of hardcoded string - Style Changed logging statements to use %s and __func__ instead of hard coding the function name in a string. Signed-off-by: Felix Siegel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 7 ++++--- drivers/staging/gasket/gasket_core.c | 8 +++++--- drivers/staging/gasket/gasket_ioctl.c | 3 ++- drivers/staging/gasket/gasket_page_table.c | 13 ++++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 161c48bcd616..cca4cf491a58 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -420,8 +420,9 @@ static int apex_device_cleanup(struct gasket_dev *gasket_dev) gasket_log_info( gasket_dev, - "apex_device_cleanup 0x%p hib_error 0x%llx scalar_error " + "%s 0x%p hib_error 0x%llx scalar_error " "0x%llx.", + __func__, gasket_dev, hib_error, scalar_error); if (allow_power_save) @@ -449,7 +450,7 @@ static int apex_reset(struct gasket_dev *gasket_dev, uint type) /* We are not in reset - toggle the reset bit so as to force * re-init of custom block */ - gasket_log_debug(gasket_dev, "apex_reset: toggle reset."); + gasket_log_debug(gasket_dev, "%s: toggle reset.", __func__); ret = apex_enter_reset(gasket_dev, type); if (ret) @@ -673,7 +674,7 @@ static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg) return -EFAULT; gasket_log_error( - gasket_dev, "apex_clock_gating %llu", ibuf.enable); + gasket_dev, "%s %llu", __func__, ibuf.enable); if (ibuf.enable) { /* Quiesce AXI, gate GCB clock. */ diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 4ca6e53116ea..14649a794e35 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -932,7 +932,7 @@ static int gasket_enable_dev( } else { gasket_log_error( gasket_dev, - "gasket_enable_dev with no physical device!!"); + "%s with no physical device!!", __func__); WARN_ON(1); ddev = NULL; } @@ -2100,8 +2100,9 @@ int gasket_wait_sync( if (diff_nanosec > timeout_ns) { gasket_log_error( gasket_dev, - "gasket_wait_sync timeout: reg %llx count %x " + "%s timeout: reg %llx count %x " "dma %lld ns\n", + __func__, offset, count, diff_nanosec); return -1; } @@ -2141,7 +2142,8 @@ int gasket_wait_with_reschedule( if (retries == max_retries) { gasket_log_error( gasket_dev, - "gasket_wait_with_reschedule timeout: reg %llx timeout (%llu ms)", + "%s timeout: reg %llx timeout (%llu ms)", + __func__, offset, max_retries * delay_ms); return -EINVAL; } diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 3c54542610f7..0c2f85cf5448 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -178,7 +178,8 @@ static uint gasket_ioctl_check_permissions(struct file *filp, uint cmd) alive = (gasket_dev->status == GASKET_STATUS_ALIVE); if (!alive) { gasket_nodev_error( - "gasket_ioctl_check_permissions alive %d status %d.", + "%s alive %d status %d.", + __func__, alive, gasket_dev->status); } diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index f00a8f1d07e1..3de7f8c400c9 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -445,8 +445,9 @@ int gasket_page_table_map( mutex_unlock(&pg_tbl->mutex); gasket_nodev_debug( - "gasket_page_table_map done: ha %llx daddr %llx num %d, " + "%s done: ha %llx daddr %llx num %d, " "ret %d\n", + __func__, (unsigned long long)host_addr, (unsigned long long)dev_addr, num_pages, ret); return ret; @@ -869,7 +870,7 @@ static int gasket_perform_mapping( for (i = 0; i < num_pages; i++) { page_addr = host_addr + i * PAGE_SIZE; offset = page_addr & (PAGE_SIZE - 1); - gasket_nodev_debug("gasket_perform_mapping i %d\n", i); + gasket_nodev_debug("%s i %d\n", __func__, i); if (is_coherent(pg_tbl, host_addr)) { u64 off = (u64)host_addr - @@ -907,17 +908,19 @@ static int gasket_perform_mapping( } gasket_nodev_debug( - " gasket_perform_mapping dev %p " + "%s dev %p " "i %d pte %p pfn %p -> mapped %llx\n", + __func__, pg_tbl->device, i, &ptes[i], (void *)page_to_pfn(page), (unsigned long long)ptes[i].dma_addr); if (ptes[i].dma_addr == -1) { gasket_nodev_error( - "gasket_perform_mapping i %d" + "%s i %d" " -> fail to map page %llx " "[pfn %p ohys %p]\n", + __func__, i, (unsigned long long)ptes[i].dma_addr, (void *)page_to_pfn(page), @@ -1623,7 +1626,7 @@ int gasket_set_user_virt( pg_tbl = gasket_dev->page_table[0]; if (!pg_tbl) { gasket_nodev_error( - "gasket_set_user_virt: invalid page table index"); + "%s: invalid page table index", __func__); return 0; } for (j = 0; j < num_pages; j++) { From 6cf58b91827002673b5e0a505743bb291951952d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ko=C5=82odziej?= Date: Thu, 12 Jul 2018 10:11:39 +0200 Subject: [PATCH 347/903] staging: rtl8188eu: break line longer than 80 cols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Break too long line to follow kernel coding style. Signed-off-by: Kacper KoÅ‚odziej Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 454a975a14f2..220b4bbe1f84 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -362,7 +362,8 @@ void expire_timeout_chk(struct adapter *padapter) stainfo_offset = rtw_stainfo_offset(pstapriv, psta); if (stainfo_offset_valid(stainfo_offset)) - chk_alive_list[chk_alive_num++] = stainfo_offset; + chk_alive_list[chk_alive_num++] = + stainfo_offset; continue; } From a796528951e25a9ee635bd22d0a6e2c4fb2bd45c Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Thu, 12 Jul 2018 10:33:30 -0500 Subject: [PATCH 348/903] staging: rtlwifi: Remove empty halmac_pcie_reg.h halmac_pcie_reg.h is empty, so remove it and the only include of it. Signed-off-by: Bjorn Helgaas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/halmac/halmac_api.h | 1 - .../staging/rtlwifi/halmac/halmac_pcie_reg.h | 17 ----------------- 2 files changed, 18 deletions(-) delete mode 100644 drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h diff --git a/drivers/staging/rtlwifi/halmac/halmac_api.h b/drivers/staging/rtlwifi/halmac/halmac_api.h index 4922cc8ce6f2..e220db39c8a7 100644 --- a/drivers/staging/rtlwifi/halmac/halmac_api.h +++ b/drivers/staging/rtlwifi/halmac/halmac_api.h @@ -29,7 +29,6 @@ #include "halmac_usb_reg.h" #include "halmac_sdio_reg.h" -#include "halmac_pcie_reg.h" #include "halmac_bit2.h" #include "halmac_reg2.h" diff --git a/drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h b/drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h deleted file mode 100644 index a2552b27367b..000000000000 --- a/drivers/staging/rtlwifi/halmac/halmac_pcie_reg.h +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2016 Realtek Corporation. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ -#ifndef __HALMAC_PCIE_REG_H__ -#define __HALMAC_PCIE_REG_H__ - -#endif /* __HALMAC_PCIE_REG_H__ */ From de9b58400a3ce6b9b6cc45f66c3f5e3d754becf1 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Jul 2018 18:16:13 +0200 Subject: [PATCH 349/903] staging: rtl8188eu: use strlcpy instead of strncpy Use strlcpy instead of strncpy to avoid gcc 8 warning: warning: '__builtin_strncpy' specified bound 16 equals destination size [-Wstringop-truncation] The maximum length of the source string including terminating null is 5. Hence it always fits in the destination buffer of length 16. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 80ccd19e776d..0f82a8c330f8 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1912,7 +1912,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, goto exit; } - strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); + strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) param->u.crypt.set_tx = 1; From 81f34e96dc9f965e80497ffbc764bf931b91ac5f Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Thu, 12 Jul 2018 12:12:29 -0500 Subject: [PATCH 350/903] staging: fsl-dpaa2/eth: Remove unnecessary cast There's no need to explicitly cast DPAA2_ETH_MFL to u16, so remove it. Signed-off-by: Ioana Radulescu Suggested-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 4ae2371940bc..da993ed80ecf 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -2366,7 +2366,7 @@ static int netdev_init(struct net_device *net_dev) /* Set MTU upper limit; lower limit is 68B (default value) */ net_dev->max_mtu = DPAA2_ETH_MAX_MTU; err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token, - (u16)DPAA2_ETH_MFL); + DPAA2_ETH_MFL); if (err) { dev_err(dev, "dpni_set_max_frame_length() failed\n"); return err; From 4feb0f375f030050906c834fde8bf80ac4a4571b Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Fri, 13 Jul 2018 00:54:16 +0300 Subject: [PATCH 351/903] staging: bcm2835-audio: Check if workqueue allocation failed Currently, if allocating a workqueue fails, the driver will probe successfully but it will silently do nothing, which is rather silly. So instead bail out with -ENOMEM in bcm2835_audio_open() if alloc_workqueue() fails, and remove the now pointless checks for a NULL workqueue. While at it, get rid of the rather pointless one-line function my_workqueue_init(). Signed-off-by: Tuomas Tynkkynen Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-audio/bcm2835-vchiq.c | 105 ++++++++---------- 1 file changed, 47 insertions(+), 58 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index f0cefa1b7b0f..8c4345cb44af 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -117,44 +117,40 @@ static void my_wq_function(struct work_struct *work) int bcm2835_audio_start(struct bcm2835_alsa_stream *alsa_stream) { - if (alsa_stream->my_wq) { - struct bcm2835_audio_work *work; + struct bcm2835_audio_work *work; - work = kmalloc(sizeof(*work), GFP_ATOMIC); - /*--- Queue some work (item 1) ---*/ - if (!work) { - LOG_ERR(" .. Error: NULL work kmalloc\n"); - return -ENOMEM; - } - INIT_WORK(&work->my_work, my_wq_function); - work->alsa_stream = alsa_stream; - work->cmd = BCM2835_AUDIO_START; - if (!queue_work(alsa_stream->my_wq, &work->my_work)) { - kfree(work); - return -EBUSY; - } + work = kmalloc(sizeof(*work), GFP_ATOMIC); + /*--- Queue some work (item 1) ---*/ + if (!work) { + LOG_ERR(" .. Error: NULL work kmalloc\n"); + return -ENOMEM; + } + INIT_WORK(&work->my_work, my_wq_function); + work->alsa_stream = alsa_stream; + work->cmd = BCM2835_AUDIO_START; + if (!queue_work(alsa_stream->my_wq, &work->my_work)) { + kfree(work); + return -EBUSY; } return 0; } int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream) { - if (alsa_stream->my_wq) { - struct bcm2835_audio_work *work; + struct bcm2835_audio_work *work; - work = kmalloc(sizeof(*work), GFP_ATOMIC); - /*--- Queue some work (item 1) ---*/ - if (!work) { - LOG_ERR(" .. Error: NULL work kmalloc\n"); - return -ENOMEM; - } - INIT_WORK(&work->my_work, my_wq_function); - work->alsa_stream = alsa_stream; - work->cmd = BCM2835_AUDIO_STOP; - if (!queue_work(alsa_stream->my_wq, &work->my_work)) { - kfree(work); - return -EBUSY; - } + work = kmalloc(sizeof(*work), GFP_ATOMIC); + /*--- Queue some work (item 1) ---*/ + if (!work) { + LOG_ERR(" .. Error: NULL work kmalloc\n"); + return -ENOMEM; + } + INIT_WORK(&work->my_work, my_wq_function); + work->alsa_stream = alsa_stream; + work->cmd = BCM2835_AUDIO_STOP; + if (!queue_work(alsa_stream->my_wq, &work->my_work)) { + kfree(work); + return -EBUSY; } return 0; } @@ -162,40 +158,31 @@ int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream) int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, unsigned int count, void *src) { - if (alsa_stream->my_wq) { - struct bcm2835_audio_work *work; + struct bcm2835_audio_work *work; - work = kmalloc(sizeof(*work), GFP_ATOMIC); - /*--- Queue some work (item 1) ---*/ - if (!work) { - LOG_ERR(" .. Error: NULL work kmalloc\n"); - return -ENOMEM; - } - INIT_WORK(&work->my_work, my_wq_function); - work->alsa_stream = alsa_stream; - work->cmd = BCM2835_AUDIO_WRITE; - work->src = src; - work->count = count; - if (!queue_work(alsa_stream->my_wq, &work->my_work)) { - kfree(work); - return -EBUSY; - } + work = kmalloc(sizeof(*work), GFP_ATOMIC); + /*--- Queue some work (item 1) ---*/ + if (!work) { + LOG_ERR(" .. Error: NULL work kmalloc\n"); + return -ENOMEM; + } + INIT_WORK(&work->my_work, my_wq_function); + work->alsa_stream = alsa_stream; + work->cmd = BCM2835_AUDIO_WRITE; + work->src = src; + work->count = count; + if (!queue_work(alsa_stream->my_wq, &work->my_work)) { + kfree(work); + return -EBUSY; } return 0; } -static void my_workqueue_init(struct bcm2835_alsa_stream *alsa_stream) -{ - alsa_stream->my_wq = alloc_workqueue("my_queue", WQ_HIGHPRI, 1); -} - static void my_workqueue_quit(struct bcm2835_alsa_stream *alsa_stream) { - if (alsa_stream->my_wq) { - flush_workqueue(alsa_stream->my_wq); - destroy_workqueue(alsa_stream->my_wq); - alsa_stream->my_wq = NULL; - } + flush_workqueue(alsa_stream->my_wq); + destroy_workqueue(alsa_stream->my_wq); + alsa_stream->my_wq = NULL; } static void audio_vchi_callback(void *param, @@ -436,7 +423,9 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) int status; int ret; - my_workqueue_init(alsa_stream); + alsa_stream->my_wq = alloc_workqueue("my_queue", WQ_HIGHPRI, 1); + if (!alsa_stream->my_wq) + return -ENOMEM; ret = bcm2835_audio_open_connection(alsa_stream); if (ret) { From 678c5b119307c40f9a17152512f9c949d0ec7292 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Fri, 13 Jul 2018 00:54:17 +0300 Subject: [PATCH 352/903] staging: bcm2835-audio: Don't leak workqueue if open fails Currently, if bcm2835_audio_open() fails partway, the allocated workqueue is leaked. Avoid that. While at it, propagate the return value of bcm2835_audio_open_connection() on failure instead of returning -1. Signed-off-by: Tuomas Tynkkynen Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 8c4345cb44af..868e2d6aaf1b 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -428,16 +428,16 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) return -ENOMEM; ret = bcm2835_audio_open_connection(alsa_stream); - if (ret) { - ret = -1; - goto exit; - } + if (ret) + goto free_wq; + instance = alsa_stream->instance; LOG_DBG(" instance (%p)\n", instance); if (mutex_lock_interruptible(&instance->vchi_mutex)) { LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", instance->num_connections); - return -EINTR; + ret = -EINTR; + goto free_wq; } vchi_service_use(instance->vchi_handle[0]); @@ -460,7 +460,11 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) unlock: vchi_service_release(instance->vchi_handle[0]); mutex_unlock(&instance->vchi_mutex); -exit: + +free_wq: + if (ret) + destroy_workqueue(alsa_stream->my_wq); + return ret; } From c0f94a0aebe605a5a3ffa8c9afc0ebedef6c0a15 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:40 +0100 Subject: [PATCH 353/903] staging:rtl8192u: typedef struct tx_desc_819x_usb > struct tx_desc_819x_usb Change structure tx_desc_819x_usb from being typedef to being a simple structure, without the typedef. checkpatch warns about defining new types in code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 6 +++--- drivers/staging/rtl8192u/r8192U_core.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 37aa36126d19..fa451c6081ef 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -177,7 +177,7 @@ extern u32 rt_global_debug_component; #define CCK_Table_length 12 /* For rtl819x */ -typedef struct _tx_desc_819x_usb { +struct tx_desc_819x_usb { /* DWORD 0 */ u16 PktSize; u8 Offset; @@ -213,7 +213,7 @@ typedef struct _tx_desc_819x_usb { u32 Reserved5; u32 Reserved6; u32 Reserved7; -} tx_desc_819x_usb, *ptx_desc_819x_usb; +}; #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE typedef struct _tx_desc_819x_usb_aggr_subframe { @@ -371,7 +371,7 @@ typedef struct rx_drvinfo_819x_usb { #define MAX_FIRMWARE_INFORMATION_SIZE 32 #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) #define ENCRYPTION_MAX_OVERHEAD 128 -#define USB_HWDESC_HEADER_LEN sizeof(tx_desc_819x_usb) +#define USB_HWDESC_HEADER_LEN sizeof(struct tx_desc_819x_usb) #define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb)) #define MAX_FRAGMENT_COUNT 8 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 848239e24859..a2a107521450 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1462,7 +1462,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) { struct r8192_priv *priv = ieee80211_priv(dev); struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data; + struct tx_desc_819x_usb *tx_desc = (struct tx_desc_819x_usb *)skb->data; tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN); struct usb_device *udev = priv->udev; @@ -1535,7 +1535,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) } /* Fill Tx descriptor */ - memset(tx_desc, 0, sizeof(tx_desc_819x_usb)); + memset(tx_desc, 0, sizeof(struct tx_desc_819x_usb)); /* DWORD 0 */ tx_desc->LINIP = 0; tx_desc->CmdInit = 1; From ef7ebea4ae3abaad659c3e809ae64f38685dd8ad Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:41 +0100 Subject: [PATCH 354/903] staging:rtl8192u: trim multiple blank lines - Coding Style Trim the extra blank lines from the code, to clear checkpatch messages. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index fa451c6081ef..da23e7e9e3b9 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -59,7 +59,6 @@ extern u32 rt_global_debug_component; #define COMP_DBG BIT(1) #define COMP_INIT BIT(2) /* Driver initialization/halt/reset. */ - #define COMP_RECV BIT(3) /* Receive data path. */ #define COMP_SEND BIT(4) /* Send data path. */ #define COMP_IO BIT(5) @@ -127,7 +126,6 @@ extern u32 rt_global_debug_component; #define RT_DEBUG_DATA(level, data, datalen) do {} while (0) #endif /* RTL8169_DEBUG */ - /* Queue Select Value in TxDesc */ #define QSLT_BK 0x1 #define QSLT_BE 0x0 @@ -240,8 +238,6 @@ typedef struct _tx_desc_819x_usb_aggr_subframe { } tx_desc_819x_usb_aggr_subframe, *ptx_desc_819x_usb_aggr_subframe; #endif - - typedef struct _tx_desc_cmd_819x_usb { /* DWORD 0 */ u16 Reserved0; @@ -269,7 +265,6 @@ typedef struct _tx_desc_cmd_819x_usb { u32 Reserved8; } tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb; - typedef struct _tx_fwinfo_819x_usb { /* DOWRD 0 */ u8 TxRate:7; @@ -492,7 +487,6 @@ typedef struct _rt_firmware_info_819xUsb { #define PHY_RSSI_SLID_WIN_MAX 100 - typedef enum _WIRELESS_MODE { WIRELESS_MODE_UNKNOWN = 0x00, WIRELESS_MODE_A = 0x01, @@ -503,7 +497,6 @@ typedef enum _WIRELESS_MODE { WIRELESS_MODE_N_5G = 0x20 } WIRELESS_MODE; - #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) typedef struct buffer { @@ -523,11 +516,6 @@ typedef struct rtl_reg_debug { unsigned char buf[0xff]; } rtl_reg_debug; - - - - - typedef struct _rt_9x_tx_rate_history { u32 cck[4]; u32 ofdm[8]; @@ -642,13 +630,11 @@ typedef struct Stats { u32 CurrentShowTxate; } Stats; - /* Bandwidth Offset */ #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 #define HAL_PRIME_CHNL_OFFSET_LOWER 1 #define HAL_PRIME_CHNL_OFFSET_UPPER 2 - typedef struct ChnlAccessSetting { u16 SIFS_Timer; u16 DIFS_Timer; @@ -757,7 +743,6 @@ typedef struct _ccktxbbgain_struct { u8 ccktxbb_valuearray[8]; } ccktxbbgain_struct, *pccktxbbgain_struct; - typedef struct _init_gain { u8 xaagccore1; u8 xbagccore1; @@ -793,7 +778,6 @@ typedef struct _phy_cck_rx_status_report_819xusb { u8 cck_agc_rpt; } phy_sts_cck_819xusb_t; - struct phy_ofdm_rx_status_rxsc_sgien_exintfflag { u8 reserved:4; u8 rxsc:2; @@ -885,7 +869,6 @@ typedef struct r8192_priv { short sens; short max_sens; - short up; /* If 1, allow bad crc frame, reception in monitor mode */ short crcmon; @@ -924,7 +907,6 @@ typedef struct r8192_priv { short tx_urb_index; atomic_t tx_pending[0x10]; /* UART_PRIORITY + 1 */ - struct tasklet_struct irq_rx_tasklet; struct urb *rxurb_task; @@ -937,7 +919,6 @@ typedef struct r8192_priv { u32 LastRxDescTSFHigh; u32 LastRxDescTSFLow; - /* Rx Related variables */ u16 EarlyRxThreshold; u32 ReceiveConfig; @@ -1172,5 +1153,4 @@ void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate); void EnableHWSecurityConfig8192(struct net_device *dev); void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); - #endif From 28a1fe524ac49590d052d4cf3b7aebef803d641d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:42 +0100 Subject: [PATCH 355/903] staging:rtl8192u: remove unused structure tx_desc_819x_usb_aggr_subframe Structure tx_desc_819x_usb_aggr_subframe is defined in a local header file but is not used outside of the header file. Removed from the code as a result. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index da23e7e9e3b9..a653a51f7b90 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -213,31 +213,6 @@ struct tx_desc_819x_usb { u32 Reserved7; }; -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE -typedef struct _tx_desc_819x_usb_aggr_subframe { - /* DWORD 0 */ - u16 PktSize; - u8 Offset; - u8 TxFWInfoSize; - - /* DWORD 1 */ - u8 RATid:3; - u8 DISFB:1; - u8 USERATE:1; - u8 MOREFRAG:1; - u8 NoEnc:1; - u8 PIFS:1; - u8 QueueSelect:5; - u8 NoACM:1; - u8 Reserved1:2; - u8 SecCAMID:5; - u8 SecDescAssign:1; - u8 SecType:2; - u8 PacketID:7; - u8 OWN:1; -} tx_desc_819x_usb_aggr_subframe, *ptx_desc_819x_usb_aggr_subframe; -#endif - typedef struct _tx_desc_cmd_819x_usb { /* DWORD 0 */ u16 Reserved0; @@ -374,9 +349,6 @@ typedef struct rx_drvinfo_819x_usb { #else #define MAX_TRANSMIT_BUFFER_SIZE 8000 #endif -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE -#define TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES (sizeof(tx_desc_819x_usb_aggr_subframe) + sizeof(tx_fwinfo_819x_usb)) -#endif /* Octets for crc32 (FCS, ICV) */ #define scrclng 4 From 6e5fde482be90222aad73e6566dcd9b3f9343b27 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:44 +0100 Subject: [PATCH 356/903] staging:rtl8192u: typedef struct tx_desc_cmd_819x_usb remove typedef Change structure tx_desc_cmd_819x_usb from being typedef to being a simple structure, without the typedef. checkpatch warns about defining new types in the code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 4 ++-- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index a653a51f7b90..f0dae8e9cd8f 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -213,7 +213,7 @@ struct tx_desc_819x_usb { u32 Reserved7; }; -typedef struct _tx_desc_cmd_819x_usb { +struct tx_desc_cmd_819x_usb { /* DWORD 0 */ u16 Reserved0; u8 Reserved1; @@ -238,7 +238,7 @@ typedef struct _tx_desc_cmd_819x_usb { u32 Reserved6; u32 Reserved7; u32 Reserved8; -} tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb; +}; typedef struct _tx_fwinfo_819x_usb { /* DOWRD 0 */ diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index a2a107521450..d7fa7ece62fb 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1242,7 +1242,7 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb) int status; struct urb *tx_urb; unsigned int idx_pipe; - tx_desc_cmd_819x_usb *pdesc = (tx_desc_cmd_819x_usb *)skb->data; + struct tx_desc_cmd_819x_usb *pdesc = (struct tx_desc_cmd_819x_usb *)skb->data; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; From ec65e266ae548ea560c7f109c3d9749abcc877b5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:45 +0100 Subject: [PATCH 357/903] staging:rtl8192u: typedef struct tx_fwinfo_819x_usb remove typedef Change structure tx_fwinfo_819x_usb from being typedef to being a simple structure, without the typedef. Clears the coding style issue flagged by checkpatch, (new type definitions) Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 6 +++--- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index f0dae8e9cd8f..d036040481fd 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -240,7 +240,7 @@ struct tx_desc_cmd_819x_usb { u32 Reserved8; }; -typedef struct _tx_fwinfo_819x_usb { +struct tx_fwinfo_819x_usb { /* DOWRD 0 */ u8 TxRate:7; u8 CtsEnable:1; @@ -271,7 +271,7 @@ typedef struct _tx_fwinfo_819x_usb { u32 TxAGCSign:1; u32 Tx_INFO_RSVD:6; u32 PacketID:13; -} tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb; +}; struct rtl8192_rx_info { struct urb *urb; @@ -342,7 +342,7 @@ typedef struct rx_drvinfo_819x_usb { #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) #define ENCRYPTION_MAX_OVERHEAD 128 #define USB_HWDESC_HEADER_LEN sizeof(struct tx_desc_819x_usb) -#define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb)) +#define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(struct tx_fwinfo_819x_usb)) #define MAX_FRAGMENT_COUNT 8 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE #define MAX_TRANSMIT_BUFFER_SIZE 32000 diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index d7fa7ece62fb..75bbcc115141 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1463,8 +1463,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) struct r8192_priv *priv = ieee80211_priv(dev); struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct tx_desc_819x_usb *tx_desc = (struct tx_desc_819x_usb *)skb->data; - tx_fwinfo_819x_usb *tx_fwinfo = - (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN); + struct tx_fwinfo_819x_usb *tx_fwinfo = + (struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN); struct usb_device *udev = priv->udev; int pend; int status; @@ -1489,7 +1489,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) } /* Fill Tx firmware info */ - memset(tx_fwinfo, 0, sizeof(tx_fwinfo_819x_usb)); + memset(tx_fwinfo, 0, sizeof(struct tx_fwinfo_819x_usb)); /* DWORD 0 */ tx_fwinfo->TxHT = (tcb_desc->data_rate & 0x80) ? 1 : 0; tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate); @@ -1539,7 +1539,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) /* DWORD 0 */ tx_desc->LINIP = 0; tx_desc->CmdInit = 1; - tx_desc->Offset = sizeof(tx_fwinfo_819x_usb) + 8; + tx_desc->Offset = sizeof(struct tx_fwinfo_819x_usb) + 8; tx_desc->PktSize = (skb->len - TX_PACKET_SHIFT_BYTES) & 0xffff; /*DWORD 1*/ @@ -1570,7 +1570,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) } tx_desc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index); - tx_desc->TxFWInfoSize = sizeof(tx_fwinfo_819x_usb); + tx_desc->TxFWInfoSize = sizeof(struct tx_fwinfo_819x_usb); tx_desc->DISFB = tcb_desc->bTxDisableRateFallBack; tx_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate; From 2541fcd9bb5b18156af908b0dfc37a94a6268d33 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:46 +0100 Subject: [PATCH 358/903] staging:rtl8192u: typedef struct rx_desc_819x_usb remove typedef Change structure rx_desc_819x_usb from being typedef to being a simple structure, without the typedef. Clears a checkpatch issue, definging new types in the code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 4 ++-- drivers/staging/rtl8192u/r8192U_core.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index d036040481fd..2bda7458f397 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -279,7 +279,7 @@ struct rtl8192_rx_info { u8 out_pipe; }; -typedef struct rx_desc_819x_usb { +struct rx_desc_819x_usb { /* DOWRD 0 */ u16 Length:14; u16 CRC32:1; @@ -292,7 +292,7 @@ typedef struct rx_desc_819x_usb { /* DWORD 1 */ u32 Reserved2; -} rx_desc_819x_usb, *prx_desc_819x_usb; +}; #ifdef USB_RX_AGGREGATION_SUPPORT typedef struct _rx_desc_819x_usb_aggr_subframe { diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 75bbcc115141..655aae06f8a4 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -739,7 +739,7 @@ static void rtl8192_rx_isr(struct urb *urb); static u32 get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats *pstats) { - return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize + return (sizeof(struct rx_desc_819x_usb) + pstats->RxDrvInfoSize + pstats->RxBufShift); } @@ -4633,7 +4633,7 @@ static void query_rxdesc_status(struct sk_buff *skb, rx_drvinfo_819x_usb *driver_info = NULL; /* Get Rx Descriptor Information */ - rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data; + struct rx_desc_819x_usb *desc = (struct rx_desc_819x_usb *)skb->data; stats->Length = desc->Length; stats->RxDrvInfoSize = desc->RxDrvInfoSize; @@ -4659,7 +4659,7 @@ static void query_rxdesc_status(struct sk_buff *skb, if (stats->RxDrvInfoSize != 0) { driver_info = (rx_drvinfo_819x_usb *)( skb->data - + sizeof(rx_desc_819x_usb) + + sizeof(struct rx_desc_819x_usb) + stats->RxBufShift ); /* unit: 0.5M */ @@ -4704,7 +4704,7 @@ static void query_rxdesc_status(struct sk_buff *skb, driver_info->FirstAGGR, driver_info->PartAggr); } - skb_pull(skb, sizeof(rx_desc_819x_usb)); + skb_pull(skb, sizeof(struct rx_desc_819x_usb)); /* Get Total offset of MPDU Frame Body */ if ((stats->RxBufShift + stats->RxDrvInfoSize) > 0) { stats->bShift = 1; @@ -4733,7 +4733,7 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) bool unicast_packet = false; /* 20 is for ps-poll */ - if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) { + if ((skb->len >= (20 + sizeof(struct rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) { /* first packet should not contain Rx aggregation header */ query_rxdesc_status(skb, &stats, false); /* TODO */ @@ -4809,7 +4809,7 @@ static void rtl819xusb_process_received_packet( static void query_rx_cmdpkt_desc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats) { - rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data; + struct rx_desc_819x_usb *desc = (struct rx_desc_819x_usb *)skb->data; /* Get Rx Descriptor Information */ stats->virtual_address = (u8 *)skb->data; @@ -4835,7 +4835,7 @@ static void rtl8192_rx_cmd(struct sk_buff *skb) .freq = IEEE80211_24GHZ_BAND, }; - if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) { + if ((skb->len >= (20 + sizeof(struct rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) { query_rx_cmdpkt_desc_status(skb, &stats); /* prfd->queue_id = 1; */ From 0fab863ecc551a5661ff5c5e5ae4d3ba7504ffc3 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:47 +0100 Subject: [PATCH 359/903] staging:rtl8192u: Remove struct rx_desc_819x_usb_aggr_subframe Removal of structure rx_desc_819x_usb_aggr_subframe from local header file, which is not used outside the header file. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 2bda7458f397..50aa082d3182 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -294,24 +294,6 @@ struct rx_desc_819x_usb { u32 Reserved2; }; -#ifdef USB_RX_AGGREGATION_SUPPORT -typedef struct _rx_desc_819x_usb_aggr_subframe { - /* DOWRD 0 */ - u16 Length:14; - u16 CRC32:1; - u16 ICV:1; - u8 Offset; - u8 RxDrvInfoSize; - /* DOWRD 1 */ - u8 Shift:2; - u8 PHYStatus:1; - u8 SWDec:1; - u8 Reserved1:4; - u8 Reserved2; - u16 Reserved3; -} rx_desc_819x_usb_aggr_subframe, *prx_desc_819x_usb_aggr_subframe; -#endif - typedef struct rx_drvinfo_819x_usb { /* DWORD 0 */ u16 Reserved1:12; From 6898f96695142c0d201ae59bd172236534b23ffe Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:48 +0100 Subject: [PATCH 360/903] staging:rtl8192u: remove typedef from struct rx_drvinfo_819x_usb Removed the typedef from the struct rx_drvinfo_819x_usb to leave it as a simple structure. This clears the issue flagged by checkpatch, defining new types. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 4 ++-- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 50aa082d3182..4b67783b617e 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -294,7 +294,7 @@ struct rx_desc_819x_usb { u32 Reserved2; }; -typedef struct rx_drvinfo_819x_usb { +struct rx_drvinfo_819x_usb { /* DWORD 0 */ u16 Reserved1:12; u16 PartAggr:1; @@ -315,7 +315,7 @@ typedef struct rx_drvinfo_819x_usb { /* DWORD 1 */ u32 TSFL; -} rx_drvinfo_819x_usb, *prx_drvinfo_819x_usb; +}; /* Support till 64 bit bus width OS */ #define MAX_DEV_ADDR_SIZE 8 diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 655aae06f8a4..c01e8d76a265 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -4194,7 +4194,7 @@ static inline bool rx_hal_is_cck_rate(struct rx_drvinfo_819x_usb *pdrvinfo) static void rtl8192_query_rxphystatus(struct r8192_priv *priv, struct ieee80211_rx_stats *pstats, - rx_drvinfo_819x_usb *pdrvinfo, + struct rx_drvinfo_819x_usb *pdrvinfo, struct ieee80211_rx_stats *precord_stats, bool bpacket_match_bssid, bool bpacket_toself, @@ -4231,7 +4231,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, prxpkt = (u8 *)pdrvinfo; /* Move pointer to the 16th bytes. Phy status start address. */ - prxpkt += sizeof(rx_drvinfo_819x_usb); + prxpkt += sizeof(struct rx_drvinfo_819x_usb); /* Initial the cck and ofdm buffer pointer */ pcck_buf = (phy_sts_cck_819xusb_t *)prxpkt; @@ -4431,7 +4431,7 @@ static void rtl8192_record_rxdesc_forlateruse( static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, struct ieee80211_rx_stats *pstats, - rx_drvinfo_819x_usb *pdrvinfo) + struct rx_drvinfo_819x_usb *pdrvinfo) { /* TODO: We must only check packet for current MAC address. * Not finish @@ -4630,7 +4630,7 @@ static void query_rxdesc_status(struct sk_buff *skb, struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; struct net_device *dev = info->dev; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - rx_drvinfo_819x_usb *driver_info = NULL; + struct rx_drvinfo_819x_usb *driver_info = NULL; /* Get Rx Descriptor Information */ struct rx_desc_819x_usb *desc = (struct rx_desc_819x_usb *)skb->data; @@ -4657,7 +4657,7 @@ static void query_rxdesc_status(struct sk_buff *skb, * Driver info are written to the RxBuffer following rx desc */ if (stats->RxDrvInfoSize != 0) { - driver_info = (rx_drvinfo_819x_usb *)( + driver_info = (struct rx_drvinfo_819x_usb *)( skb->data + sizeof(struct rx_desc_819x_usb) + stats->RxBufShift From 704719d6cde0be9aaacdb64c4eacdb1b99838fea Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 11 Jul 2018 20:21:49 +0100 Subject: [PATCH 361/903] staging:rtl8192u: Change struct r8192_priv member Rf_Mode from u8 > enum The file r8192U.h defines the structure for holding private data for the driver (typedef struct r8192_priv). This structure includes a member Rf_Mode which is defined to be of type "u8". Whilst the variable Rf_Mode is defined to be of type "u8" it is being assigned enumerated values defined by the enumerated type "enum rf_op_type". Because of the mismatch in types being used any advantage of using an enumerated type, to have the compiler check assignments, is nullified. This patch changes the type of the Rf_Mode member from a u8 to the enumerated type "enum rf_op_type", so that the compiler can now check assignments. This change of type would cause a problem if the structure was mapped from a hardware device and the size and location of members was significant. I believe that the structure to hold private data for the driver is allocated from memory and populated with data in the function rtl8192_usb_probe() in the file r8192U_core.c. As such the physical size of the member variable Rf_Mode is not significant, so the change should have no impact on code execution, bar the move from a u8 type to an int, (or whatever size compiler uses for enum). Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 4b67783b617e..98b6bf7985f7 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -334,11 +334,12 @@ struct rx_drvinfo_819x_usb { /* Octets for crc32 (FCS, ICV) */ #define scrclng 4 -typedef enum rf_optype { +enum rf_op_type { RF_OP_By_SW_3wire = 0, RF_OP_By_FW, RF_OP_MAX -} rf_op_type; +}; + /* 8190 Loopback Mode definition */ typedef enum _rtl819xUsb_loopback { RTL819xU_NO_LOOPBACK = 0, @@ -894,7 +895,7 @@ typedef struct r8192_priv { u8 slot_time; bool bDcut; bool bCurrentRxAggrEnable; - u8 Rf_Mode; /* For Firmware RF -R/W switch */ + enum rf_op_type Rf_Mode; /* For Firmware RF -R/W switch */ prt_firmware pFirmware; rtl819xUsb_loopback_e LoopbackMode; u16 EEPROMTxPowerDiff; From 5e53b6c871520376edad8bcfc423c2181f13e169 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Jul 2018 12:36:06 +0200 Subject: [PATCH 362/903] staging: rtl8723bs: remove unused code Remove commented rtw_is_cckrates_included() and rtw_is_cckratesonly_included() from os_dep/ioctl_linux.c. Both are defined in core/rtw_ieee80211.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index ceb2b10fa0b2..63b79a7eaccf 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -79,38 +79,6 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter) eth_zero_addr(wrqu.ap_addr.sa_data); } -/* -uint rtw_is_cckrates_included(u8 *rate) -{ - u32 i = 0; - - while (rate[i]!= 0) - { - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) - return true; - i++; - } - - return false; -} - -uint rtw_is_cckratesonly_included(u8 *rate) -{ - u32 i = 0; - - while (rate[i]!= 0) - { - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) - return false; - i++; - } - - return true; -} -*/ - static char *translate_scan(struct adapter *padapter, struct iw_request_info* info, struct wlan_network *pnetwork, char *start, char *stop) From c53578cd0ba8251304560c818c558b32a23217aa Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Jul 2018 12:36:07 +0200 Subject: [PATCH 363/903] staging: rtl8723bs: refactor rtw_is_cckrates_included() Refactor rtw_is_cckrates_included() to improve readability and slightly reduce object file size. Suggested-by: Joe Perches Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 3f1c7bb0eb9f..3adb58759d5f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -68,13 +68,12 @@ int rtw_get_bit_value_from_ieee_value(u8 val) uint rtw_is_cckrates_included(u8 *rate) { - u32 i = 0; + while (*rate) { + u8 r = *rate & 0x7f; - while (rate[i] != 0) { - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + if (r == 2 || r == 4 || r == 11 || r == 22) return true; - i++; + rate++; } return false; From 4f2a3d835dbd971224c4c6ff2e715e1056659d10 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Jul 2018 12:36:08 +0200 Subject: [PATCH 364/903] staging: rtl8723bs: refactor rtw_is_cckratesonly_included Refactor rtw_is_cckratesonly_included() to improve readability and slightly reduce object file size. Suggested-by: Joe Perches Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 3adb58759d5f..e4a20a4a5e59 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -81,13 +81,12 @@ uint rtw_is_cckrates_included(u8 *rate) uint rtw_is_cckratesonly_included(u8 *rate) { - u32 i = 0; + while (*rate) { + u8 r = *rate & 0x7f; - while (rate[i] != 0) { - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + if (r != 2 && r != 4 && r != 11 && r != 22) return false; - i++; + rate++; } return true; From 6bf4d28ea1f438256983376b1f58f588a57161ec Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Jul 2018 12:36:09 +0200 Subject: [PATCH 365/903] staging: rtl8723bs: change return type to bool Both rtw_is_cckrates_included() and rtw_is_cckratesonly_included() return true or false. Change the return type from uint to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index e4a20a4a5e59..62718045f3cc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -66,7 +66,7 @@ int rtw_get_bit_value_from_ieee_value(u8 val) return 0; } -uint rtw_is_cckrates_included(u8 *rate) +bool rtw_is_cckrates_included(u8 *rate) { while (*rate) { u8 r = *rate & 0x7f; @@ -79,7 +79,7 @@ uint rtw_is_cckrates_included(u8 *rate) return false; } -uint rtw_is_cckratesonly_included(u8 *rate) +bool rtw_is_cckratesonly_included(u8 *rate) { while (*rate) { u8 r = *rate & 0x7f; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 974e922f54fa..bcc8dfa8e672 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -1169,9 +1169,9 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv); int rtw_get_bit_value_from_ieee_value(u8 val); -uint rtw_is_cckrates_included(u8 *rate); +bool rtw_is_cckrates_included(u8 *rate); -uint rtw_is_cckratesonly_included(u8 *rate); +bool rtw_is_cckratesonly_included(u8 *rate); int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); From 153c6b11eb40e93c5a9cabd63ffebde37e7661f8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Jul 2018 12:36:10 +0200 Subject: [PATCH 366/903] staging: rtl8723bs: fix comparsions to true Use if(x) instead of if(x == true). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_ieee80211.c | 6 ++-- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 28 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 62718045f3cc..33f2649ba2ec 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -95,14 +95,14 @@ bool rtw_is_cckratesonly_included(u8 *rate) int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) { if (channel > 14) { - if ((rtw_is_cckrates_included(rate)) == true) + if (rtw_is_cckrates_included(rate)) return WIRELESS_INVALID; else return WIRELESS_11A; } else{ /* could be pure B, pure G, or B/G */ - if ((rtw_is_cckratesonly_included(rate)) == true) + if (rtw_is_cckratesonly_included(rate)) return WIRELESS_11B; - else if ((rtw_is_cckrates_included(rate)) == true) + else if (rtw_is_cckrates_included(rate)) return WIRELESS_11BG; else return WIRELESS_11G; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 63b79a7eaccf..c38298d960ff 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -126,26 +126,26 @@ static char *translate_scan(struct adapter *padapter, /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates)) == true) { - if (ht_cap == true) + if (rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates)) { + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); - } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates)) == true) { - if (ht_cap == true) + } else if (rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates)) { + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); } else { if (pnetwork->network.Configuration.DSConfig > 14) { - if (vht_cap == true) + if (vht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11AC"); - else if (ht_cap == true) + else if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); } else { - if (ht_cap == true) + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); @@ -785,26 +785,26 @@ static int rtw_wx_get_name(struct net_device *dev, prates = &pcur_bss->SupportedRates; - if (rtw_is_cckratesonly_included((u8 *)prates) == true) { - if (ht_cap == true) + if (rtw_is_cckratesonly_included((u8 *)prates)) { + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); - } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) { - if (ht_cap == true) + } else if (rtw_is_cckrates_included((u8 *)prates)) { + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { if (pcur_bss->Configuration.DSConfig > 14) { - if (vht_cap == true) + if (vht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11AC"); - else if (ht_cap == true) + else if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); } else { - if (ht_cap == true) + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); From 4162433ac98e07501e42dccd176ae846dedc0e21 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:22:59 +0100 Subject: [PATCH 367/903] staging:rtl8192u: remove typedef of enumeration SwChnlCmdID - Style To clear a checkpatch issue removed the typedef of the enumeration SwChnlCmdID this should not impact runtime code as it's only a coding style change. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- drivers/staging/rtl8192u/r819xU_phy.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 98cfc222e241..bc86e6bfb8f5 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1221,7 +1221,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, * notice: ******************************************************************************/ static u8 rtl8192_phy_SetSwChnlCmdArray(SwChnlCmd *CmdTable, u32 CmdTableIdx, - u32 CmdTableSz, SwChnlCmdID CmdID, + u32 CmdTableSz, enum SwChnlCmdID CmdID, u32 Para1, u32 Para2, u32 msDelay) { SwChnlCmd *pCmd; diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index d2e69228ac8a..4471a0e00936 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -7,7 +7,7 @@ #define MAX_RFDEPENDCMD_CNT 16 #define MAX_POSTCMD_CNT 16 -typedef enum _SwChnlCmdID { +enum SwChnlCmdID { CmdID_End, CmdID_SetTxPowerLevel, CmdID_BBRegWrite10, @@ -15,15 +15,15 @@ typedef enum _SwChnlCmdID { CmdID_WritePortUshort, CmdID_WritePortUchar, CmdID_RF_WriteReg, -} SwChnlCmdID; +}; /* -----------------------Define structure---------------------- */ /* 1. Switch channel related */ typedef struct _SwChnlCmd { - SwChnlCmdID CmdID; - u32 Para1; - u32 Para2; - u32 msDelay; + enum SwChnlCmdID CmdID; + u32 Para1; + u32 Para2; + u32 msDelay; } __packed SwChnlCmd; extern u32 rtl819XMACPHY_Array_PG[]; From 983e14e25443d63adf228bc0c60f1bfa2a814166 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:00 +0100 Subject: [PATCH 368/903] staging:rtl8192u: remove typdef from enumeration HW90_BLOCK_E - Style Checkpatch warns about the creation of new types in code. This patch simply removes the typedef from the enumeration HW90_BLOCK_E to clear this warning. There should be no impact on run time code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 6 +++--- drivers/staging/rtl8192u/r819xU_phy.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index bc86e6bfb8f5..0462de662eff 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -695,7 +695,7 @@ static void rtl8192_InitBBRFRegDef(struct net_device *dev) * return: return whether BB and RF is ok (0:OK, 1:Fail) * notice: This function may be removed in the ASIC ******************************************************************************/ -u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, HW90_BLOCK_E CheckBlock, +u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath) { u8 ret = 0; @@ -787,10 +787,10 @@ static void rtl8192_BB_Config_ParaFile(struct net_device *dev) /* ----Ckeck FPGAPHY0 and PHY1 board is OK---- */ /* TODO: this function should be removed on ASIC */ - for (eCheckItem = (HW90_BLOCK_E)HW90_BLOCK_PHY0; + for (eCheckItem = (enum HW90_BLOCK_E)HW90_BLOCK_PHY0; eCheckItem <= HW90_BLOCK_PHY1; eCheckItem++) { /* don't care RF path */ - status = rtl8192_phy_checkBBAndRF(dev, (HW90_BLOCK_E)eCheckItem, + status = rtl8192_phy_checkBBAndRF(dev, (enum HW90_BLOCK_E)eCheckItem, (RF90_RADIO_PATH_E)0); if (status != 0) { RT_TRACE((COMP_ERR | COMP_PHY), diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 4471a0e00936..0f680a04a468 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -34,13 +34,13 @@ extern u32 rtl819XRadioB_Array[]; extern u32 rtl819XRadioC_Array[]; extern u32 rtl819XRadioD_Array[]; -typedef enum _HW90_BLOCK { +enum HW90_BLOCK_E { HW90_BLOCK_MAC = 0, HW90_BLOCK_PHY0 = 1, HW90_BLOCK_PHY1 = 2, HW90_BLOCK_RF = 3, HW90_BLOCK_MAXIMUM = 4, /* Never use this */ -} HW90_BLOCK_E, *PHW90_BLOCK_E; +}; typedef enum _RF90_RADIO_PATH { RF90_PATH_A = 0, /* Radio Path A */ @@ -69,7 +69,7 @@ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, void rtl8192_phy_configmac(struct net_device *dev); void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, - HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); + enum HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); void rtl8192_BBConfig(struct net_device *dev); void rtl8192_phy_getTxPower(struct net_device *dev); void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); From 8b5c53e62c98e52b555feb52ff8fa8fc913141e7 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:01 +0100 Subject: [PATCH 369/903] staging:rtl8192u: Remove typdef from enumeration RF90_RADIO_PATH_E - Style Checkpatch warns about the creation of new types. This patch simply removes the typedef from the enumeration RF90_RADIO_PATH_E to clear this checkpatch warning. There should be no impact on run time code execution, as this is a coding style issue only. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8190_rtl8256.c | 42 ++++++++++++------------ drivers/staging/rtl8192u/r8192U_core.c | 4 +-- drivers/staging/rtl8192u/r819xU_phy.c | 31 ++++++++++------- drivers/staging/rtl8192u/r819xU_phy.h | 15 +++++---- 4 files changed, 51 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c index 02bdd933f05b..9f35dcb9e13e 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.c +++ b/drivers/staging/rtl8192u/r8190_rtl8256.c @@ -41,16 +41,16 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, enum ht_channel_width Bandwi || priv->card_8192_version == VERSION_819xU_B) { /* 8256 D-cut, E-cut, xiong: consider it later! */ rtl8192_phy_SetRFReg(dev, - (RF90_RADIO_PATH_E)eRFPath, + (enum RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x100); /* phy para:1ba */ rtl8192_phy_SetRFReg(dev, - (RF90_RADIO_PATH_E)eRFPath, + (enum RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3d7); rtl8192_phy_SetRFReg(dev, - (RF90_RADIO_PATH_E)eRFPath, + (enum RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x021); rtl8192_phy_SetRFReg(dev, - (RF90_RADIO_PATH_E)eRFPath, + (enum RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab); } else { RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); @@ -58,15 +58,15 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, enum ht_channel_width Bandwi break; case HT_CHANNEL_WIDTH_20_40: if (priv->card_8192_version == VERSION_819xU_A || priv->card_8192_version == VERSION_819xU_B) { /* 8256 D-cut, E-cut, xiong: consider it later! */ - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); /* phy para:3ba */ - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3df); - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0a1); + rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); /* phy para:3ba */ + rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3df); + rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0a1); if (priv->chan == 3 || priv->chan == 9) /* I need to set priv->chan whenever current channel changes */ - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x59b); + rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x59b); else - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab); + rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab); } else { RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); } @@ -115,14 +115,14 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; /* Initialize RF */ - for (eRFPath = (RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath < priv->NumTotalRFPath; eRFPath++) { + for (eRFPath = (enum RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; pPhyReg = &priv->PHYRegDef[eRFPath]; /* Joseph test for shorten RF config - * pHalData->RfReg0Value[eRFPath] = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, rGlobalCtrl, bMaskDWord); + * pHalData->RfReg0Value[eRFPath] = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, rGlobalCtrl, bMaskDWord); * ----Store original RFENV control type */ switch (eRFPath) { @@ -146,12 +146,12 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258 */ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for Z-serial and 8258, and set 1 to 14 bits for ??? */ - rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf); + rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf); /* Check RF block (for FPGA platform only)---- * TODO: this function should be removed on ASIC , Emily 2007.2.2 */ - if (rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (RF90_RADIO_PATH_E)eRFPath)) { + if (rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum RF90_RADIO_PATH_E)eRFPath)) { RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -162,32 +162,32 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) switch (eRFPath) { case RF90_PATH_A: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_B: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_C: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_D: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index c01e8d76a265..cf39c0bc2a26 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2897,7 +2897,7 @@ static bool rtl8192_adapter_start(struct net_device *dev) */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) PHY_SetRFReg(Adapter, - (RF90_RADIO_PATH_E)eRFPath, + (enum RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0); } else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) { /* H/W or S/W RF OFF before sleep. */ @@ -2923,7 +2923,7 @@ static bool rtl8192_adapter_start(struct net_device *dev) */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) PHY_SetRFReg(Adapter, - (RF90_RADIO_PATH_E)eRFPath, + (enum RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0); } } diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 0462de662eff..3df4775e1f99 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -108,11 +108,13 @@ u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask) return (reg & bitmask) >> bitshift; } -static u32 phy_FwRFSerialRead(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum RF90_RADIO_PATH_E eRFPath, u32 offset); static void phy_FwRFSerialWrite(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath, u32 offset, + enum RF90_RADIO_PATH_E eRFPath, + u32 offset, u32 data); /****************************************************************************** @@ -130,7 +132,7 @@ static void phy_FwRFSerialWrite(struct net_device *dev, * ---need more spec for this information. ******************************************************************************/ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath, u32 offset) + enum RF90_RADIO_PATH_E eRFPath, u32 offset) { struct r8192_priv *priv = ieee80211_priv(dev); u32 ret = 0; @@ -215,7 +217,8 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, * --------------------------------------------------------------------------- *****************************************************************************/ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath, u32 offset, + enum RF90_RADIO_PATH_E eRFPath, + u32 offset, u32 data) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -279,7 +282,8 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, * return: none * notice: *****************************************************************************/ -void rtl8192_phy_SetRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, +void rtl8192_phy_SetRFReg(struct net_device *dev, + enum RF90_RADIO_PATH_E eRFPath, u32 reg_addr, u32 bitmask, u32 data) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -327,7 +331,8 @@ void rtl8192_phy_SetRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, * return: u32 data //the readback register value * notice: *****************************************************************************/ -u32 rtl8192_phy_QueryRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, +u32 rtl8192_phy_QueryRFReg(struct net_device *dev, + enum RF90_RADIO_PATH_E eRFPath, u32 reg_addr, u32 bitmask) { u32 reg, bitshift; @@ -357,7 +362,8 @@ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, * return: u32 * notice: ****************************************************************************/ -static u32 phy_FwRFSerialRead(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum RF90_RADIO_PATH_E eRFPath, u32 offset) { u32 reg = 0; @@ -422,7 +428,8 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, * notice: ****************************************************************************/ static void phy_FwRFSerialWrite(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath, u32 offset, u32 data) + enum RF90_RADIO_PATH_E eRFPath, + u32 offset, u32 data) { u8 time = 0; u32 tmp; @@ -696,7 +703,7 @@ static void rtl8192_InitBBRFRegDef(struct net_device *dev) * notice: This function may be removed in the ASIC ******************************************************************************/ u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum HW90_BLOCK_E CheckBlock, - RF90_RADIO_PATH_E eRFPath) + enum RF90_RADIO_PATH_E eRFPath) { u8 ret = 0; u32 i, CheckTimes = 4, reg = 0; @@ -791,7 +798,7 @@ static void rtl8192_BB_Config_ParaFile(struct net_device *dev) eCheckItem <= HW90_BLOCK_PHY1; eCheckItem++) { /* don't care RF path */ status = rtl8192_phy_checkBBAndRF(dev, (enum HW90_BLOCK_E)eCheckItem, - (RF90_RADIO_PATH_E)0); + (enum RF90_RADIO_PATH_E)0); if (status != 0) { RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config(): Check PHY%d Fail!!\n", @@ -969,7 +976,7 @@ void rtl8192_phy_updateInitGain(struct net_device *dev) * notice: Delay may be required for RF configuration *****************************************************************************/ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath) + enum RF90_RADIO_PATH_E eRFPath) { int i; @@ -1387,7 +1394,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, case CmdID_RF_WriteReg: for (eRFPath = 0; eRFPath < RF90_PATH_MAX; eRFPath++) { rtl8192_phy_SetRFReg(dev, - (RF90_RADIO_PATH_E)eRFPath, + (enum RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, bZebra1_ChannelNum, CurrentCmd->Para2); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 0f680a04a468..d93da2360649 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -42,13 +42,13 @@ enum HW90_BLOCK_E { HW90_BLOCK_MAXIMUM = 4, /* Never use this */ }; -typedef enum _RF90_RADIO_PATH { +enum RF90_RADIO_PATH_E { RF90_PATH_A = 0, /* Radio Path A */ RF90_PATH_B = 1, /* Radio Path B */ RF90_PATH_C = 2, /* Radio Path C */ RF90_PATH_D = 3, /* Radio Path D */ RF90_PATH_MAX /* Max RF number 92 support */ -} RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E; +}; #define bMaskByte0 0xff #define bMaskByte1 0xff00 @@ -62,21 +62,24 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath); void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr, u32 bitmask, u32 data); u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask); -void rtl8192_phy_SetRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, +void rtl8192_phy_SetRFReg(struct net_device *dev, + enum RF90_RADIO_PATH_E eRFPath, u32 reg_addr, u32 bitmask, u32 data); -u32 rtl8192_phy_QueryRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, +u32 rtl8192_phy_QueryRFReg(struct net_device *dev, + enum RF90_RADIO_PATH_E eRFPath, u32 reg_addr, u32 bitmask); void rtl8192_phy_configmac(struct net_device *dev); void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, - enum HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); + enum HW90_BLOCK_E CheckBlock, + enum RF90_RADIO_PATH_E eRFPath); void rtl8192_BBConfig(struct net_device *dev); void rtl8192_phy_getTxPower(struct net_device *dev); void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); void rtl8192_phy_RFConfig(struct net_device *dev); void rtl8192_phy_updateInitGain(struct net_device *dev); u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath); + enum RF90_RADIO_PATH_E eRFPath); u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); void rtl8192_SetBWMode(struct net_device *dev, From 9821cb6d9bcad7144f0596d39a97b99dd9318600 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:02 +0100 Subject: [PATCH 370/903] staging:rtl8192u: remove typedef from structure SwChnlCmd - Style Checkpatch warns against creation of new types in code. This patch simply removes the "typedef" declaration of the structure SwChnlCmd to clear this issue. Simple coding style issue which should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 20 ++++++++++---------- drivers/staging/rtl8192u/r819xU_phy.h | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 3df4775e1f99..d88f6c3ed46f 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1227,11 +1227,11 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, * return: true if finished, false otherwise * notice: ******************************************************************************/ -static u8 rtl8192_phy_SetSwChnlCmdArray(SwChnlCmd *CmdTable, u32 CmdTableIdx, +static u8 rtl8192_phy_SetSwChnlCmdArray(struct SwChnlCmd *CmdTable, u32 CmdTableIdx, u32 CmdTableSz, enum SwChnlCmdID CmdID, u32 Para1, u32 Para2, u32 msDelay) { - SwChnlCmd *pCmd; + struct SwChnlCmd *pCmd; if (CmdTable == NULL) { RT_TRACE(COMP_ERR, "%s(): CmdTable cannot be NULL\n", __func__); @@ -1268,14 +1268,14 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, u8 *step, u32 *delay) { struct r8192_priv *priv = ieee80211_priv(dev); - SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT]; - u32 PreCommonCmdCnt; - SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT]; - u32 PostCommonCmdCnt; - SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; - u32 RfDependCmdCnt; - SwChnlCmd *CurrentCmd = NULL; - u8 eRFPath; + struct SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT]; + u32 PreCommonCmdCnt; + struct SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT]; + u32 PostCommonCmdCnt; + struct SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; + u32 RfDependCmdCnt; + struct SwChnlCmd *CurrentCmd = NULL; + u8 eRFPath; RT_TRACE(COMP_CH, "%s() stage: %d, step: %d, channel: %d\n", __func__, *stage, *step, channel); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index d93da2360649..a02e1e0ea643 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -19,12 +19,12 @@ enum SwChnlCmdID { /* -----------------------Define structure---------------------- */ /* 1. Switch channel related */ -typedef struct _SwChnlCmd { +struct SwChnlCmd { enum SwChnlCmdID CmdID; u32 Para1; u32 Para2; u32 msDelay; -} __packed SwChnlCmd; +} __packed; extern u32 rtl819XMACPHY_Array_PG[]; extern u32 rtl819XPHY_REG_1T2RArray[]; From 2dad9cba09036f614f39e4c1be258d7ed78d591d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:03 +0100 Subject: [PATCH 371/903] staging:rtl8192u: Rename SwChnlCmdID > switch_chan_cmd_id - Coding Style Rename enumerated type to clear a CamelCase warning from checkpatch. The change is style only. No impact on run time execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 4 ++-- drivers/staging/rtl8192u/r819xU_phy.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index d88f6c3ed46f..c373dbe06154 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1219,7 +1219,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, * input: SwChnlCmd *CmdTable //table to be set * u32 CmdTableIdx //variable index in table to be set * u32 CmdTableSz //table size - * SwChnlCmdID CmdID //command ID to set + * switch_chan_cmd_id CmdID //command ID to set * u32 Para1 * u32 Para2 * u32 msDelay @@ -1228,7 +1228,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, * notice: ******************************************************************************/ static u8 rtl8192_phy_SetSwChnlCmdArray(struct SwChnlCmd *CmdTable, u32 CmdTableIdx, - u32 CmdTableSz, enum SwChnlCmdID CmdID, + u32 CmdTableSz, enum switch_chan_cmd_id CmdID, u32 Para1, u32 Para2, u32 msDelay) { struct SwChnlCmd *pCmd; diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index a02e1e0ea643..0c63c646b625 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -7,7 +7,7 @@ #define MAX_RFDEPENDCMD_CNT 16 #define MAX_POSTCMD_CNT 16 -enum SwChnlCmdID { +enum switch_chan_cmd_id { CmdID_End, CmdID_SetTxPowerLevel, CmdID_BBRegWrite10, @@ -20,7 +20,7 @@ enum SwChnlCmdID { /* -----------------------Define structure---------------------- */ /* 1. Switch channel related */ struct SwChnlCmd { - enum SwChnlCmdID CmdID; + enum switch_chan_cmd_id CmdID; u32 Para1; u32 Para2; u32 msDelay; From 8772da06f6d01636a9c6e0fb7634c19c1be9d6e5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:04 +0100 Subject: [PATCH 372/903] staging:rtl8192u: Rename enum label CmdID_End > CMD_ID_END - Style Rename enum label to clear a CamelCase warning from checkpatch. This is a simple style change and should not impact execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 10 +++++----- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index c373dbe06154..c67159f2d9ab 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1295,13 +1295,13 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, MAX_PRECMD_CNT, CmdID_SetTxPowerLevel, 0, 0, 0); rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, - MAX_PRECMD_CNT, CmdID_End, 0, 0, 0); + MAX_PRECMD_CNT, CMD_ID_END, 0, 0, 0); /* <2> Fill up post common command. */ PostCommonCmdCnt = 0; rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, - MAX_POSTCMD_CNT, CmdID_End, 0, 0, 0); + MAX_POSTCMD_CNT, CMD_ID_END, 0, 0, 0); /* <3> Fill up RF dependent command. */ RfDependCmdCnt = 0; @@ -1321,7 +1321,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, 10); rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_End, 0, 0, 0); + CMD_ID_END, 0, 0, 0); break; case RF_8256: @@ -1338,7 +1338,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, rZebra1_Channel, channel, 10); rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_End, 0, 0, 0); + CMD_ID_END, 0, 0, 0); break; case RF_8258: @@ -1363,7 +1363,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, break; } - if (CurrentCmd->CmdID == CmdID_End) { + if (CurrentCmd->CmdID == CMD_ID_END) { if ((*stage) == 2) { (*delay) = CurrentCmd->msDelay; return true; diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 0c63c646b625..efbca1f458f5 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -8,7 +8,7 @@ #define MAX_POSTCMD_CNT 16 enum switch_chan_cmd_id { - CmdID_End, + CMD_ID_END, CmdID_SetTxPowerLevel, CmdID_BBRegWrite10, CmdID_WritePortUlong, From 1be8f4e7588f5f4272baac097f61396eeb513183 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:05 +0100 Subject: [PATCH 373/903] staging:rtl8192u: rename CmdID_SetTxPowerLevel > CMD_ID_SET_TX_PWR_LEVEL Rename enumeration label CmdID_SetTxPowerLevel to CMD_ID_SET_TX_PWR_LEVEL. This change clears a checkpatch warning on CamelCase. The change should not impact runtime execution, style change only. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 4 ++-- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index c67159f2d9ab..0b850abe3533 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1292,7 +1292,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, /* <1> Fill up pre common command. */ PreCommonCmdCnt = 0; rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, - MAX_PRECMD_CNT, CmdID_SetTxPowerLevel, + MAX_PRECMD_CNT, CMD_ID_SET_TX_PWR_LEVEL, 0, 0, 0); rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, CMD_ID_END, 0, 0, 0); @@ -1374,7 +1374,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, } switch (CurrentCmd->CmdID) { - case CmdID_SetTxPowerLevel: + case CMD_ID_SET_TX_PWR_LEVEL: if (priv->card_8192_version == (u8)VERSION_819xU_A) /* consider it later! */ rtl8192_SetTxPowerLevel(dev, channel); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index efbca1f458f5..91b2e9e39368 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -9,7 +9,7 @@ enum switch_chan_cmd_id { CMD_ID_END, - CmdID_SetTxPowerLevel, + CMD_ID_SET_TX_PWR_LEVEL, CmdID_BBRegWrite10, CmdID_WritePortUlong, CmdID_WritePortUshort, From 3a11b1948981abea8fae00e0fbed418fd169b1c2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:06 +0100 Subject: [PATCH 374/903] staging:rtl8192u: Remove unused enum label CmdID_BBRegWrite10 The enum label CmdID_BBRegWrite10 is not used in the code, so removed from the source code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 91b2e9e39368..d69b03ce7bd9 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -10,7 +10,6 @@ enum switch_chan_cmd_id { CMD_ID_END, CMD_ID_SET_TX_PWR_LEVEL, - CmdID_BBRegWrite10, CmdID_WritePortUlong, CmdID_WritePortUshort, CmdID_WritePortUchar, From 3ebdf34f548141d1d7f3a69c10b590789a0e5411 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:07 +0100 Subject: [PATCH 375/903] staging:rtl8192u: Rename CmdID_WritePortUlong > CMD_ID_WRITE_PORT_ULONG Rename enum label CmdID_WritePortUlong to CMD_ID_WRITE_PORT_ULONG to clear the checkpatch CamelCase issue. Simple syle change which should not impact code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 0b850abe3533..a10d3455b1f8 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1379,7 +1379,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, /* consider it later! */ rtl8192_SetTxPowerLevel(dev, channel); break; - case CmdID_WritePortUlong: + case CMD_ID_WRITE_PORT_ULONG: write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2); break; diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index d69b03ce7bd9..95250ac4764e 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -10,7 +10,7 @@ enum switch_chan_cmd_id { CMD_ID_END, CMD_ID_SET_TX_PWR_LEVEL, - CmdID_WritePortUlong, + CMD_ID_WRITE_PORT_ULONG, CmdID_WritePortUshort, CmdID_WritePortUchar, CmdID_RF_WriteReg, From 61c9f41b317500d95e562726d15c640ce5b4de76 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:08 +0100 Subject: [PATCH 376/903] staging:rtl8192u: Rename CmdID_WritePortUshort > CMD_ID_WRITE_PORT_USHORT Rename the enum label CmdID_WritePortUshort to CMD_ID_WRITE_PORT_USHORT to clear the checkpatch warning on CamelCase naming. This is a coding style change only and should not impact code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index a10d3455b1f8..a681e7eab219 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1383,7 +1383,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2); break; - case CmdID_WritePortUshort: + case CMD_ID_WRITE_PORT_USHORT: write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2); break; diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 95250ac4764e..45372a2ff7c5 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -11,7 +11,7 @@ enum switch_chan_cmd_id { CMD_ID_END, CMD_ID_SET_TX_PWR_LEVEL, CMD_ID_WRITE_PORT_ULONG, - CmdID_WritePortUshort, + CMD_ID_WRITE_PORT_USHORT, CmdID_WritePortUchar, CmdID_RF_WriteReg, }; From 64641cf65eed2f6f4f52d5d76e03482accdb1699 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:09 +0100 Subject: [PATCH 377/903] staging:rtl8192u: Rename CmdID_WritePortUchar > CMD_ID_WRITE_PORT_UCHAR Rename the enum label CmdID_WritePortUchar to CMD_ID_WRITE_PORT_UCHAR, to clear the checkpatch issue with CamelCase. The change is a coding style change only and should not impact code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 2 +- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index a681e7eab219..6c57c38dc9fe 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1387,7 +1387,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2); break; - case CmdID_WritePortUchar: + case CMD_ID_WRITE_PORT_UCHAR: write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2); break; diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 45372a2ff7c5..1496f74768c9 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -12,7 +12,7 @@ enum switch_chan_cmd_id { CMD_ID_SET_TX_PWR_LEVEL, CMD_ID_WRITE_PORT_ULONG, CMD_ID_WRITE_PORT_USHORT, - CmdID_WritePortUchar, + CMD_ID_WRITE_PORT_UCHAR, CmdID_RF_WriteReg, }; From f6e1472ae3b14a1e9b19ad1f9bebdfad769c9c25 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:10 +0100 Subject: [PATCH 378/903] staging:rtl8192u: Rename CmdID_RF_WriteReg > CMD_ID_RF_WRITE_REG - Style Rename enum label CmdID_RF_WriteReg to CMD_ID_RF_WRITE_REG. This change clears the checkpatch issue with CamelCase. The change is style only and should not impact code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 6 +++--- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 6c57c38dc9fe..75fcd3134b6d 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1315,7 +1315,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, } rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, + CMD_ID_RF_WRITE_REG, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); @@ -1334,7 +1334,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, } rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, + CMD_ID_RF_WRITE_REG, rZebra1_Channel, channel, 10); rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, @@ -1391,7 +1391,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2); break; - case CmdID_RF_WriteReg: + case CMD_ID_RF_WRITE_REG: for (eRFPath = 0; eRFPath < RF90_PATH_MAX; eRFPath++) { rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 1496f74768c9..75aa56ddd22f 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -13,7 +13,7 @@ enum switch_chan_cmd_id { CMD_ID_WRITE_PORT_ULONG, CMD_ID_WRITE_PORT_USHORT, CMD_ID_WRITE_PORT_UCHAR, - CmdID_RF_WriteReg, + CMD_ID_RF_WRITE_REG, }; /* -----------------------Define structure---------------------- */ From 3870288897f455fd5ec62539829ce7120a434c24 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 13 Jul 2018 12:23:11 +0100 Subject: [PATCH 379/903] staging:rtl8192u: Rename file macro to avoid camel case - Coding Style Simple rename of the preprosessor switch, protecting against multiple inclusion of the header file. Change to clear the checkpatch coding style issue. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 98b6bf7985f7..e615d9b3f6b1 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -15,8 +15,8 @@ * project Authors. */ -#ifndef R819xU_H -#define R819xU_H +#ifndef R8192U_H +#define R8192U_H #include #include From 7faa7d57b2f0fe4e1f2ac3501d343e9429ce0a32 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 12:05:51 +0200 Subject: [PATCH 380/903] staging: gasket: remove pointless gasket_interrupt_pause() gasket_interrupt_pause() does nothing, and no one calls it, so remove it as it is dead-weight. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 18 ------------------ drivers/staging/gasket/gasket_interrupt.h | 11 ----------- 2 files changed, 29 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index faaabdce4720..922ffd5836cd 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -426,24 +426,6 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) } /* See gasket_interrupt.h for description. */ -void gasket_interrupt_pause(struct gasket_dev *gasket_dev, int enable_pause) -{ - WARN_ON(!gasket_dev); - - if (!gasket_dev->interrupt_data) - return; /* nothing to do */ - - if (gasket_dev->interrupt_data->type == PCI_MSI || - gasket_dev->interrupt_data->type == PCI_MSIX) { - /* Nothing to be done for MSI/MSIX just yet. */ - } - - if (gasket_dev->interrupt_data->type == PLATFORM_WIRE) { - /* Nothing to be done for PLATFORM_WIRE */ - } -} -EXPORT_SYMBOL(gasket_interrupt_pause); - void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) { struct gasket_interrupt_data *interrupt_data = diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h index 44ea98570844..44ceedec52d8 100644 --- a/drivers/staging/gasket/gasket_interrupt.h +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -150,15 +150,4 @@ struct eventfd_ctx **gasket_interrupt_get_eventfd_ctxs( int gasket_interrupt_system_status(struct gasket_dev *gasket_dev); -/* - * Masks interrupts and de-register the handler. - * After an interrupt pause it is not guaranteed that the chip registers will - * be accessible anymore, since the chip may be in a power save mode, - * which means that the interrupt handler (if it were to happen) may not - * have a way to clear the interrupt condition. - * @gasket_dev: The Gasket device struct - * @enable_pause: Whether to pause or unpause the interrupts. - */ -void gasket_interrupt_pause(struct gasket_dev *gasket_dev, int enable_pause); - #endif From f09b915b37ed827854d904b50dccd531da8dcc99 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 12:05:52 +0200 Subject: [PATCH 381/903] staging: gasket: remove gasket_interrupt_get_eventfd_ctxs() It is exported, yet no one calls it so just remove the dead code. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 7 ------- drivers/staging/gasket/gasket_interrupt.h | 12 ------------ 2 files changed, 19 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 922ffd5836cd..3ea168fd9b51 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -522,13 +522,6 @@ struct msix_entry *gasket_interrupt_get_msix_entries( return interrupt_data->msix_entries; } -struct eventfd_ctx **gasket_interrupt_get_eventfd_ctxs( - struct gasket_interrupt_data *interrupt_data) -{ - return interrupt_data->eventfd_ctxs; -} -EXPORT_SYMBOL(gasket_interrupt_get_eventfd_ctxs); - static ssize_t interrupt_sysfs_show( struct device *device, struct device_attribute *attr, char *buf) { diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h index 44ceedec52d8..f0586a6898ec 100644 --- a/drivers/staging/gasket/gasket_interrupt.h +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -128,18 +128,6 @@ int gasket_interrupt_trigger_eventfd( struct msix_entry *gasket_interrupt_get_msix_entries( struct gasket_interrupt_data *interrupt_data); -/* - * Get a pointer to data's eventfd contexts. - * @data: The interrupt data from which to extract. - * - * Returns the internal pointer to data's eventfd contexts. - * - * This function exists for backwards compatibility with older drivers. - * No new uses should be written. - */ -struct eventfd_ctx **gasket_interrupt_get_eventfd_ctxs( - struct gasket_interrupt_data *interrupt_data); - /* * Get the health of the interrupt subsystem. * @gasket_dev: The Gasket device struct. From b19409549bffc4e5b4e3940d825cec5edb606959 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 12:05:53 +0200 Subject: [PATCH 382/903] staging: gasket: remove gasket_interrupt_trigger_eventfd() No one calls it, so just remove the dead code. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 12 ------------ drivers/staging/gasket/gasket_interrupt.h | 13 ------------- 2 files changed, 25 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 3ea168fd9b51..691996d84cad 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -504,18 +504,6 @@ int gasket_interrupt_clear_eventfd( return 0; } -int gasket_interrupt_trigger_eventfd( - struct gasket_interrupt_data *interrupt_data, int interrupt) -{ - struct eventfd_ctx *ctx = interrupt_data->eventfd_ctxs[interrupt]; - - if (!ctx) - return -EINVAL; - - eventfd_signal(ctx, 1); - return 0; -} - struct msix_entry *gasket_interrupt_get_msix_entries( struct gasket_interrupt_data *interrupt_data) { diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h index f0586a6898ec..5b65d052abc7 100644 --- a/drivers/staging/gasket/gasket_interrupt.h +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -101,19 +101,6 @@ int gasket_interrupt_set_eventfd( int gasket_interrupt_clear_eventfd( struct gasket_interrupt_data *interrupt_data, int interrupt); -/* - * Signals the eventfd associated with interrupt. - * @data: Pointer to device interrupt data. - * @interrupt: The device interrupt to signal for. - * - * Simulates a device interrupt by signaling the eventfd associated with - * interrupt, if any. - * Returns 0 if the eventfd was successfully triggered, a negative error code - * otherwise (if, for example, no eventfd was associated with interrupt). - */ -int gasket_interrupt_trigger_eventfd( - struct gasket_interrupt_data *interrupt_data, int interrupt); - /* * The below functions exist for backwards compatibility. * No new uses should be written. From 4c89a44dd907644743fe24ad92fdf1f15889fb60 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 12:05:54 +0200 Subject: [PATCH 383/903] staging: gasket: remove gasket_interrupt_get_msix_entries() No one calls it, it is claimed to be "legacy", whatever that means, so just remove the dead code. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 6 ------ drivers/staging/gasket/gasket_interrupt.h | 10 ---------- 2 files changed, 16 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 691996d84cad..d096ce73cc8b 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -504,12 +504,6 @@ int gasket_interrupt_clear_eventfd( return 0; } -struct msix_entry *gasket_interrupt_get_msix_entries( - struct gasket_interrupt_data *interrupt_data) -{ - return interrupt_data->msix_entries; -} - static ssize_t interrupt_sysfs_show( struct device *device, struct device_attribute *attr, char *buf) { diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h index 5b65d052abc7..805fee64569f 100644 --- a/drivers/staging/gasket/gasket_interrupt.h +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -105,16 +105,6 @@ int gasket_interrupt_clear_eventfd( * The below functions exist for backwards compatibility. * No new uses should be written. */ -/* - * Retrieve a pointer to data's MSI-X - * entries. - * @data: The interrupt data from which to extract. - * - * Returns the internal pointer to data's MSI-X entries. - */ -struct msix_entry *gasket_interrupt_get_msix_entries( - struct gasket_interrupt_data *interrupt_data); - /* * Get the health of the interrupt subsystem. * @gasket_dev: The Gasket device struct. From af3abc4414cb94929be4940f3d9c02fea3f0b5c8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 12:05:55 +0200 Subject: [PATCH 384/903] staging: gasket: remove gasket_page_table_num_extended_entries() It is exported, yet no one calls it so just remove the dead code. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 11 ----------- drivers/staging/gasket/gasket_page_table.h | 7 ------- 2 files changed, 18 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 3de7f8c400c9..dcd52e141f95 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -640,17 +640,6 @@ uint gasket_page_table_num_simple_entries(struct gasket_page_table *pg_tbl) EXPORT_SYMBOL(gasket_page_table_num_simple_entries); /* See gasket_page_table.h for description. */ -uint gasket_page_table_num_extended_entries(struct gasket_page_table *pg_tbl) -{ - if (!pg_tbl) { - gasket_nodev_error("Passed a null page table."); - return 0; - } - - return pg_tbl->num_extended_entries; -} -EXPORT_SYMBOL(gasket_page_table_num_extended_entries); - uint gasket_page_table_num_active_pages(struct gasket_page_table *pg_tbl) { if (!pg_tbl) { diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index d8d031cf16a2..720ce2bc2c01 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h @@ -201,13 +201,6 @@ uint gasket_page_table_num_entries(struct gasket_page_table *page_table); */ uint gasket_page_table_num_simple_entries(struct gasket_page_table *page_table); -/* - * Gets the number of extended entries. - * @page_table: Gasket page table pointer. - */ -uint gasket_page_table_num_extended_entries( - struct gasket_page_table *page_table); - /* * Gets the number of actively pinned pages. * @page_table: Gasket page table pointer. From 11bab0e3e08b491c8cfcbb6fc6c206e08cf6aae8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 10:29:02 +0200 Subject: [PATCH 385/903] staging: gasket: remove GASKET_SYSFS_REG() In an attempt to start to clean up the monstrosity of the sysfs abuse in the gasket driver, let's remove code that is not used at all. The GASKET_SYSFS_REG() macro is never used, so delete it. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h index 40db5a063afd..0949cdae876c 100644 --- a/drivers/staging/gasket/gasket_sysfs.h +++ b/drivers/staging/gasket/gasket_sysfs.h @@ -78,15 +78,6 @@ struct gasket_sysfs_attribute { .attr = __ATTR(_name, S_IRUGO, _show_function, NULL), \ .data.attr_type = _attr_type \ } -#define GASKET_SYSFS_REG(_name, _offset, _bar) \ - { \ - .attr = __ATTR(_name, S_IRUGO, gasket_sysfs_register_show, \ - NULL), \ - .data.bar_address = { \ - .bar = _bar, \ - .offset = _offset \ - } \ - } /* Initializes the Gasket sysfs subsystem. * From 3adb0e35a4d86b442a55eabfa6ab7b67059e514f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 10:29:03 +0200 Subject: [PATCH 386/903] staging: gasket: remove gasket_sysfs_register_show() In an attempt to start to clean up the monstrosity of the sysfs abuse in the gasket driver, let's remove code that is not used at all. The gasket_sysfs_register_show() function is never used, so delete it. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 38 --------------------------- drivers/staging/gasket/gasket_sysfs.h | 4 --- 2 files changed, 42 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index 94e55f19b43f..39f9595c85e8 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -396,44 +396,6 @@ void gasket_sysfs_put_attr( } EXPORT_SYMBOL(gasket_sysfs_put_attr); -ssize_t gasket_sysfs_register_show( - struct device *device, struct device_attribute *attr, char *buf) -{ - ulong reg_address, reg_bar, reg_value; - struct gasket_sysfs_mapping *mapping; - struct gasket_dev *gasket_dev; - struct gasket_sysfs_attribute *gasket_attr; - - mapping = get_mapping(device); - if (!mapping) { - gasket_nodev_info("Device driver may have been removed."); - return 0; - } - - gasket_dev = mapping->gasket_dev; - if (!gasket_dev) { - gasket_nodev_error( - "No sysfs mapping found for device 0x%p", device); - put_mapping(mapping); - return 0; - } - - gasket_attr = gasket_sysfs_get_attr(device, attr); - if (!gasket_attr) { - put_mapping(mapping); - return 0; - } - - reg_address = gasket_attr->data.bar_address.offset; - reg_bar = gasket_attr->data.bar_address.bar; - reg_value = gasket_dev_read_64(gasket_dev, reg_bar, reg_address); - - gasket_sysfs_put_attr(device, gasket_attr); - put_mapping(mapping); - return snprintf(buf, PAGE_SIZE, "0x%lX\n", reg_value); -} -EXPORT_SYMBOL(gasket_sysfs_register_show); - ssize_t gasket_sysfs_register_store( struct device *device, struct device_attribute *attr, const char *buf, size_t count) diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h index 0949cdae876c..e9f4fad80461 100644 --- a/drivers/staging/gasket/gasket_sysfs.h +++ b/drivers/staging/gasket/gasket_sysfs.h @@ -167,10 +167,6 @@ struct gasket_sysfs_attribute *gasket_sysfs_get_attr( void gasket_sysfs_put_attr( struct device *device, struct gasket_sysfs_attribute *attr); -/* Display a register as a sysfs node. */ -ssize_t gasket_sysfs_register_show( - struct device *device, struct device_attribute *attr, char *buf); - /* * Write to a register sysfs node. * @buf: NULL-terminated data being written. From 2e008cd075ba8c2b2212b9e8f3c75d79fa1ee44b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 10:29:04 +0200 Subject: [PATCH 387/903] staging: gasket: sysfs: remove legacy_device field This field is only ever checked, never actually set, and looks to be left-over from some old interface of some sort. As it's not being used at all here, and is just adding to the complexity, delete it. Cc: Rob Springer Cc: John Joseph Cc: Ben Chan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 29 ++------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index 39f9595c85e8..e3d770630961 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -17,9 +17,6 @@ struct gasket_sysfs_mapping { */ struct device *device; - /* Legacy device struct, if used by this mapping's driver. */ - struct device *legacy_device; - /* The Gasket descriptor for this device. */ struct gasket_dev *gasket_dev; @@ -75,8 +72,7 @@ static struct gasket_sysfs_mapping *get_mapping(struct device *device) for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) { mutex_lock(&dev_mappings[i].mutex); - if (dev_mappings[i].device == device || - dev_mappings[i].legacy_device == device) { + if (dev_mappings[i].device == device) { kref_get(&dev_mappings[i].refcount); mutex_unlock(&dev_mappings[i].mutex); return &dev_mappings[i]; @@ -105,7 +101,6 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) int num_files_to_remove = 0; struct device_attribute *files_to_remove; struct device *device; - struct device *legacy_device; if (!mapping) { gasket_nodev_info("Mapping should not be NULL."); @@ -126,7 +121,6 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) * sysfs nodes are removed outside the lock. */ device = mapping->device; - legacy_device = mapping->legacy_device; num_files_to_remove = mapping->attribute_count; files_to_remove = kcalloc(num_files_to_remove, sizeof(*files_to_remove), @@ -143,12 +137,8 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) mutex_unlock(&mapping->mutex); if (num_files_to_remove != 0) { - for (i = 0; i < num_files_to_remove; ++i) { + for (i = 0; i < num_files_to_remove; ++i) device_remove_file(device, &files_to_remove[i]); - if (legacy_device) - device_remove_file( - legacy_device, &files_to_remove[i]); - } kfree(files_to_remove); } } @@ -282,21 +272,6 @@ int gasket_sysfs_create_entries( return ret; } - if (mapping->legacy_device) { - ret = device_create_file(mapping->legacy_device, - &attrs[i].attr); - if (ret) { - gasket_log_error( - mapping->gasket_dev, - "Unable to create legacy sysfs entries;" - " rc: %d", - ret); - mutex_unlock(&mapping->mutex); - put_mapping(mapping); - return ret; - } - } - mapping->attributes[mapping->attribute_count] = attrs[i]; ++mapping->attribute_count; } From bfd727f3a59c3696d6fbe086589376a16a5cdf05 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 13 Jul 2018 17:46:17 +0200 Subject: [PATCH 388/903] staging: gasket: remove gasket_wait_sync() This function is not called anywhere, so just remove it. Also, as an added benifit, Arnd points out that it doesn't even work properly: This code won't work correct during leap seconds or a concurrent settimeofday() call, and it probably doesn't do what the author intended even for the normal case, as it passes a timeout in nanoseconds but reads the time using a jiffies-granularity accessor. Reported-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 45 ---------------------------- drivers/staging/gasket/gasket_core.h | 5 ---- 2 files changed, 50 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 14649a794e35..b69b630f1b79 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -2067,51 +2067,6 @@ struct device *gasket_get_device(struct gasket_dev *dev) return NULL; } -/** - * Synchronously waits on device. - * @gasket_dev: Device struct. - * @bar: Bar - * @offset: Register offset - * @mask: Register mask - * @val: Expected value - * @timeout_ns: Timeout in nanoseconds - * - * Description: Busy waits for a specific combination of bits to be set - * on a Gasket register. - **/ -int gasket_wait_sync( - struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - u64 timeout_ns) -{ - u64 reg; - struct timespec start_time, cur_time; - u64 diff_nanosec; - int count = 0; - - reg = gasket_dev_read_64(gasket_dev, bar, offset); - start_time = current_kernel_time(); - while ((reg & mask) != val) { - count++; - cur_time = current_kernel_time(); - diff_nanosec = (u64)(cur_time.tv_sec - start_time.tv_sec) * - 1000000000LL + - (u64)(cur_time.tv_nsec) - - (u64)(start_time.tv_nsec); - if (diff_nanosec > timeout_ns) { - gasket_log_error( - gasket_dev, - "%s timeout: reg %llx count %x " - "dma %lld ns\n", - __func__, - offset, count, diff_nanosec); - return -1; - } - reg = gasket_dev_read_64(gasket_dev, bar, offset); - } - return 0; -} -EXPORT_SYMBOL(gasket_wait_sync); - /** * Asynchronously waits on device. * @gasket_dev: Device struct. diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 45013446b8c5..e51acadc0fc4 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -699,11 +699,6 @@ const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev); /* Get the device structure for a given device. */ struct device *gasket_get_device(struct gasket_dev *dev); -/* Helper function, Synchronous waits on a given set of bits. */ -int gasket_wait_sync( - struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - u64 timeout_ns); - /* Helper function, Asynchronous waits on a given set of bits. */ int gasket_wait_with_reschedule( struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, From 382fa5812583b6c3a4d02a5830b70ec7ee2f07a3 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Tue, 10 Jul 2018 00:10:08 +0900 Subject: [PATCH 389/903] iio: accel: adxl345: add sampling frequency support The ADXL345 provides selectable output data rate. This adds the iio channel information for the sampling frequency with that feature. Cc: Eva Rachel Retuya Cc: Andy Shevchenko Cc: Jonathan Cameron Signed-off-by: Akinobu Mita Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl345_core.c | 57 +++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 7b29ae8375e9..3359f33db4e3 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -14,6 +14,7 @@ #include #include +#include #include "adxl345.h" @@ -22,6 +23,7 @@ #define ADXL345_REG_OFSY 0x1f #define ADXL345_REG_OFSZ 0x20 #define ADXL345_REG_OFS_AXIS(index) (ADXL345_REG_OFSX + (index)) +#define ADXL345_REG_BW_RATE 0x2C #define ADXL345_REG_POWER_CTL 0x2D #define ADXL345_REG_DATA_FORMAT 0x31 #define ADXL345_REG_DATAX0 0x32 @@ -30,6 +32,10 @@ #define ADXL345_REG_DATA_AXIS(index) \ (ADXL345_REG_DATAX0 + (index) * sizeof(__le16)) +#define ADXL345_BW_RATE GENMASK(3, 0) +#define ADXL345_BASE_RATE_NANO_HZ 97656250LL +#define NHZ_PER_HZ 1000000000LL + #define ADXL345_POWER_CTL_MEASURE BIT(3) #define ADXL345_POWER_CTL_STANDBY 0x00 @@ -62,7 +68,8 @@ struct adxl345_data { .address = index, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_CALIBBIAS), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ } static const struct iio_chan_spec adxl345_channels[] = { @@ -77,6 +84,7 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, { struct adxl345_data *data = iio_priv(indio_dev); __le16 accel; + long long samp_freq_nhz; unsigned int regval; int ret; @@ -112,6 +120,16 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, *val = sign_extend32(regval, 7) * 4; return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + ret = regmap_read(data->regmap, ADXL345_REG_BW_RATE, ®val); + if (ret < 0) + return ret; + + samp_freq_nhz = ADXL345_BASE_RATE_NANO_HZ << + (regval & ADXL345_BW_RATE); + *val = div_s64_rem(samp_freq_nhz, NHZ_PER_HZ, val2); + + return IIO_VAL_INT_PLUS_NANO; } return -EINVAL; @@ -122,6 +140,7 @@ static int adxl345_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { struct adxl345_data *data = iio_priv(indio_dev); + s64 n; switch (mask) { case IIO_CHAN_INFO_CALIBBIAS: @@ -132,14 +151,50 @@ static int adxl345_write_raw(struct iio_dev *indio_dev, return regmap_write(data->regmap, ADXL345_REG_OFS_AXIS(chan->address), val / 4); + case IIO_CHAN_INFO_SAMP_FREQ: + n = div_s64(val * NHZ_PER_HZ + val2, ADXL345_BASE_RATE_NANO_HZ); + + return regmap_update_bits(data->regmap, ADXL345_REG_BW_RATE, + ADXL345_BW_RATE, + clamp_val(ilog2(n), 0, + ADXL345_BW_RATE)); } return -EINVAL; } +static int adxl345_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_CALIBBIAS: + return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + return IIO_VAL_INT_PLUS_NANO; + default: + return -EINVAL; + } +} + +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( +"0.09765625 0.1953125 0.390625 0.78125 1.5625 3.125 6.25 12.5 25 50 100 200 400 800 1600 3200" +); + +static struct attribute *adxl345_attrs[] = { + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group adxl345_attrs_group = { + .attrs = adxl345_attrs, +}; + static const struct iio_info adxl345_info = { + .attrs = &adxl345_attrs_group, .read_raw = adxl345_read_raw, .write_raw = adxl345_write_raw, + .write_raw_get_fmt = adxl345_write_raw_get_fmt, }; int adxl345_core_probe(struct device *dev, struct regmap *regmap, From 7f310e5d07112e0bae57ce63de954e6773a26f81 Mon Sep 17 00:00:00 2001 From: Andreas Klinger Date: Tue, 10 Jul 2018 20:18:31 +0200 Subject: [PATCH 390/903] iio: hx711: add clock-frequency property in DT Add clock-frequency property for hx711 ADC. This is the frequency of PD_SCK. After PD_SCK goes high DOUT is read just before PD_SCK goes down again. This is necessary because of parasitic capacitance on the wiring. Signed-off-by: Andreas Klinger Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/avia-hx711.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt index b3629405f568..2c1b67d33c49 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt @@ -8,11 +8,17 @@ Required properties: See Documentation/devicetree/bindings/gpio/gpio.txt - avdd-supply: Definition of the regulator used as analog supply +Optional properties: + - clock-frequency: Frequency of PD_SCK in Hz + Minimum value allowed is 10 kHz because of maximum + high time of 50 microseconds. + Example: weight@0 { compatible = "avia,hx711"; sck-gpios = <&gpio3 10 GPIO_ACTIVE_HIGH>; dout-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; avdd-suppy = <&avdd>; + clock-frequency = <100000>; }; From 461631face58054c72b1f1453f2d66d71b1974e7 Mon Sep 17 00:00:00 2001 From: Andreas Klinger Date: Tue, 10 Jul 2018 20:19:03 +0200 Subject: [PATCH 391/903] iio: hx711: add delay until DOUT is ready On a system with parasitic capacitance it turned out that DOUT is not ready after 100 ns after PD_SCK has raised. A measurement showed almost 1000 ns until DOUT has reached its correct value. With this patch its now possible to wait until data is ready. The wait time should not be higher than the maximum PD_SCK high time which is corresponding to the datasheet 50000 ns. Signed-off-by: Andreas Klinger Signed-off-by: Jonathan Cameron --- drivers/iio/adc/hx711.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 9430b54121e0..36b59d8957fb 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -97,6 +97,14 @@ struct hx711_data { * 2x32-bit channel + 64-bit timestamp */ u32 buffer[4]; + /* + * delay after a rising edge on SCK until the data is ready DOUT + * this is dependent on the hx711 where the datasheet tells a + * maximum value of 100 ns + * but also on potential parasitic capacities on the wiring + */ + u32 data_ready_delay_ns; + u32 clock_frequency; }; static int hx711_cycle(struct hx711_data *hx711_data) @@ -110,6 +118,14 @@ static int hx711_cycle(struct hx711_data *hx711_data) */ preempt_disable(); gpiod_set_value(hx711_data->gpiod_pd_sck, 1); + + /* + * wait until DOUT is ready + * it turned out that parasitic capacities are extending the time + * until DOUT has reached it's value + */ + ndelay(hx711_data->data_ready_delay_ns); + val = gpiod_get_value(hx711_data->gpiod_dout); /* * here we are not waiting for 0.2 us as suggested by the datasheet, @@ -120,6 +136,12 @@ static int hx711_cycle(struct hx711_data *hx711_data) gpiod_set_value(hx711_data->gpiod_pd_sck, 0); preempt_enable(); + /* + * make it a square wave for addressing cases with capacitance on + * PC_SCK + */ + ndelay(hx711_data->data_ready_delay_ns); + return val; } @@ -458,6 +480,7 @@ static const struct iio_chan_spec hx711_chan_spec[] = { static int hx711_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct hx711_data *hx711_data; struct iio_dev *indio_dev; int ret; @@ -530,6 +553,22 @@ static int hx711_probe(struct platform_device *pdev) hx711_data->gain_set = 128; hx711_data->gain_chan_a = 128; + hx711_data->clock_frequency = 400000; + ret = of_property_read_u32(np, "clock-frequency", + &hx711_data->clock_frequency); + + /* + * datasheet says the high level of PD_SCK has a maximum duration + * of 50 microseconds + */ + if (hx711_data->clock_frequency < 20000) { + dev_warn(dev, "clock-frequency too low - assuming 400 kHz\n"); + hx711_data->clock_frequency = 400000; + } + + hx711_data->data_ready_delay_ns = + 1000000000 / hx711_data->clock_frequency; + platform_set_drvdata(pdev, indio_dev); indio_dev->name = "hx711"; From 843429708e394a31d3298f9b6dfa8fca180f8bfa Mon Sep 17 00:00:00 2001 From: Andreas Klinger Date: Tue, 10 Jul 2018 20:19:37 +0200 Subject: [PATCH 392/903] iio: hx711: fix spurious unit-address in example Device tree compiler (dtc) gives a warning if a device node has "@" with a following number as it's name but no reg property. Fix the example in the documentation of avia,hx711 to conform to dtc behavior. Signed-off-by: Andreas Klinger Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/avia-hx711.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt index 2c1b67d33c49..7222328a3d0d 100644 --- a/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt +++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt @@ -14,7 +14,7 @@ Optional properties: high time of 50 microseconds. Example: -weight@0 { +weight { compatible = "avia,hx711"; sck-gpios = <&gpio3 10 GPIO_ACTIVE_HIGH>; dout-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; From de8df0b9c38d8f232f0df03220ff540a54eaf73d Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Tue, 10 Jul 2018 21:09:30 -0400 Subject: [PATCH 393/903] iio: imu: mpu6050: add support for 6515 variant This patch adds support for the MPU 6515 variant. Confirmed that the driver functions correctly on a LG Nexus 5 (hammerhead) phone. Signed-off-by: Brian Masney Signed-off-by: Jonathan Marek Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt | 1 + drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 ++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 5 +++++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 ++ 4 files changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt index 5f4777e8cc9e..b7def51c8ad9 100644 --- a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt +++ b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt @@ -6,6 +6,7 @@ Required properties: - compatible : should be one of "invensense,mpu6050" "invensense,mpu6500" + "invensense,mpu6515" "invensense,mpu9150" "invensense,mpu9250" "invensense,mpu9255" diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index de68e83fc52d..12c1b9507007 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -103,6 +103,12 @@ static const struct inv_mpu6050_hw hw_info[] = { .reg = ®_set_6500, .config = &chip_config_6050, }, + { + .whoami = INV_MPU6515_WHOAMI_VALUE, + .name = "MPU6515", + .reg = ®_set_6500, + .config = &chip_config_6050, + }, { .whoami = INV_MPU6000_WHOAMI_VALUE, .name = "MPU6000", diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index 495409d56207..dd758e3d403d 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -174,6 +174,7 @@ static int inv_mpu_remove(struct i2c_client *client) static const struct i2c_device_id inv_mpu_id[] = { {"mpu6050", INV_MPU6050}, {"mpu6500", INV_MPU6500}, + {"mpu6515", INV_MPU6515}, {"mpu9150", INV_MPU9150}, {"mpu9250", INV_MPU9250}, {"mpu9255", INV_MPU9255}, @@ -192,6 +193,10 @@ static const struct of_device_id inv_of_match[] = { .compatible = "invensense,mpu6500", .data = (void *)INV_MPU6500 }, + { + .compatible = "invensense,mpu6515", + .data = (void *)INV_MPU6515 + }, { .compatible = "invensense,mpu9150", .data = (void *)INV_MPU9150 diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index de8391693e17..e69a59659dbc 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -71,6 +71,7 @@ struct inv_mpu6050_reg_map { enum inv_devices { INV_MPU6050, INV_MPU6500, + INV_MPU6515, INV_MPU6000, INV_MPU9150, INV_MPU9250, @@ -256,6 +257,7 @@ struct inv_mpu6050_state { #define INV_MPU9150_WHOAMI_VALUE 0x68 #define INV_MPU9250_WHOAMI_VALUE 0x71 #define INV_MPU9255_WHOAMI_VALUE 0x73 +#define INV_MPU6515_WHOAMI_VALUE 0x74 #define INV_ICM20608_WHOAMI_VALUE 0xAF /* scan element definition */ From d2b863baf1c7d92969c2a9dcada3c6b14e5dbbc4 Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Tue, 10 Jul 2018 21:33:45 -0400 Subject: [PATCH 394/903] iio: pressure: bmp280: remove unused options from device tree documentation There are several options in the device tree documentation that are no longer relevant for the current in-kernel bmp280 driver so this patch removes them. Signed-off-by: Brian Masney Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/pressure/bmp085.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/pressure/bmp085.txt b/Documentation/devicetree/bindings/iio/pressure/bmp085.txt index c7198a03c906..abcab02504fb 100644 --- a/Documentation/devicetree/bindings/iio/pressure/bmp085.txt +++ b/Documentation/devicetree/bindings/iio/pressure/bmp085.txt @@ -8,10 +8,6 @@ Required properties: "bosch,bme280" Optional properties: -- chip-id: configurable chip id for non-default chip revisions -- temp-measurement-period: temperature measurement period (milliseconds) -- default-oversampling: default oversampling value to be used at startup, - value range is 0-3 with rising sensitivity. - interrupt-parent: should be the phandle for the interrupt controller - interrupts: interrupt mapping for IRQ - reset-gpios: a GPIO line handling reset of the sensor: as the line is @@ -24,9 +20,6 @@ Example: pressure@77 { compatible = "bosch,bmp085"; reg = <0x77>; - chip-id = <10>; - temp-measurement-period = <100>; - default-oversampling = <2>; interrupt-parent = <&gpio0>; interrupts = <25 IRQ_TYPE_EDGE_RISING>; reset-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; From a42174983c7545055bd8375965e31b3c15b287dc Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Thu, 12 Jul 2018 00:15:12 +0200 Subject: [PATCH 395/903] iio: imu: st_lsm6dsx: add error logs to st_lsm6dsx_read_fifo() Add debug info to error conditions in st_lsm6dsx_read_fifo routine Suggested-by: Jorge Ramirez-Ortiz Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 4994f920a836..7589f2ad1dae 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -298,8 +298,11 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) err = regmap_bulk_read(hw->regmap, hw->settings->fifo_ops.fifo_diff.addr, &fifo_status, sizeof(fifo_status)); - if (err < 0) + if (err < 0) { + dev_err(hw->dev, "failed to read fifo status (err=%d)\n", + err); return err; + } if (fifo_status & cpu_to_le16(ST_LSM6DSX_FIFO_EMPTY_MASK)) return 0; @@ -313,8 +316,12 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) for (read_len = 0; read_len < fifo_len; read_len += pattern_len) { err = st_lsm6dsx_read_block(hw, hw->buff, pattern_len); - if (err < 0) + if (err < 0) { + dev_err(hw->dev, + "failed to read pattern from fifo (err=%d)\n", + err); return err; + } /* * Data are written to the FIFO with a specific pattern @@ -385,8 +392,11 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) if (unlikely(reset_ts)) { err = st_lsm6dsx_reset_hw_ts(hw); - if (err < 0) + if (err < 0) { + dev_err(hw->dev, "failed to reset hw ts (err=%d)\n", + err); return err; + } } return read_len; } From ef89f4b96a2ab8dc1a0a3815d9365240e4c3c06b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 13 Jul 2018 14:50:44 +0300 Subject: [PATCH 396/903] iio: adxl345: Add support for the ADXL375 The ADXL375 is fully register map compatible to the ADXL345 (including the device ID register returning the same value ...). The only difference is the resolution of the acceleration sensor. The ADXL375 can measure up to +-200g of acceleration. Datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL375.PDF Signed-off-by: Lars-Peter Clausen Signed-off-by: Mircea Caprioru Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/accel/adxl345.txt | 7 +++++-- drivers/iio/accel/Kconfig | 4 ++-- drivers/iio/accel/adxl345.h | 7 ++++++- drivers/iio/accel/adxl345_core.c | 19 +++++++++++++++++-- drivers/iio/accel/adxl345_i2c.c | 7 +++++-- drivers/iio/accel/adxl345_spi.c | 6 ++++-- 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/accel/adxl345.txt b/Documentation/devicetree/bindings/iio/accel/adxl345.txt index e7111b02c02c..bb7fc0bd5776 100644 --- a/Documentation/devicetree/bindings/iio/accel/adxl345.txt +++ b/Documentation/devicetree/bindings/iio/accel/adxl345.txt @@ -1,9 +1,12 @@ -Analog Devices ADXL345 3-Axis, +/-(2g/4g/8g/16g) Digital Accelerometer +Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers http://www.analog.com/en/products/mems/accelerometers/adxl345.html +http://www.analog.com/en/products/sensors-mems/accelerometers/adxl375.html Required properties: - - compatible : should be "adi,adxl345" + - compatible : should be one of + "adi,adxl345" + "adi,adxl375" - reg : the I2C address or SPI chip select number of the sensor Required properties for SPI bus usage: diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 62ae7e5abcfa..829dc96c9dd6 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -40,7 +40,7 @@ config ADXL345_I2C select REGMAP_I2C help Say Y here if you want to build support for the Analog Devices - ADXL345 3-axis digital accelerometer. + ADXL345 or ADXL375 3-axis digital accelerometer. To compile this driver as a module, choose M here: the module will be called adxl345_i2c and you will also get adxl345_core @@ -54,7 +54,7 @@ config ADXL345_SPI select REGMAP_SPI help Say Y here if you want to build support for the Analog Devices - ADXL345 3-axis digital accelerometer. + ADXL345 or ADXL375 3-axis digital accelerometer. To compile this driver as a module, choose M here: the module will be called adxl345_spi and you will also get adxl345_core diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h index c1ddf3927c47..ccd63de7a55a 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -11,8 +11,13 @@ #ifndef _ADXL345_H_ #define _ADXL345_H_ +enum adxl345_device_type { + ADXL345, + ADXL375, +}; + int adxl345_core_probe(struct device *dev, struct regmap *regmap, - const char *name); + enum adxl345_device_type type, const char *name); int adxl345_core_remove(struct device *dev); #endif /* _ADXL345_H_ */ diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 3359f33db4e3..780f87f72338 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -56,9 +56,16 @@ */ static const int adxl345_uscale = 38300; +/* + * The Datasheet lists a resolution of Resolution is ~49 mg per LSB. That's + * ~480mm/s**2 per LSB. + */ +static const int adxl375_uscale = 480000; + struct adxl345_data { struct regmap *regmap; u8 data_range; + enum adxl345_device_type type; }; #define ADXL345_CHANNEL(index, axis) { \ @@ -105,7 +112,14 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; - *val2 = adxl345_uscale; + switch (data->type) { + case ADXL345: + *val2 = adxl345_uscale; + break; + case ADXL375: + *val2 = adxl375_uscale; + break; + } return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_CALIBBIAS: @@ -198,7 +212,7 @@ static const struct iio_info adxl345_info = { }; int adxl345_core_probe(struct device *dev, struct regmap *regmap, - const char *name) + enum adxl345_device_type type, const char *name) { struct adxl345_data *data; struct iio_dev *indio_dev; @@ -224,6 +238,7 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap, data = iio_priv(indio_dev); dev_set_drvdata(dev, indio_dev); data->regmap = regmap; + data->type = type; /* Enable full-resolution mode */ data->data_range = ADXL345_DATA_FORMAT_FULL_RES; diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c index 05e1ec49700c..785c89de91e7 100644 --- a/drivers/iio/accel/adxl345_i2c.c +++ b/drivers/iio/accel/adxl345_i2c.c @@ -34,7 +34,8 @@ static int adxl345_i2c_probe(struct i2c_client *client, return PTR_ERR(regmap); } - return adxl345_core_probe(&client->dev, regmap, id ? id->name : NULL); + return adxl345_core_probe(&client->dev, regmap, id->driver_data, + id ? id->name : NULL); } static int adxl345_i2c_remove(struct i2c_client *client) @@ -43,7 +44,8 @@ static int adxl345_i2c_remove(struct i2c_client *client) } static const struct i2c_device_id adxl345_i2c_id[] = { - { "adxl345", 0 }, + { "adxl345", ADXL345 }, + { "adxl375", ADXL375 }, { } }; @@ -51,6 +53,7 @@ MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id); static const struct of_device_id adxl345_of_match[] = { { .compatible = "adi,adxl345" }, + { .compatible = "adi,adxl375" }, { }, }; diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c index 6d658196f81c..67b7c66a8492 100644 --- a/drivers/iio/accel/adxl345_spi.c +++ b/drivers/iio/accel/adxl345_spi.c @@ -42,7 +42,7 @@ static int adxl345_spi_probe(struct spi_device *spi) return PTR_ERR(regmap); } - return adxl345_core_probe(&spi->dev, regmap, id->name); + return adxl345_core_probe(&spi->dev, regmap, id->driver_data, id->name); } static int adxl345_spi_remove(struct spi_device *spi) @@ -51,7 +51,8 @@ static int adxl345_spi_remove(struct spi_device *spi) } static const struct spi_device_id adxl345_spi_id[] = { - { "adxl345", 0 }, + { "adxl345", ADXL345 }, + { "adxl375", ADXL375 }, { } }; @@ -59,6 +60,7 @@ MODULE_DEVICE_TABLE(spi, adxl345_spi_id); static const struct of_device_id adxl345_of_match[] = { { .compatible = "adi,adxl345" }, + { .compatible = "adi,adxl375" }, { }, }; From cd570e6fa43a5ed061b91e64dc507a6ac54fac95 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 13 Jul 2018 03:25:34 +0200 Subject: [PATCH 397/903] iio: change strncpy+truncation to strlcpy Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_core.c | 3 +-- drivers/iio/pressure/st_pressure_i2c.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 57db19182e95..26fbd1bd9413 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -380,8 +380,7 @@ void st_sensors_of_name_probe(struct device *dev, return; /* The name from the OF match takes precedence if present */ - strncpy(name, of_id->data, len); - name[len - 1] = '\0'; + strlcpy(name, of_id->data, len); } EXPORT_SYMBOL(st_sensors_of_name_probe); #else diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index fbb59059e942..2026a1012012 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -94,9 +94,8 @@ static int st_press_i2c_probe(struct i2c_client *client, if ((ret < 0) || (ret >= ST_PRESS_MAX)) return -ENODEV; - strncpy(client->name, st_press_id_table[ret].name, + strlcpy(client->name, st_press_id_table[ret].name, sizeof(client->name)); - client->name[sizeof(client->name) - 1] = '\0'; } else if (!id) return -ENODEV; From 0d4876f4e977798238db594321db9184704fcf5d Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sat, 14 Jul 2018 20:54:09 +0300 Subject: [PATCH 398/903] staging:r8188eu: Use lib80211 to encrypt (TKIP) tx frames Put data to skb, decrypt with lib80211_crypt_tkip, and place back to tx buffer. MIC calculation will be replaced later. Signed-off-by: Ivan Safonov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 433 ++++-------------- 1 file changed, 84 insertions(+), 349 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index a01290467c64..ada69efd61b3 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -12,121 +12,6 @@ #include #include -/* WEP related ===== */ - -#define CRC32_POLY 0x04c11db7 - -struct arc4context { - u32 x; - u32 y; - u8 state[256]; -}; - -static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) -{ - u32 t, u; - u32 keyindex; - u32 stateindex; - u8 *state; - u32 counter; - - state = parc4ctx->state; - parc4ctx->x = 0; - parc4ctx->y = 0; - for (counter = 0; counter < 256; counter++) - state[counter] = (u8)counter; - keyindex = 0; - stateindex = 0; - for (counter = 0; counter < 256; counter++) { - t = state[counter]; - stateindex = (stateindex + key[keyindex] + t) & 0xff; - u = state[stateindex]; - state[stateindex] = (u8)t; - state[counter] = (u8)u; - if (++keyindex >= key_len) - keyindex = 0; - } -} - -static u32 arcfour_byte(struct arc4context *parc4ctx) -{ - u32 x; - u32 y; - u32 sx, sy; - u8 *state; - - state = parc4ctx->state; - x = (parc4ctx->x + 1) & 0xff; - sx = state[x]; - y = (sx + parc4ctx->y) & 0xff; - sy = state[y]; - parc4ctx->x = x; - parc4ctx->y = y; - state[y] = (u8)sx; - state[x] = (u8)sy; - return state[(sx + sy) & 0xff]; -} - -static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) -{ - u32 i; - - for (i = 0; i < len; i++) - dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); -} - -static int bcrc32initialized; -static u32 crc32_table[256]; - -static u8 crc32_reverseBit(u8 data) -{ - return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) | - ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) | - ((data>>5)&0x02) | ((data>>7)&0x01); -} - -static void crc32_init(void) -{ - if (bcrc32initialized == 1) { - return; - } else { - int i, j; - u32 c; - u8 *p = (u8 *)&c, *p1; - u8 k; - - c = 0x12340000; - - for (i = 0; i < 256; ++i) { - k = crc32_reverseBit((u8)i); - for (c = ((u32)k) << 24, j = 8; j > 0; --j) - c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); - p1 = (u8 *)&crc32_table[i]; - - p1[0] = crc32_reverseBit(p[3]); - p1[1] = crc32_reverseBit(p[2]); - p1[2] = crc32_reverseBit(p[1]); - p1[3] = crc32_reverseBit(p[0]); - } - bcrc32initialized = 1; - } -} - -static __le32 getcrc32(u8 *buf, int len) -{ - u8 *p; - u32 crc; - - if (bcrc32initialized == 0) - crc32_init(); - - crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ - - for (p = buf; len > 0; ++p, --len) - crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); - return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ -} - /* Need to consider the fragment situation */ @@ -395,202 +280,24 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod #define P1K_SIZE 10 /* 80-bit Phase1 key */ #define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */ -/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */ -static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) */ -{ - 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, - 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, - 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, - 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, - 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, - 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, - 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, - 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, - 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, - 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, - 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, - 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, - 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, - 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, - 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, - 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, - 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, - 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, - 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, - 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, - 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, - 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, - 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, - 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, - 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, - 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, - 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, - 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, - 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, - 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, - 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, - 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, - }, - - { /* second half of table is unsigned char-reversed version of first! */ - 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, - 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, - 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, - 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, - 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, - 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, - 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, - 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, - 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, - 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, - 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, - 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, - 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, - 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, - 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, - 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, - 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, - 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, - 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, - 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, - 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, - 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, - 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, - 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, - 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, - 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, - 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, - 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, - 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, - 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, - 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, - 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C, - } -}; - - /* -********************************************************************** -* Routine: Phase 1 -- generate P1K, given TA, TK, IV32 -* -* Inputs: -* tk[] = temporal key [128 bits] -* ta[] = transmitter's MAC address [ 48 bits] -* iv32 = upper 32 bits of IV [ 32 bits] -* Output: -* p1k[] = Phase 1 key [ 80 bits] -* -* Note: -* This function only needs to be called every 2**16 packets, -* although in theory it could be called every packet. -* -********************************************************************** -*/ -static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) -{ - int i; - /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ - p1k[0] = Lo16(iv32); - p1k[1] = Hi16(iv32); - p1k[2] = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */ - p1k[3] = Mk16(ta[3], ta[2]); - p1k[4] = Mk16(ta[5], ta[4]); - - /* Now compute an unbalanced Feistel cipher with 80-bit block */ - /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ - for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */ - p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); - p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); - p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); - p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6)); - p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); - p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ - } -} - -/* -********************************************************************** -* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16 -* -* Inputs: -* tk[] = Temporal key [128 bits] -* p1k[] = Phase 1 output key [ 80 bits] -* iv16 = low 16 bits of IV counter [ 16 bits] -* Output: -* rc4key[] = the key used to encrypt the packet [128 bits] -* -* Note: -* The value {TA, IV32, IV16} for Phase1/Phase2 must be unique -* across all packets using the same key TK value. Then, for a -* given value of TK[], this TKIP48 construction guarantees that -* the final RC4KEY value is unique across all packets. -* -* Suggested implementation optimization: if PPK[] is "overlaid" -* appropriately on RC4KEY[], there is no need for the final -* for loop below that copies the PPK[] result into RC4KEY[]. -* -********************************************************************** -*/ -static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) -{ - int i; - u16 PPK[6]; /* temporary key for mixing */ - /* Note: all adds in the PPK[] equations below are mod 2**16 */ - for (i = 0; i < 5; i++) - PPK[i] = p1k[i]; /* first, copy P1K to PPK */ - PPK[5] = p1k[4] + iv16; /* next, add in IV16 */ - - /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ - PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */ - PPK[1] += _S_(PPK[0] ^ TK16(1)); - PPK[2] += _S_(PPK[1] ^ TK16(2)); - PPK[3] += _S_(PPK[2] ^ TK16(3)); - PPK[4] += _S_(PPK[3] ^ TK16(4)); - PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */ - - /* Final sweep: bijective, "linear". Rotates kill LSB correlations */ - PPK[0] += RotR1(PPK[5] ^ TK16(6)); - PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */ - PPK[2] += RotR1(PPK[1]); - PPK[3] += RotR1(PPK[2]); - PPK[4] += RotR1(PPK[3]); - PPK[5] += RotR1(PPK[4]); - /* Note: At this point, for a given key TK[0..15], the 96-bit output */ - /* value PPK[0..5] is guaranteed to be unique, as a function */ - /* of the 96-bit "input" value {TA, IV32, IV16}. That is, P1K */ - /* is now a keyed permutation of {TA, IV32, IV16}. */ - - /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key */ - rc4key[0] = Hi8(iv16); /* RC4KEY[0..2] is the WEP IV */ - rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */ - rc4key[2] = Lo8(iv16); - rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); - - /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ - for (i = 0; i < 6; i++) { - rc4key[4+2*i] = Lo8(PPK[i]); - rc4key[5+2*i] = Hi8(PPK[i]); - } -} - /* The hlen isn't include the IV */ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) -{ /* exclude ICV */ - u16 pnl; - u32 pnh; - u8 rc4key[16]; - u8 ttkey[16]; - u8 crc[4]; +{ u8 hw_hdr_offset = 0; - struct arc4context mycontext; int curfragnum, length; - u8 *pframe, *payload, *iv, *prwskey; - union pn48 dot11txpn; + u8 *pframe; struct sta_info *stainfo; struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; + void *crypto_private; + struct sk_buff *skb; + u8 key[32]; + int key_idx; + const int key_length = 32; + struct lib80211_crypto_ops *crypto_ops; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -599,57 +306,85 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt == _TKIP_) { - if (pattrib->psta) - stainfo = pattrib->psta; - else - stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); + if (pattrib->encrypt != _TKIP_) + return res; - if (stainfo != NULL) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - if (IS_MCAST(pattrib->ra)) - prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; - else - prwskey = &stainfo->dot118021x_UncstKey.skey[0]; - - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; - payload = pframe+pattrib->iv_len+pattrib->hdrlen; - - GET_TKIP_PN(iv, dot11txpn); - - pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val>>16); - phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); - phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); - - if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - RT_TRACE(_module_rtl871x_security_c_, _drv_info_, - ("pattrib->iv_len=%x, pattrib->icv_len=%x\n", - pattrib->iv_len, pattrib->icv_len)); - *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ - - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); - } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); - - pframe += pxmitpriv->frag_len; - pframe = (u8 *)round_up((size_t)(pframe), 4); - } - } - } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); - res = _FAIL; - } + if (!stainfo) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); + return _FAIL; } + + crypto_ops = try_then_request_module(lib80211_get_crypto_ops("TKIP"), "lib80211_crypt_tkip"); + + if (IS_MCAST(pattrib->ra)) { + key_idx = psecuritypriv->dot118021XGrpKeyid; + memcpy(key, psecuritypriv->dot118021XGrpKey[key_idx].skey, 16); + memcpy(key + 16, psecuritypriv->dot118021XGrptxmickey[key_idx].skey, 16); + } else { + key_idx = 0; + memcpy(key, stainfo->dot118021x_UncstKey.skey, 16); + memcpy(key + 16, stainfo->dot11tkiptxmickey.skey, 16); + } + + if (!crypto_ops) { + res = _FAIL; + goto exit; + } + + crypto_private = crypto_ops->init(key_idx); + if (!crypto_private) { + res = _FAIL; + goto exit; + } + + if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) { + res = _FAIL; + goto exit_crypto_ops_deinit; + } + + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + if ((curfragnum+1) == pattrib->nr_frags) + length = pattrib->last_txcmdsz; + else + length = pxmitpriv->frag_len; + + skb = dev_alloc_skb(length); + if (!skb) { + res = _FAIL; + goto exit_crypto_ops_deinit; + } + + skb_put_data(skb, pframe, length); + + memmove(skb->data + pattrib->iv_len, skb->data, pattrib->hdrlen); + skb_pull(skb, pattrib->iv_len); + skb_trim(skb, skb->len - pattrib->icv_len); + + if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, crypto_private)) { + kfree_skb(skb); + res = _FAIL; + goto exit_crypto_ops_deinit; + } + + memcpy(pframe, skb->data, skb->len); + + pframe += skb->len; + pframe = (u8 *)round_up((size_t)(pframe), 4); + + kfree_skb(skb); + } + +exit_crypto_ops_deinit: + crypto_ops->deinit(crypto_private); + +exit: return res; } From 515ce733e86ee2e1bea4dba76d2d4491013d0f73 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sat, 14 Jul 2018 20:54:10 +0300 Subject: [PATCH 399/903] staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames Put data to skb, decrypt with lib80211_crypt_ccmp, and place back to tx buffer. Signed-off-by: Ivan Safonov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 790 ++---------------- 1 file changed, 78 insertions(+), 712 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index ada69efd61b3..508d3299b4e9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -462,510 +462,22 @@ exit: return res; } -/* 3 ===== AES related ===== */ - - -#define MAX_MSG_SIZE 2048 -/*****************************/ -/******** SBOX Table *********/ -/*****************************/ - -static u8 sbox_table[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, - 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, - 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, - 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, - 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, - 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, - 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, - 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, - 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, - 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, - 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, - 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, - 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, - 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, - 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, - 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, - 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -}; - -/*****************************/ -/**** Function Prototypes ****/ -/*****************************/ - -static void bitwise_xor(u8 *ina, u8 *inb, u8 *out); -static void construct_mic_iv(u8 *mic_header1, int qc_exists, int a4_exists, u8 *mpdu, uint payload_length, u8 *pn_vector); -static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu); -static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists); -static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c); -static void xor_128(u8 *a, u8 *b, u8 *out); -static void xor_32(u8 *a, u8 *b, u8 *out); -static u8 sbox(u8 a); -static void next_key(u8 *key, int round); -static void byte_sub(u8 *in, u8 *out); -static void shift_row(u8 *in, u8 *out); -static void mix_column(u8 *in, u8 *out); -static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext); - -/****************************************/ -/* aes128k128d() */ -/* Performs a 128 bit AES encrypt with */ -/* 128 bit data. */ -/****************************************/ -static void xor_128(u8 *a, u8 *b, u8 *out) -{ - int i; - - for (i = 0; i < 16; i++) - out[i] = a[i] ^ b[i]; -} - -static void xor_32(u8 *a, u8 *b, u8 *out) -{ - int i; - - for (i = 0; i < 4; i++) - out[i] = a[i] ^ b[i]; -} - -static u8 sbox(u8 a) -{ - return sbox_table[(int)a]; -} - -static void next_key(u8 *key, int round) -{ - u8 rcon; - u8 sbox_key[4]; - u8 rcon_table[12] = { - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, - 0x1b, 0x36, 0x36, 0x36 - }; - - sbox_key[0] = sbox(key[13]); - sbox_key[1] = sbox(key[14]); - sbox_key[2] = sbox(key[15]); - sbox_key[3] = sbox(key[12]); - - rcon = rcon_table[round]; - - xor_32(&key[0], sbox_key, &key[0]); - key[0] = key[0] ^ rcon; - - xor_32(&key[4], &key[0], &key[4]); - xor_32(&key[8], &key[4], &key[8]); - xor_32(&key[12], &key[8], &key[12]); -} - -static void byte_sub(u8 *in, u8 *out) -{ - int i; - for (i = 0; i < 16; i++) - out[i] = sbox(in[i]); -} - -static void shift_row(u8 *in, u8 *out) -{ - out[0] = in[0]; - out[1] = in[5]; - out[2] = in[10]; - out[3] = in[15]; - out[4] = in[4]; - out[5] = in[9]; - out[6] = in[14]; - out[7] = in[3]; - out[8] = in[8]; - out[9] = in[13]; - out[10] = in[2]; - out[11] = in[7]; - out[12] = in[12]; - out[13] = in[1]; - out[14] = in[6]; - out[15] = in[11]; -} - -static void mix_column(u8 *in, u8 *out) -{ - int i; - u8 add1b[4]; - u8 add1bf7[4]; - u8 rotl[4]; - u8 swap_halves[4]; - u8 andf7[4]; - u8 rotr[4]; - u8 temp[4]; - u8 tempb[4]; - - for (i = 0 ; i < 4; i++) { - if ((in[i] & 0x80) == 0x80) - add1b[i] = 0x1b; - else - add1b[i] = 0x00; - } - - swap_halves[0] = in[2]; /* Swap halves */ - swap_halves[1] = in[3]; - swap_halves[2] = in[0]; - swap_halves[3] = in[1]; - - rotl[0] = in[3]; /* Rotate left 8 bits */ - rotl[1] = in[0]; - rotl[2] = in[1]; - rotl[3] = in[2]; - - andf7[0] = in[0] & 0x7f; - andf7[1] = in[1] & 0x7f; - andf7[2] = in[2] & 0x7f; - andf7[3] = in[3] & 0x7f; - - for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ - andf7[i] = andf7[i] << 1; - if ((andf7[i-1] & 0x80) == 0x80) - andf7[i] = (andf7[i] | 0x01); - } - andf7[0] = andf7[0] << 1; - andf7[0] = andf7[0] & 0xfe; - - xor_32(add1b, andf7, add1bf7); - - xor_32(in, add1bf7, rotr); - - temp[0] = rotr[0]; /* Rotate right 8 bits */ - rotr[0] = rotr[1]; - rotr[1] = rotr[2]; - rotr[2] = rotr[3]; - rotr[3] = temp[0]; - - xor_32(add1bf7, rotr, temp); - xor_32(swap_halves, rotl, tempb); - xor_32(temp, tempb, out); -} - -static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) -{ - int round; - int i; - u8 intermediatea[16]; - u8 intermediateb[16]; - u8 round_key[16]; - - for (i = 0; i < 16; i++) - round_key[i] = key[i]; - for (round = 0; round < 11; round++) { - if (round == 0) { - xor_128(round_key, data, ciphertext); - next_key(round_key, round); - } else if (round == 10) { - byte_sub(ciphertext, intermediatea); - shift_row(intermediatea, intermediateb); - xor_128(intermediateb, round_key, ciphertext); - } else { /* 1 - 9 */ - byte_sub(ciphertext, intermediatea); - shift_row(intermediatea, intermediateb); - mix_column(&intermediateb[0], &intermediatea[0]); - mix_column(&intermediateb[4], &intermediatea[4]); - mix_column(&intermediateb[8], &intermediatea[8]); - mix_column(&intermediateb[12], &intermediatea[12]); - xor_128(intermediatea, round_key, ciphertext); - next_key(round_key, round); - } - } -} - -/************************************************/ -/* construct_mic_iv() */ -/* Builds the MIC IV from header fields and PN */ -/************************************************/ -static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, - uint payload_length, u8 *pn_vector) -{ - int i; - - mic_iv[0] = 0x59; - if (qc_exists && a4_exists) - mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ - if (qc_exists && !a4_exists) - mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */ - if (!qc_exists) - mic_iv[1] = 0x00; - for (i = 2; i < 8; i++) - mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ - for (i = 8; i < 14; i++) - mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ - mic_iv[14] = (unsigned char)(payload_length / 256); - mic_iv[15] = (unsigned char)(payload_length % 256); -} - -/************************************************/ -/* construct_mic_header1() */ -/* Builds the first MIC header block from */ -/* header fields. */ -/************************************************/ -static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu) -{ - mic_header1[0] = (u8)((header_length - 2) / 256); - mic_header1[1] = (u8)((header_length - 2) % 256); - mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ - mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */ - mic_header1[4] = mpdu[4]; /* A1 */ - mic_header1[5] = mpdu[5]; - mic_header1[6] = mpdu[6]; - mic_header1[7] = mpdu[7]; - mic_header1[8] = mpdu[8]; - mic_header1[9] = mpdu[9]; - mic_header1[10] = mpdu[10]; /* A2 */ - mic_header1[11] = mpdu[11]; - mic_header1[12] = mpdu[12]; - mic_header1[13] = mpdu[13]; - mic_header1[14] = mpdu[14]; - mic_header1[15] = mpdu[15]; -} - -/************************************************/ -/* construct_mic_header2() */ -/* Builds the last MIC header block from */ -/* header fields. */ -/************************************************/ -static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists) -{ - int i; - - for (i = 0; i < 16; i++) - mic_header2[i] = 0x00; - - mic_header2[0] = mpdu[16]; /* A3 */ - mic_header2[1] = mpdu[17]; - mic_header2[2] = mpdu[18]; - mic_header2[3] = mpdu[19]; - mic_header2[4] = mpdu[20]; - mic_header2[5] = mpdu[21]; - - mic_header2[6] = 0x00; - mic_header2[7] = 0x00; /* mpdu[23]; */ - - if (!qc_exists && a4_exists) { - for (i = 0; i < 6; i++) - mic_header2[8+i] = mpdu[24+i]; /* A4 */ - } - - if (qc_exists && !a4_exists) { - mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */ - mic_header2[9] = mpdu[25] & 0x00; - } - - if (qc_exists && a4_exists) { - for (i = 0; i < 6; i++) - mic_header2[8+i] = mpdu[24+i]; /* A4 */ - - mic_header2[14] = mpdu[30] & 0x0f; - mic_header2[15] = mpdu[31] & 0x00; - } -} - -/************************************************/ -/* construct_mic_header2() */ -/* Builds the last MIC header block from */ -/* header fields. */ -/************************************************/ -static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c) -{ - int i; - - for (i = 0; i < 16; i++) - ctr_preload[i] = 0x00; - i = 0; - - ctr_preload[0] = 0x01; /* flag */ - if (qc_exists && a4_exists) - ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */ - if (qc_exists && !a4_exists) - ctr_preload[1] = mpdu[24] & 0x0f; - - for (i = 2; i < 8; i++) - ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ - for (i = 8; i < 14; i++) - ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ - ctr_preload[14] = (unsigned char)(c / 256); /* Ctr */ - ctr_preload[15] = (unsigned char)(c % 256); -} - -/************************************/ -/* bitwise_xor() */ -/* A 128 bit, bitwise exclusive or */ -/************************************/ -static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) -{ - int i; - - for (i = 0; i < 16; i++) - out[i] = ina[i] ^ inb[i]; -} - -static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) -{ - uint qc_exists, a4_exists, i, j, payload_remainder, - num_blocks, payload_index; - - u8 pn_vector[6]; - u8 mic_iv[16]; - u8 mic_header1[16]; - u8 mic_header2[16]; - u8 ctr_preload[16]; - - /* Intermediate Buffers */ - u8 chain_buffer[16]; - u8 aes_out[16]; - u8 padded_buffer[16]; - u8 mic[8]; - uint frtype = GetFrameType(pframe); - uint frsubtype = GetFrameSubType(pframe); - - frsubtype >>= 4; - - memset(mic_iv, 0, 16); - memset(mic_header1, 0, 16); - memset(mic_header2, 0, 16); - memset(ctr_preload, 0, 16); - memset(chain_buffer, 0, 16); - memset(aes_out, 0, 16); - memset(padded_buffer, 0, 16); - - if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) - a4_exists = 0; - else - a4_exists = 1; - - if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) || (frtype == WIFI_DATA_CFACKPOLL)) { - qc_exists = 1; - if (hdrlen != WLAN_HDR_A3_QOS_LEN) - hdrlen += 2; - } else if ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) || (frsubtype == 0x0b)) { - if (hdrlen != WLAN_HDR_A3_QOS_LEN) - hdrlen += 2; - qc_exists = 1; - } else { - qc_exists = 0; - } - - pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; - - construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector); - - construct_mic_header1(mic_header1, hdrlen, pframe); - construct_mic_header2(mic_header2, pframe, a4_exists, qc_exists); - - payload_remainder = plen % 16; - num_blocks = plen / 16; - - /* Find start of payload */ - payload_index = hdrlen + 8; - - /* Calculate MIC */ - aes128k128d(key, mic_iv, aes_out); - bitwise_xor(aes_out, mic_header1, chain_buffer); - aes128k128d(key, chain_buffer, aes_out); - bitwise_xor(aes_out, mic_header2, chain_buffer); - aes128k128d(key, chain_buffer, aes_out); - - for (i = 0; i < num_blocks; i++) { - bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ - - payload_index += 16; - aes128k128d(key, chain_buffer, aes_out); - } - - /* Add on the final payload block if it needs padding */ - if (payload_remainder > 0) { - for (j = 0; j < 16; j++) - padded_buffer[j] = 0x00; - for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */ - bitwise_xor(aes_out, padded_buffer, chain_buffer); - aes128k128d(key, chain_buffer, aes_out); - } - - for (j = 0; j < 8; j++) - mic[j] = aes_out[j]; - - /* Insert MIC into payload */ - for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; - - payload_index = hdrlen + 8; - for (i = 0; i < num_blocks; i++) { - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); - aes128k128d(key, ctr_preload, aes_out); - bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); - for (j = 0; j < 16; j++) - pframe[payload_index++] = chain_buffer[j]; - } - - if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ - /* encrypt it and copy the unpadded part back */ - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); - - for (j = 0; j < 16; j++) - padded_buffer[j] = 0x00; - for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j]; - aes128k128d(key, ctr_preload, aes_out); - bitwise_xor(aes_out, padded_buffer, chain_buffer); - for (j = 0; j < payload_remainder; j++) - pframe[payload_index++] = chain_buffer[j]; - } - /* Encrypt the MIC */ - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, 0); - - for (j = 0; j < 16; j++) - padded_buffer[j] = 0x00; - for (j = 0; j < 8; j++) - padded_buffer[j] = pframe[j+hdrlen+8+plen]; - - aes128k128d(key, ctr_preload, aes_out); - bitwise_xor(aes_out, padded_buffer, chain_buffer); - for (j = 0; j < 8; j++) - pframe[payload_index++] = chain_buffer[j]; - return _SUCCESS; -} - u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) -{ /* exclude ICV */ - - /*static*/ -/* unsigned char message[MAX_MSG_SIZE]; */ - - /* Intermediate Buffers */ +{ int curfragnum, length; - u8 *pframe, *prwskey; /* *payload,*iv */ + u8 *pframe; /* *payload,*iv */ u8 hw_hdr_offset = 0; struct sta_info *stainfo; struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - -/* uint offset = 0; */ u32 res = _SUCCESS; + void *crypto_private; + struct sk_buff *skb; + struct lib80211_crypto_ops *crypto_ops; + const int key_idx = IS_MCAST(pattrib->ra) ? psecuritypriv->dot118021XGrpKeyid : 0; + const int key_length = 16; + u8 *key; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -976,40 +488,81 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt == _AES_) { - if (pattrib->psta) - stainfo = pattrib->psta; - else - stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); + if (pattrib->encrypt != _AES_) + return res; - if (stainfo) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - if (IS_MCAST(pattrib->ra)) - prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; - else - prwskey = &stainfo->dot118021x_UncstKey.skey[0]; - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - - aes_cipher(prwskey, pattrib->hdrlen, pframe, length); - } else{ - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - - aes_cipher(prwskey, pattrib->hdrlen, pframe, length); - pframe += pxmitpriv->frag_len; - pframe = (u8 *)round_up((size_t)(pframe), 8); - } - } - } else{ - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); - res = _FAIL; - } + if (!stainfo) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); + return _FAIL; } + crypto_ops = try_then_request_module(lib80211_get_crypto_ops("CCMP"), "lib80211_crypt_ccmp"); - return res; + if (IS_MCAST(pattrib->ra)) + key = psecuritypriv->dot118021XGrpKey[key_idx].skey; + else + key = stainfo->dot118021x_UncstKey.skey; + + if (!crypto_ops) { + res = _FAIL; + goto exit; + } + + crypto_private = crypto_ops->init(key_idx); + if (!crypto_private) { + res = _FAIL; + goto exit; + } + + if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) { + res = _FAIL; + goto exit_crypto_ops_deinit; + } + + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + if ((curfragnum+1) == pattrib->nr_frags) + length = pattrib->last_txcmdsz; + else + length = pxmitpriv->frag_len; + + skb = dev_alloc_skb(length); + if (!skb) { + res = _FAIL; + goto exit_crypto_ops_deinit; + } + + skb_put_data(skb, pframe, length); + + memmove(skb->data + pattrib->iv_len, skb->data, pattrib->hdrlen); + skb_pull(skb, pattrib->iv_len); + skb_trim(skb, skb->len - pattrib->icv_len); + + if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, crypto_private)) { + kfree_skb(skb); + res = _FAIL; + goto exit_crypto_ops_deinit; + } + + memcpy(pframe, skb->data, skb->len); + + pframe += skb->len; + pframe = (u8 *)round_up((size_t)(pframe), 8); + + kfree_skb(skb); + } + +exit_crypto_ops_deinit: + crypto_ops->deinit(crypto_private); + +exit: + return res; } u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) @@ -1085,190 +638,3 @@ exit_lib80211_ccmp: exit: return res; } - -/* AES tables*/ -const u32 Te0[256] = { - 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, - 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, - 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, - 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, - 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, - 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, - 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, - 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, - 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, - 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, - 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, - 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, - 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, - 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, - 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, - 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, - 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, - 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, - 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, - 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, - 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, - 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, - 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, - 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, - 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, - 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, - 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, - 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, - 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, - 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, - 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, - 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, - 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, - 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, - 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, - 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, - 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, - 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, - 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, - 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, - 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, - 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, - 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, - 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, - 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, - 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, - 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, - 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, - 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, - 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, - 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, - 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, - 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, - 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, - 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, - 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, - 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, - 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, - 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, - 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, - 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, - 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, - 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, - 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, -}; - -const u32 Td0[256] = { - 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, - 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, - 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, - 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, - 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, - 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, - 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, - 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, - 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, - 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, - 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, - 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, - 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, - 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, - 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, - 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, - 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, - 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, - 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, - 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, - 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, - 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, - 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, - 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, - 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, - 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, - 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, - 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, - 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, - 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, - 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, - 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, - 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, - 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, - 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, - 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, - 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, - 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, - 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, - 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, - 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, - 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, - 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, - 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, - 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, - 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, - 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, - 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, - 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, - 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, - 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, - 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, - 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, - 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, - 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, - 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, - 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, - 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, - 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, - 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, - 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, - 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, - 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, - 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, -}; - -const u8 Td4s[256] = { - 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, - 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, - 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U, - 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU, - 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU, - 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU, - 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U, - 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U, - 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U, - 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U, - 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU, - 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U, - 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU, - 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U, - 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U, - 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU, - 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU, - 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U, - 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U, - 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU, - 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U, - 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU, - 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U, - 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U, - 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U, - 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU, - 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU, - 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU, - 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U, - 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U, - 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, - 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, -}; -const u8 rcons[] = { - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 - /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ -}; - -/** - * Expand the cipher key into the encryption key schedule. - * - * @return the number of rounds for the given cipher key size. - */ -#define ROUND(i, d, s) \ -do { \ - d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \ - d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \ - d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \ - d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \ -} while (0) From 0b37913150c93002127e728925353b80677eb5f1 Mon Sep 17 00:00:00 2001 From: Cristian Kubis Date: Sun, 15 Jul 2018 00:25:40 +0200 Subject: [PATCH 400/903] staging: olpc_dcon: prefer 'help' in KConfig Fix for a style warning reported by checkpatch.pl in KConfig suggesting to use 'help' instead of '---help---'. Signed-off-by: Cristian Kubis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/olpc_dcon/Kconfig b/drivers/staging/olpc_dcon/Kconfig index d277f048789e..c91a56f77bcb 100644 --- a/drivers/staging/olpc_dcon/Kconfig +++ b/drivers/staging/olpc_dcon/Kconfig @@ -4,7 +4,7 @@ config FB_OLPC_DCON depends on I2C depends on (GPIO_CS5535 || GPIO_CS5535=n) select BACKLIGHT_CLASS_DEVICE - ---help--- + help In order to support very low power operation, the XO laptop uses a secondary Display CONtroller, or DCON. This secondary controller is present in the video pipeline between the primary display @@ -18,7 +18,7 @@ config FB_OLPC_DCON_1 bool "OLPC XO-1 DCON support" depends on FB_OLPC_DCON && GPIO_CS5535 default y - ---help--- + help Enable support for the DCON in XO-1 model laptops. The kernel communicates with the DCON using model-specific code. If you have an XO-1 (or if you're unsure what model you have), you should @@ -28,7 +28,7 @@ config FB_OLPC_DCON_1_5 bool "OLPC XO-1.5 DCON support" depends on FB_OLPC_DCON && ACPI default y - ---help--- + help Enable support for the DCON in XO-1.5 model laptops. The kernel communicates with the DCON using model-specific code. If you have an XO-1.5 (or if you're unsure what model you have), you From 9b59883c14267ccf2c3f9d260bd6fb0dc9478fa1 Mon Sep 17 00:00:00 2001 From: Cristian Kubis Date: Sun, 15 Jul 2018 00:25:41 +0200 Subject: [PATCH 401/903] staging: olpc_dcon: add missing identifier names Add missing function argument identifier names as suggested by checkpatch.pl. Signed-off-by: Cristian Kubis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h index fa89bb97c7b0..c987aaf894e7 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.h +++ b/drivers/staging/olpc_dcon/olpc_dcon.h @@ -91,10 +91,10 @@ struct dcon_priv { }; struct dcon_platform_data { - int (*init)(struct dcon_priv *); + int (*init)(struct dcon_priv *dcon); void (*bus_stabilize_wiggle)(void); - void (*set_dconload)(int); - int (*read_status)(u8 *); + void (*set_dconload)(int load); + int (*read_status)(u8 *status); }; #include From bb4e1ca9b2008c0dc124ec39b68e94964f45e8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20H=C3=BCbers?= Date: Fri, 13 Jul 2018 15:41:03 +0200 Subject: [PATCH 402/903] staging: mt7621-pci: Include preferred headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following checkpatch warnings: Use #include instead of Use #include instead of Signed-off-by: Oliver Hübers Signed-off-by: Vanessa Borgmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 4f568401b37e..e092b5dc2bc1 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -44,8 +44,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include From 884d5ba53f22bf857cce790d2623dd4f1df34644 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 13 Jul 2018 20:05:08 +0200 Subject: [PATCH 403/903] staging: rtl8188eu: remove is_{multicast,broadcast}_mac_addr Remove custom is_multicast_mac_addr() and is_broadcast_mac_addr(). Use is_multicast_ether_addr() instead. By definition the broadcast address is also a multicast address. is_multicast_ether_addr() returns true for broadcast addresses. Hence checking for multicast in the conditional is sufficient. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 3 +-- drivers/staging/rtl8188eu/include/ieee80211.h | 11 ----------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 79567cf470de..53c65d5463c0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -952,8 +952,7 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, if (!memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->pkt->data), ETH_ALEN)) psta->sta_stats.rx_probersp_pkts++; - else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->pkt->data)) || - is_multicast_mac_addr(GetAddr1Ptr(precv_frame->pkt->data))) + else if (is_multicast_ether_addr(GetAddr1Ptr(precv_frame->pkt->data))) psta->sta_stats.rx_probersp_bm_pkts++; else psta->sta_stats.rx_probersp_uo_pkts++; diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index 1668bb531ead..3fbd92a95b17 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -515,17 +515,6 @@ enum ieee80211_state { #define DEFAULT_MAX_SCAN_AGE (15 * HZ) #define DEFAULT_FTS 2346 -static inline int is_multicast_mac_addr(const u8 *addr) -{ - return ((addr[0] != 0xff) && (0x01 & addr[0])); -} - -static inline int is_broadcast_mac_addr(const u8 *addr) -{ - return (addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && - (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff); -} - #define CFG_IEEE80211_RESERVE_FCS BIT(0) #define CFG_IEEE80211_COMPUTE_FCS BIT(1) From 7d6bc56932de5c0b337b783dc837e9d92f24c45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20H=C3=BCbers?= Date: Fri, 13 Jul 2018 15:41:06 +0200 Subject: [PATCH 404/903] staging: mt7621: Add SPDX license identifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Oliver Hübers Signed-off-by: Vanessa Borgmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index e092b5dc2bc1..650e49b995e3 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /************************************************************************** * * BRIEF MODULE DESCRIPTION From 8c6ade2e0c8b42d13d6dd7d4b0c30b11afea98a9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Jul 2018 14:52:36 +0200 Subject: [PATCH 405/903] staging: rtl8188eu: do not line break function definition Do not line break function definition of Efuse_PowerSwitch(). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 3ac3dd796ec9..367cb2cf8ad1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -29,10 +29,7 @@ enum{ * and disable LDO 2.5V. */ -void Efuse_PowerSwitch( - struct adapter *pAdapter, - u8 bWrite, - u8 PwrState) +void Efuse_PowerSwitch(struct adapter *pAdapter, u8 bWrite, u8 PwrState) { u8 tempval; u16 tmpV16; From c7279e34cb8f19ffcd4d886dcb1898cccb23e4c4 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Jul 2018 14:52:37 +0200 Subject: [PATCH 406/903] staging: rtl8188eu: rename Efuse_PowerSwitch Rename function to avoid CamelCase. Efuse_PowerSwitch -> efuse_power_switch Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 8 ++++---- drivers/staging/rtl8188eu/include/rtw_efuse.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 367cb2cf8ad1..fa145cd89613 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -22,14 +22,14 @@ enum{ }; /* - * Function: Efuse_PowerSwitch + * Function: efuse_power_switch * * Overview: When we want to enable write operation, we should change to * pwr on state. When we stop write, we should switch to 500k mode * and disable LDO 2.5V. */ -void Efuse_PowerSwitch(struct adapter *pAdapter, u8 bWrite, u8 PwrState) +void efuse_power_switch(struct adapter *pAdapter, u8 bWrite, u8 PwrState) { u8 tempval; u16 tmpV16; @@ -896,11 +896,11 @@ void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) */ static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 efuseType, u8 *Efuse) { - Efuse_PowerSwitch(pAdapter, false, true); + efuse_power_switch(pAdapter, false, true); efuse_ReadEFuse(pAdapter, efuseType, 0, EFUSE_MAP_LEN_88E, Efuse); - Efuse_PowerSwitch(pAdapter, false, false); + efuse_power_switch(pAdapter, false, false); } /* diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h index adfbf3571c8b..e125bab0caf1 100644 --- a/drivers/staging/rtl8188eu/include/rtw_efuse.h +++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h @@ -82,7 +82,7 @@ u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data); void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf); -void Efuse_PowerSwitch(struct adapter *adapt, u8 bWrite, u8 PwrState); +void efuse_power_switch(struct adapter *adapt, u8 bWrite, u8 PwrState); int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data); bool Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data); void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); From b5a870456fd73a378605332a9f8a2dd6f4932cce Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Jul 2018 14:52:38 +0200 Subject: [PATCH 407/903] staging: rtl8188eu: rename function parameters Rename function parameters to avoid CamelCase. bWrite -> write PwrState -> pwrstate Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 8 ++++---- drivers/staging/rtl8188eu/include/rtw_efuse.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index fa145cd89613..004b786de37e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -29,12 +29,12 @@ enum{ * and disable LDO 2.5V. */ -void efuse_power_switch(struct adapter *pAdapter, u8 bWrite, u8 PwrState) +void efuse_power_switch(struct adapter *pAdapter, u8 write, u8 pwrstate) { u8 tempval; u16 tmpV16; - if (PwrState) { + if (pwrstate) { usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), default valid */ @@ -57,7 +57,7 @@ void efuse_power_switch(struct adapter *pAdapter, u8 bWrite, u8 PwrState) usb_write16(pAdapter, REG_SYS_CLKR, tmpV16); } - if (bWrite) { + if (write) { /* Enable LDO 2.5V before read/write action */ tempval = usb_read8(pAdapter, EFUSE_TEST+3); tempval &= 0x0F; @@ -67,7 +67,7 @@ void efuse_power_switch(struct adapter *pAdapter, u8 bWrite, u8 PwrState) } else { usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); - if (bWrite) { + if (write) { /* Disable LDO 2.5V after read/write action */ tempval = usb_read8(pAdapter, EFUSE_TEST+3); usb_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h index e125bab0caf1..3ec53761e9fd 100644 --- a/drivers/staging/rtl8188eu/include/rtw_efuse.h +++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h @@ -82,7 +82,7 @@ u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data); void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf); -void efuse_power_switch(struct adapter *adapt, u8 bWrite, u8 PwrState); +void efuse_power_switch(struct adapter *adapt, u8 write, u8 pwrstate); int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data); bool Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data); void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); From 3cedbfb8519960c56610d308bd3c8c13c71273cc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Jul 2018 14:52:39 +0200 Subject: [PATCH 408/903] staging: rtl8188eu: rename variable Rename variable to avoid CamelCase. tmpV16 -> tmpv16 Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 004b786de37e..93d20bc758e7 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -32,29 +32,29 @@ enum{ void efuse_power_switch(struct adapter *pAdapter, u8 write, u8 pwrstate) { u8 tempval; - u16 tmpV16; + u16 tmpv16; if (pwrstate) { usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), default valid */ - tmpV16 = usb_read16(pAdapter, REG_SYS_ISO_CTRL); - if (!(tmpV16 & PWC_EV12V)) { - tmpV16 |= PWC_EV12V; - usb_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); + tmpv16 = usb_read16(pAdapter, REG_SYS_ISO_CTRL); + if (!(tmpv16 & PWC_EV12V)) { + tmpv16 |= PWC_EV12V; + usb_write16(pAdapter, REG_SYS_ISO_CTRL, tmpv16); } /* Reset: 0x0000h[28], default valid */ - tmpV16 = usb_read16(pAdapter, REG_SYS_FUNC_EN); - if (!(tmpV16 & FEN_ELDR)) { - tmpV16 |= FEN_ELDR; - usb_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16); + tmpv16 = usb_read16(pAdapter, REG_SYS_FUNC_EN); + if (!(tmpv16 & FEN_ELDR)) { + tmpv16 |= FEN_ELDR; + usb_write16(pAdapter, REG_SYS_FUNC_EN, tmpv16); } /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ - tmpV16 = usb_read16(pAdapter, REG_SYS_CLKR); - if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { - tmpV16 |= (LOADER_CLK_EN | ANA8M); - usb_write16(pAdapter, REG_SYS_CLKR, tmpV16); + tmpv16 = usb_read16(pAdapter, REG_SYS_CLKR); + if ((!(tmpv16 & LOADER_CLK_EN)) || (!(tmpv16 & ANA8M))) { + tmpv16 |= (LOADER_CLK_EN | ANA8M); + usb_write16(pAdapter, REG_SYS_CLKR, tmpv16); } if (write) { From cfd707e2f79a1c8c116ae94756717daf960ddf5d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Jul 2018 14:52:40 +0200 Subject: [PATCH 409/903] staging: rtl8188eu: add spaces around '+' Add spaces around '+' to follow kernel coding style. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 93d20bc758e7..b19aa26d1705 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -59,18 +59,18 @@ void efuse_power_switch(struct adapter *pAdapter, u8 write, u8 pwrstate) if (write) { /* Enable LDO 2.5V before read/write action */ - tempval = usb_read8(pAdapter, EFUSE_TEST+3); + tempval = usb_read8(pAdapter, EFUSE_TEST + 3); tempval &= 0x0F; tempval |= (VOLTAGE_V25 << 4); - usb_write8(pAdapter, EFUSE_TEST+3, (tempval | 0x80)); + usb_write8(pAdapter, EFUSE_TEST + 3, (tempval | 0x80)); } } else { usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); if (write) { /* Disable LDO 2.5V after read/write action */ - tempval = usb_read8(pAdapter, EFUSE_TEST+3); - usb_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); + tempval = usb_read8(pAdapter, EFUSE_TEST + 3); + usb_write8(pAdapter, EFUSE_TEST + 3, (tempval & 0x7F)); } } } From 65f3264177e4c131cc2904739bccb6db9e92c3dc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Jul 2018 14:52:41 +0200 Subject: [PATCH 410/903] staging: rtl8188eu: remove redundant header file Both functions declared in rtl8188e_led.h are also declared in rtw_led.h which is included from drv_types.h. Remove rtl8188e_led.h and it's includes. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 1 - drivers/staging/rtl8188eu/hal/usb_halinit.c | 1 - .../staging/rtl8188eu/include/rtl8188e_led.h | 20 ------------------- 3 files changed, 22 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_led.h diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index ca0b0f1c2a7f..412b76271a3d 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -8,7 +8,6 @@ #include #include #include -#include #include /* LED object. */ diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 4b3ece90bb34..d551d0cca90b 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_led.h b/drivers/staging/rtl8188eu/include/rtl8188e_led.h deleted file mode 100644 index 74f2554e41d3..000000000000 --- a/drivers/staging/rtl8188eu/include/rtl8188e_led.h +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTL8188E_LED_H__ -#define __RTL8188E_LED_H__ - -#include -#include - - -/* */ -/* Interface to manipulate LED objects. */ -/* */ -void SwLedOn(struct adapter *padapter, struct LED_871x *pLed); -void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); - -#endif From 642e0692bea6e7393c01e7074a55b491700f9e6e Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Sat, 14 Jul 2018 21:14:58 +0530 Subject: [PATCH 411/903] staging: comedi: comedi_fops: Shift assignment operator '=' to previous line Shift '=' assignment operator to the end of previous line to conform to preferred kernel style line wrapping. Issue reported by checkpatch CHECK. Signed-off-by: Nishad Kamdar Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 1f3b1106f478..e18b61cdbdeb 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -79,8 +79,8 @@ MODULE_PARM_DESC(comedi_default_buf_size_kb, "default asynchronous buffer size in KiB (default " __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB) ")"); -unsigned int comedi_default_buf_maxsize_kb - = CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB; +unsigned int comedi_default_buf_maxsize_kb = + CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB; module_param(comedi_default_buf_maxsize_kb, uint, 0644); MODULE_PARM_DESC(comedi_default_buf_maxsize_kb, "default maximum size of asynchronous buffer in KiB (default " From 66558395e1bb4e02221a9a9c5c0cf5087cd4b0ba Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Mon, 16 Jul 2018 11:29:59 +0200 Subject: [PATCH 412/903] staging: fbtft: Fix line over 80 characters Fix checkpatch line over 80 characters where it seemed appropriate Signed-off-by: Matthias Wolf Signed-off-by: Felix Siegel Signed-off-by: Tim Cofala Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_s6d02a1.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/staging/fbtft/fb_s6d02a1.c b/drivers/staging/fbtft/fb_s6d02a1.c index 75295760f491..55513a395567 100644 --- a/drivers/staging/fbtft/fb_s6d02a1.c +++ b/drivers/staging/fbtft/fb_s6d02a1.c @@ -21,20 +21,27 @@ static const s16 default_init_sequence[] = { -1, 0xfc, 0x5a, 0x5a, - -1, 0xfa, 0x02, 0x1f, 0x00, 0x10, 0x22, 0x30, 0x38, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3d, 0x02, 0x01, + -1, 0xfa, 0x02, 0x1f, 0x00, 0x10, 0x22, 0x30, 0x38, + 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3d, 0x02, 0x01, - -1, 0xfb, 0x21, 0x00, 0x02, 0x04, 0x07, 0x0a, 0x0b, 0x0c, 0x0c, 0x16, 0x1e, 0x30, 0x3f, 0x01, 0x02, + -1, 0xfb, 0x21, 0x00, 0x02, 0x04, 0x07, 0x0a, 0x0b, + 0x0c, 0x0c, 0x16, 0x1e, 0x30, 0x3f, 0x01, 0x02, /* power setting sequence */ - -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x01, 0x01, 0x00, 0x1f, 0x1f, + -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x01, + 0x01, 0x00, 0x1f, 0x1f, - -1, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, + -1, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, + 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, - -1, 0xf5, 0x00, 0x70, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x66, 0x06, + -1, 0xf5, 0x00, 0x70, 0x66, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x6d, 0x66, 0x06, - -1, 0xf6, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x01, 0x00, + -1, 0xf6, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x06, 0x01, 0x00, - -1, 0xf2, 0x00, 0x01, 0x03, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x08, 0x08, + -1, 0xf2, 0x00, 0x01, 0x03, 0x08, 0x08, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x08, 0x08, -1, 0xf8, 0x11, @@ -54,7 +61,8 @@ static const s16 default_init_sequence[] = { -1, 0xf3, 0x00, 0x0f, -2, 50, - -1, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, + -1, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3f, 0x3f, + 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, -2, 50, -1, 0xf3, 0x00, 0x1f, @@ -65,9 +73,11 @@ static const s16 default_init_sequence[] = { -1, 0xf3, 0x00, 0xff, -2, 50, - -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x00, 0x01, 0x00, 0x16, 0x16, + -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x00, + 0x01, 0x00, 0x16, 0x16, - -1, 0xf4, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, + -1, 0xf4, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3f, 0x3f, + 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, /* initializing sequence */ From ab608b341b482f1ab5a6fd43ff853a7627107b19 Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Mon, 16 Jul 2018 11:30:00 +0200 Subject: [PATCH 413/903] staging: fbtft: Fix line continuation Fix checkpatch warning: avoid unnecessary line continuation to allow grepping of whole error message. Signed-off-by: Matthias Wolf Signed-off-by: Felix Siegel Signed-off-by: Tim Cofala Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_ssd1351.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fbtft/fb_ssd1351.c b/drivers/staging/fbtft/fb_ssd1351.c index b8ef75f5e856..1b92691ac7cc 100644 --- a/drivers/staging/fbtft/fb_ssd1351.c +++ b/drivers/staging/fbtft/fb_ssd1351.c @@ -126,16 +126,14 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) for (i = 0; i < 63; i++) { if (i > 0 && curves[i] < 2) { dev_err(par->info->device, - "Illegal value in Grayscale Lookup Table at index %d. " \ - "Must be greater than 1\n", i); + "Illegal value in Grayscale Lookup Table at index %d. Must be greater than 1\n", i); return -EINVAL; } acc += curves[i]; tmp[i] = acc; if (acc > 180) { dev_err(par->info->device, - "Illegal value(s) in Grayscale Lookup Table. " \ - "At index=%d, the accumulated value has exceeded 180\n", i); + "Illegal value(s) in Grayscale Lookup Table. At index=%d, the accumulated value has exceeded 180\n", i); return -EINVAL; } } From 173a4906aebe14fccc6cd338efda618fd69d56de Mon Sep 17 00:00:00 2001 From: Tobias Lindskog Date: Fri, 6 Jul 2018 14:44:16 -0700 Subject: [PATCH 414/903] staging: android: ashmem: Shrink directly through shmem_fallocate When ashmem_shrink is called from direct reclaim on a user thread, a call to do_fallocate will check for permissions against the security policy of that user thread. It can thus fail by chance if called on a thread that isn't permitted to modify the relevant ashmem areas. Because we know that we have a shmem file underneath, call the shmem implementation of fallocate directly instead of going through the user-space interface for fallocate. Signed-off-by: Tobias Lindskog Signed-off-by: Jeff Vander Stoep Signed-off-by: Joel Fernandes (Google) Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index e392358ec244..b73cc1e089a3 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -450,9 +450,9 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) loff_t start = range->pgstart * PAGE_SIZE; loff_t end = (range->pgend + 1) * PAGE_SIZE; - vfs_fallocate(range->asma->file, - FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, - start, end - start); + range->asma->file->f_op->fallocate(range->asma->file, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, + start, end - start); range->purged = ASHMEM_WAS_PURGED; lru_del(range); From 7e8a450aa0e62545af996db1f8b863d3e8c18220 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:42 -0700 Subject: [PATCH 415/903] staging: gasket: fix typo in apex_enter_reset Fix typo in log message. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index cca4cf491a58..a31937dfff83 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -488,7 +488,7 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) APEX_BAR2_REG_USER_HIB_DMA_PAUSED, 1, 1, APEX_RESET_DELAY, APEX_RESET_RETRY)) { gasket_log_error(gasket_dev, - "DMAs did not quiece within timeout (%d ms)", + "DMAs did not quiesce within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); return -EINVAL; } From 920953ab4ed51fb2c971822dc593ca132913a4d2 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:43 -0700 Subject: [PATCH 416/903] staging: gasket: fix typo in gasket_core.h comments Grammar fixup in gasket_core.h comments describing struct gasket_interrupt_desc. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index e51acadc0fc4..94a5537bff2c 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -56,7 +56,7 @@ enum gasket_interrupt_type { /* Used to describe a Gasket interrupt. Contains an interrupt index, a register, * and packing data for that interrupt. The register and packing data - * fields is relevant only for PCI_MSIX interrupt type and can be + * fields are relevant only for PCI_MSIX interrupt type and can be * set to 0 for everything else. */ struct gasket_interrupt_desc { From b17cef4d08ac9866f8996015d3bf396f51488a25 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:44 -0700 Subject: [PATCH 417/903] staging: gasket: whitespace fix in gasket_page_table_init Tab replaced with space. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index dcd52e141f95..36a560c87af3 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -347,7 +347,7 @@ int gasket_page_table_init( pg_tbl->config.mode == GASKET_PAGE_TABLE_MODE_SIMPLE) { pg_tbl->num_simple_entries = total_entries; pg_tbl->num_extended_entries = 0; - pg_tbl->extended_flag = 1ull << page_table_config->extended_bit; + pg_tbl->extended_flag = 1ull << page_table_config->extended_bit; } else { pg_tbl->num_simple_entries = 0; pg_tbl->num_extended_entries = total_entries; From ba6585847ebc432e0c808c2bd194e620017b5901 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:45 -0700 Subject: [PATCH 418/903] staging: gasket: remove driver registration on class creation failure If class_create() fails, remove the gasket driver from the global registration table. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index b69b630f1b79..cbadab7544c8 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -335,7 +335,8 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) if (IS_ERR_OR_NULL(internal->class)) { gasket_nodev_error("Cannot register %s class [ret=%ld]", driver_desc->name, PTR_ERR(internal->class)); - return PTR_ERR(internal->class); + ret = PTR_ERR(internal->class); + goto unregister_gasket_driver; } /* @@ -369,6 +370,7 @@ fail2: fail1: class_destroy(internal->class); +unregister_gasket_driver: g_descs[desc_idx].driver_desc = NULL; return ret; } From 722c902aacfefcda4aa0517be82af5cfd2ec4bb0 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:46 -0700 Subject: [PATCH 419/903] staging: gasket: hold mutex on gasket driver unregistration Take the global mutex on driver unregistration updates for proper ordering of updates and consistent access procedures. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index cbadab7544c8..2ff328652356 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -371,7 +371,9 @@ fail1: class_destroy(internal->class); unregister_gasket_driver: + mutex_lock(&g_mutex); g_descs[desc_idx].driver_desc = NULL; + mutex_unlock(&g_mutex); return ret; } EXPORT_SYMBOL(gasket_register_device); @@ -408,7 +410,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) class_destroy(internal_desc->class); /* Finally, effectively "remove" the driver. */ + mutex_lock(&g_mutex); g_descs[desc_idx].driver_desc = NULL; + mutex_unlock(&g_mutex); gasket_nodev_info("removed %s driver", driver_desc->name); } From cf2865a0c70c645c50d2665ca66228872e225ed0 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:47 -0700 Subject: [PATCH 420/903] staging: gasket: Return EBUSY on mapping create when already in use gasket_sysfs_create_mapping() return EBUSY if sysfs mapping already in use, as a more appropriate error code than the current return of EINVAL, which would indicate invalid parameters. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index e3d770630961..dd4d3aaa57e2 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -194,7 +194,7 @@ int gasket_sysfs_create_mapping( "0x%p.", device); put_mapping(mapping); mutex_unlock(&function_mutex); - return -EINVAL; + return -EBUSY; } /* Find the first empty entry in the array. */ From 03c25b3ad0405063f8e82871cfaef627dff4d26b Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:48 -0700 Subject: [PATCH 421/903] staging: gasket: Remove stale pointers on error allocating attr array If gasket_sysfs_create_mapping() hits errors allocating the attribute array, remove stale pointers to device info from the mapping object. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index dd4d3aaa57e2..1c5f7502e0d5 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -225,6 +225,8 @@ int gasket_sysfs_create_mapping( mapping->attribute_count = 0; if (!mapping->attributes) { gasket_nodev_error("Unable to allocate sysfs attribute array."); + mapping->device = NULL; + mapping->gasket_dev = NULL; mutex_unlock(&mapping->mutex); mutex_unlock(&function_mutex); return -ENOMEM; From e24fbaf73f0541994ab3a947bcf6feb5258c9204 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:49 -0700 Subject: [PATCH 422/903] staging: gasket: convert gasket_mmap_has_permissions to bool return gasket_mmap_has_permissions() should return a boolean value. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 2ff328652356..248d717e1df6 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1241,19 +1241,19 @@ static int gasket_release(struct inode *inode, struct file *file) * that the provided descriptor/range is of adequate size to hold the range to * be mapped. */ -static int gasket_mmap_has_permissions( +static bool gasket_mmap_has_permissions( struct gasket_dev *gasket_dev, struct vm_area_struct *vma, int bar_permissions) { int requested_permissions; /* Always allow sysadmin to access. */ if (capable(CAP_SYS_ADMIN)) - return 1; + return true; /* Never allow non-sysadmins to access to a dead device. */ if (gasket_dev->status != GASKET_STATUS_ALIVE) { gasket_log_info(gasket_dev, "Device is dead."); - return 0; + return false; } /* Make sure that no wrong flags are set. */ @@ -1265,7 +1265,7 @@ static int gasket_mmap_has_permissions( "Attempting to map a region with requested permissions " "0x%x, but region has permissions 0x%x.", requested_permissions, bar_permissions); - return 0; + return false; } /* Do not allow a non-owner to write. */ @@ -1275,10 +1275,10 @@ static int gasket_mmap_has_permissions( gasket_dev, "Attempting to mmap a region for write without owning " "device."); - return 0; + return false; } - return 1; + return true; } /* From 24dfee40e6c4b558437db1bdb3c4927cec1bda51 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:50 -0700 Subject: [PATCH 423/903] staging: gasket: fix gasket_wait_with_reschedule timeout return code Return -ETIMEDOUT, not -EINVAL, on timeout, including callers. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 8 ++++---- drivers/staging/gasket/gasket_core.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index a31937dfff83..3a83c3d4d556 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -490,7 +490,7 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) gasket_log_error(gasket_dev, "DMAs did not quiesce within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } /* - Enable GCB reset (0x1 to rg_rst_gcb) */ @@ -513,7 +513,7 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) gasket_dev, "RAM did not shut down within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } return 0; @@ -562,7 +562,7 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) gasket_dev, "RAM did not enable within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } /* - Wait for Reset complete. */ @@ -574,7 +574,7 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) gasket_dev, "GCB did not leave reset within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } if (!allow_hw_clock_gating) { diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 248d717e1df6..803566229bfc 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -2106,7 +2106,7 @@ int gasket_wait_with_reschedule( "%s timeout: reg %llx timeout (%llu ms)", __func__, offset, max_retries * delay_ms); - return -EINVAL; + return -ETIMEDOUT; } return 0; } From c17acfdf4ad544144bd1a9fa3d19725cad0b236d Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:51 -0700 Subject: [PATCH 424/903] staging: gasket: gasket_wait_with_reschedule use msleep Replace schedule_timeout() call with msleep() for simplicity. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 803566229bfc..442543573f6e 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -14,6 +14,7 @@ #include "gasket_page_table.h" #include "gasket_sysfs.h" +#include #include #include #include @@ -2097,7 +2098,7 @@ int gasket_wait_with_reschedule( tmp = gasket_dev_read_64(gasket_dev, bar, offset); if ((tmp & mask) == val) break; - schedule_timeout(msecs_to_jiffies(delay_ms)); + msleep(delay_ms); retries++; } if (retries == max_retries) { From a42ea3d61c65946f7ccb1fbba7361e31eb367026 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:52 -0700 Subject: [PATCH 425/903] staging: gasket: gasket_wait_with_reschedule simplify logic gasket_wait_with_reschedule() is a little more clear if we just return directly when the waited-for condition is hit. This also allows the following condition check to be removed and identation of the conditionally-executed code to be reduced. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 442543573f6e..5ae3d44f6166 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -2097,18 +2097,12 @@ int gasket_wait_with_reschedule( while (retries < max_retries) { tmp = gasket_dev_read_64(gasket_dev, bar, offset); if ((tmp & mask) == val) - break; + return 0; msleep(delay_ms); retries++; } - if (retries == max_retries) { - gasket_log_error( - gasket_dev, - "%s timeout: reg %llx timeout (%llu ms)", - __func__, - offset, max_retries * delay_ms); - return -ETIMEDOUT; - } - return 0; + gasket_log_error(gasket_dev, "%s timeout: reg %llx timeout (%llu ms)", + __func__, offset, max_retries * delay_ms); + return -ETIMEDOUT; } EXPORT_SYMBOL(gasket_wait_with_reschedule); From 72a23054a95c5439b779930b6ffa129437178ac9 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:53 -0700 Subject: [PATCH 426/903] staging: gasket: gasket_wait_with_reschedule use 32 bits of retry count Don't need a 64-bit retry counter. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 ++-- drivers/staging/gasket/gasket_core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 5ae3d44f6166..94e64b900380 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -2089,9 +2089,9 @@ struct device *gasket_get_device(struct gasket_dev *dev) **/ int gasket_wait_with_reschedule( struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - u64 max_retries, u64 delay_ms) + uint max_retries, u64 delay_ms) { - u64 retries = 0; + uint retries = 0; u64 tmp; while (retries < max_retries) { diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 94a5537bff2c..50ad0c885318 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -702,6 +702,6 @@ struct device *gasket_get_device(struct gasket_dev *dev); /* Helper function, Asynchronous waits on a given set of bits. */ int gasket_wait_with_reschedule( struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - u64 max_retries, u64 delay_ms); + uint max_retries, u64 delay_ms); #endif /* __GASKET_CORE_H__ */ From 45042402ae97682b965d88f2393f317f48bb0042 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:54 -0700 Subject: [PATCH 427/903] staging: gasket: bail out of reset sequence on device callback error If device reset callback returns an error, error out at the gasket level. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 94e64b900380..bc3662eafb63 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1875,9 +1875,11 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) /* Perform a device reset of the requested type. */ ret = driver_desc->device_reset_cb(gasket_dev, reset_type); - if (ret) + if (ret) { gasket_log_error( gasket_dev, "Device reset cb returned %d.", ret); + return ret; + } /* Reinitialize the page tables and interrupt framework. */ for (i = 0; i < driver_desc->num_page_tables; ++i) From d7db5843bc09c4d8a7d30c09b18c03a1dd5fd713 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 17 Jul 2018 13:56:55 -0700 Subject: [PATCH 428/903] staging: gasket: drop gasket_cdev_get_info, use container_of Remove gasket_cdev_get_info(), use container_of() directly instead, drop unnecessary NULL checks. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index bc3662eafb63..0d5ba7359af7 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -233,18 +233,6 @@ static inline int gasket_check_and_invoke_callback_nolock( return ret; } -/* - * Retrieve device-specific data via cdev pointer. - * @cdev_ptr: Character device pointer associated with the device. - * - * This function returns the pointer to the device-specific data allocated in - * add_dev_cb for the device associated with cdev_ptr. - */ -static struct gasket_cdev_info *gasket_cdev_get_info(struct cdev *cdev_ptr) -{ - return container_of(cdev_ptr, struct gasket_cdev_info, cdev); -} - /* * Returns nonzero if the gasket_cdev_info is owned by the current thread group * ID. @@ -1095,12 +1083,9 @@ static int gasket_open(struct inode *inode, struct file *filp) const struct gasket_driver_desc *driver_desc; struct gasket_ownership *ownership; char task_name[TASK_COMM_LEN]; - struct gasket_cdev_info *dev_info = gasket_cdev_get_info(inode->i_cdev); + struct gasket_cdev_info *dev_info = + container_of(inode->i_cdev, struct gasket_cdev_info, cdev); - if (!dev_info) { - gasket_nodev_error("Unable to retrieve device data"); - return -EINVAL; - } gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; ownership = &dev_info->ownership; @@ -1182,11 +1167,8 @@ static int gasket_release(struct inode *inode, struct file *file) const struct gasket_driver_desc *driver_desc; char task_name[TASK_COMM_LEN]; struct gasket_cdev_info *dev_info = - (struct gasket_cdev_info *)gasket_cdev_get_info(inode->i_cdev); - if (!dev_info) { - gasket_nodev_error("Unable to retrieve device data"); - return -EINVAL; - } + container_of(inode->i_cdev, struct gasket_cdev_info, cdev); + gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; ownership = &dev_info->ownership; From ec54d1abef2ccef6dde1028c0666717d6b636611 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:01 -0700 Subject: [PATCH 429/903] staging: gasket: allow compile for ARM64 in Kconfig The gasket and apex drivers are also to be used on ARM64 architectures. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/Kconfig b/drivers/staging/gasket/Kconfig index c836389c1402..970e299046c3 100644 --- a/drivers/staging/gasket/Kconfig +++ b/drivers/staging/gasket/Kconfig @@ -2,7 +2,7 @@ menu "Gasket devices" config STAGING_GASKET_FRAMEWORK tristate "Gasket framework" - depends on PCI && X86_64 + depends on PCI && (X86_64 || ARM64) help This framework supports Gasket-compatible devices, such as Apex. It is required for any of the following module(s). From 7a013c5026df8fea863c13f414b5bda93039a906 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:02 -0700 Subject: [PATCH 430/903] staging: gasket: gasket_enable_dev remove unnecessary variable Remove unnecessary variable, pass constant param instead. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 0d5ba7359af7..f327c9d7f90a 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -898,7 +898,6 @@ static int gasket_enable_dev( { int tbl_idx; int ret; - bool has_dma_ops; struct device *ddev; const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc; @@ -917,8 +916,6 @@ static int gasket_enable_dev( return ret; } - has_dma_ops = true; - for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { gasket_log_debug( gasket_dev, "Initializing page table %d.", tbl_idx); @@ -936,7 +933,7 @@ static int gasket_enable_dev( &gasket_dev->bar_data[ driver_desc->page_table_bar_index], &driver_desc->page_table_configs[tbl_idx], - ddev, gasket_dev->pci_dev, has_dma_ops); + ddev, gasket_dev->pci_dev, true); if (ret) { gasket_log_error( gasket_dev, From b6fdbbb743ce86030d0898b53d64ff009fd50faa Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:03 -0700 Subject: [PATCH 431/903] staging: gasket: remove code for no physical device gasket_enable_dev code for enabling a gasket device with no physical PCI device registered shouldn't be necessary. Reported-by: Greg Kroah-Hartman Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index f327c9d7f90a..18cc8e3283b3 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -898,7 +898,6 @@ static int gasket_enable_dev( { int tbl_idx; int ret; - struct device *ddev; const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc; @@ -919,21 +918,12 @@ static int gasket_enable_dev( for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { gasket_log_debug( gasket_dev, "Initializing page table %d.", tbl_idx); - if (gasket_dev->pci_dev) { - ddev = &gasket_dev->pci_dev->dev; - } else { - gasket_log_error( - gasket_dev, - "%s with no physical device!!", __func__); - WARN_ON(1); - ddev = NULL; - } ret = gasket_page_table_init( &gasket_dev->page_table[tbl_idx], &gasket_dev->bar_data[ driver_desc->page_table_bar_index], &driver_desc->page_table_configs[tbl_idx], - ddev, gasket_dev->pci_dev, true); + &gasket_dev->pci_dev->dev, gasket_dev->pci_dev, true); if (ret) { gasket_log_error( gasket_dev, From ae27b2f9f76afc7bf77ef6001ba47fad43a9fce3 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:04 -0700 Subject: [PATCH 432/903] staging: gasket: fix class create bug handling class_create() never returns NULL, and this driver should never return PTR_ERR(NULL) anyway. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Reviewed-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 18cc8e3283b3..53236e1ba4e4 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -321,7 +321,7 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) internal->class = class_create(driver_desc->module, driver_desc->name); - if (IS_ERR_OR_NULL(internal->class)) { + if (IS_ERR(internal->class)) { gasket_nodev_error("Cannot register %s class [ret=%ld]", driver_desc->name, PTR_ERR(internal->class)); ret = PTR_ERR(internal->class); From ed6e96c7951b85bb5c6a50503baa2fd9bfbb0510 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:05 -0700 Subject: [PATCH 433/903] staging: gasket: remove unnecessary code in coherent allocator Remove extraneous statement in gasket_config_coherent_allocator() Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 0c2f85cf5448..d0142ed048a6 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -420,10 +420,8 @@ static int gasket_config_coherent_allocator( if (ibuf.page_table_index >= gasket_dev->num_page_tables) return -EFAULT; - if (ibuf.size > PAGE_SIZE * MAX_NUM_COHERENT_PAGES) { - ibuf.size = PAGE_SIZE * MAX_NUM_COHERENT_PAGES; + if (ibuf.size > PAGE_SIZE * MAX_NUM_COHERENT_PAGES) return -ENOMEM; - } if (ibuf.enable == 0) { ret = gasket_free_coherent_memory( From ec45f01668e42f3dc3f18e11fa8655ad150ca250 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:06 -0700 Subject: [PATCH 434/903] staging: gasket: don't treat no device reset callback as an error It is not an error for a device to not have a reset callback registered. Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 53236e1ba4e4..eb5ad161ccda 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1836,11 +1836,8 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) const struct gasket_driver_desc *driver_desc; driver_desc = gasket_dev->internal_desc->driver_desc; - if (!driver_desc->device_reset_cb) { - gasket_log_error( - gasket_dev, "No device reset callback was registered."); - return -EINVAL; - } + if (!driver_desc->device_reset_cb) + return 0; /* Perform a device reset of the requested type. */ ret = driver_desc->device_reset_cb(gasket_dev, reset_type); From e80d8afc97fb243833d9939b5098a89379433b3c Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:07 -0700 Subject: [PATCH 435/903] staging: gasket: gasket_mmap return error instead of valid BAR index When offset to be mapped matches both a BAR region and a coherent mapped region return an error as intended, not the BAR index. Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index eb5ad161ccda..3cf918f9d260 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1627,7 +1627,7 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) "0x%lx", raw_offset); trace_gasket_mmap_exit(bar_index); - return bar_index; + return -EINVAL; } vma->vm_private_data = gasket_dev; From 9116223b84da485735b495bda6c35b43f005d222 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:08 -0700 Subject: [PATCH 436/903] staging: gasket: apex_clock_gating simplify logic, reduce indentation Collapse together two checks and return immediately, avoid conditional indentation for most of function code. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 43 +++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 3a83c3d4d556..a01b1f2b827e 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -666,33 +666,30 @@ static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg) { struct apex_gate_clock_ioctl ibuf; - if (bypass_top_level) + if (bypass_top_level || !allow_sw_clock_gating) return 0; - if (allow_sw_clock_gating) { - if (copy_from_user(&ibuf, (void __user *)arg, sizeof(ibuf))) - return -EFAULT; + if (copy_from_user(&ibuf, (void __user *)arg, sizeof(ibuf))) + return -EFAULT; - gasket_log_error( - gasket_dev, "%s %llu", __func__, ibuf.enable); + gasket_log_error(gasket_dev, "%s %llu", __func__, ibuf.enable); - if (ibuf.enable) { - /* Quiesce AXI, gate GCB clock. */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_AXI_QUIESCE, 0x1, 1, 16); - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_GCB_CLOCK_GATE, 0x1, 2, 18); - } else { - /* Un-gate GCB clock, un-quiesce AXI. */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_GCB_CLOCK_GATE, 0x0, 2, 18); - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_AXI_QUIESCE, 0x0, 1, 16); - } + if (ibuf.enable) { + /* Quiesce AXI, gate GCB clock. */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_AXI_QUIESCE, 0x1, 1, 16); + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_GCB_CLOCK_GATE, 0x1, 2, 18); + } else { + /* Un-gate GCB clock, un-quiesce AXI. */ + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_GCB_CLOCK_GATE, 0x0, 2, 18); + gasket_read_modify_write_32( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_AXI_QUIESCE, 0x0, 1, 16); } return 0; } From c5172a29d7386753e19f4860351b0fda06863d47 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:09 -0700 Subject: [PATCH 437/903] staging: gasket: gasket page table functions use bool return type Convert from int to bool return type for gasket page table functions that return values used as booleans. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 58 +++++++++++----------- drivers/staging/gasket/gasket_page_table.h | 8 +-- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 36a560c87af3..2a27db658a4e 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -262,16 +262,16 @@ static void gasket_perform_unmapping( static void gasket_free_extended_subtable( struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, u64 __iomem *att_reg); -static int gasket_release_page(struct page *page); +static bool gasket_release_page(struct page *page); /* Other/utility declarations */ -static inline int gasket_addr_is_simple( +static inline bool gasket_addr_is_simple( struct gasket_page_table *pg_tbl, ulong addr); -static int gasket_is_simple_dev_addr_bad( +static bool gasket_is_simple_dev_addr_bad( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); -static int gasket_is_extended_dev_addr_bad( +static bool gasket_is_extended_dev_addr_bad( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); -static int gasket_is_pte_range_free( +static bool gasket_is_pte_range_free( struct gasket_page_table_entry *pte, uint num_entries); static void gasket_page_table_garbage_collect_nolock( struct gasket_page_table *pg_tbl); @@ -558,7 +558,7 @@ fail: } /* See gasket_page_table.h for description. */ -int gasket_page_table_are_addrs_bad( +bool gasket_page_table_are_addrs_bad( struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, ulong bytes) { @@ -567,7 +567,7 @@ int gasket_page_table_are_addrs_bad( pg_tbl, "host mapping address 0x%lx must be page aligned", host_addr); - return 1; + return true; } return gasket_page_table_is_dev_addr_bad(pg_tbl, dev_addr, bytes); @@ -575,7 +575,7 @@ int gasket_page_table_are_addrs_bad( EXPORT_SYMBOL(gasket_page_table_are_addrs_bad); /* See gasket_page_table.h for description. */ -int gasket_page_table_is_dev_addr_bad( +bool gasket_page_table_is_dev_addr_bad( struct gasket_page_table *pg_tbl, ulong dev_addr, ulong bytes) { uint num_pages = bytes / PAGE_SIZE; @@ -584,7 +584,7 @@ int gasket_page_table_is_dev_addr_bad( gasket_pg_tbl_error( pg_tbl, "mapping size 0x%lX must be page aligned", bytes); - return 1; + return true; } if (num_pages == 0) { @@ -592,7 +592,7 @@ int gasket_page_table_is_dev_addr_bad( pg_tbl, "requested mapping is less than one page: %lu / %lu", bytes, PAGE_SIZE); - return 1; + return true; } if (gasket_addr_is_simple(pg_tbl, dev_addr)) @@ -1285,23 +1285,23 @@ static void gasket_free_extended_subtable( /* * Safely return a page to the OS. * @page: The page to return to the OS. - * Returns 1 if the page was released, 0 if it was + * Returns true if the page was released, false if it was * ignored. */ -static int gasket_release_page(struct page *page) +static bool gasket_release_page(struct page *page) { if (!page) - return 0; + return false; if (!PageReserved(page)) SetPageDirty(page); put_page(page); - return 1; + return true; } /* Evaluates to nonzero if the specified virtual address is simple. */ -static inline int gasket_addr_is_simple( +static inline bool gasket_addr_is_simple( struct gasket_page_table *pg_tbl, ulong addr) { return !((addr) & (pg_tbl)->extended_flag); @@ -1317,7 +1317,7 @@ static inline int gasket_addr_is_simple( * address to/from page + offset) and that the requested page range starts and * ends within the set of currently-partitioned simple pages. */ -static int gasket_is_simple_dev_addr_bad( +static bool gasket_is_simple_dev_addr_bad( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) { ulong page_offset = dev_addr & (PAGE_SIZE - 1); @@ -1328,7 +1328,7 @@ static int gasket_is_simple_dev_addr_bad( pg_tbl, 1, page_index, page_offset) != dev_addr) { gasket_pg_tbl_error( pg_tbl, "address is invalid, 0x%lX", dev_addr); - return 1; + return true; } if (page_index >= pg_tbl->num_simple_entries) { @@ -1336,7 +1336,7 @@ static int gasket_is_simple_dev_addr_bad( pg_tbl, "starting slot at %lu is too large, max is < %u", page_index, pg_tbl->num_simple_entries); - return 1; + return true; } if (page_index + num_pages > pg_tbl->num_simple_entries) { @@ -1344,10 +1344,10 @@ static int gasket_is_simple_dev_addr_bad( pg_tbl, "ending slot at %lu is too large, max is <= %u", page_index + num_pages, pg_tbl->num_simple_entries); - return 1; + return true; } - return 0; + return false; } /* @@ -1359,7 +1359,7 @@ static int gasket_is_simple_dev_addr_bad( * @dev_addr: The device address to which the pages will be mapped. * @num_pages: The number of second-level/sub pages in the range to consider. */ -static int gasket_is_extended_dev_addr_bad( +static bool gasket_is_extended_dev_addr_bad( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) { /* Starting byte index of dev_addr into the first mapped page */ @@ -1373,7 +1373,7 @@ static int gasket_is_extended_dev_addr_bad( if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) { gasket_pg_tbl_error(pg_tbl, "device address out of bound, 0x%p", (void *)dev_addr); - return 1; + return true; } /* Find the starting sub-page index in the space of all sub-pages. */ @@ -1391,7 +1391,7 @@ static int gasket_is_extended_dev_addr_bad( pg_tbl, 0, page_global_idx, page_offset) != dev_addr) { gasket_pg_tbl_error( pg_tbl, "address is invalid, 0x%p", (void *)dev_addr); - return 1; + return true; } if (page_lvl0_idx >= pg_tbl->num_extended_entries) { @@ -1399,7 +1399,7 @@ static int gasket_is_extended_dev_addr_bad( pg_tbl, "starting level 0 slot at %lu is too large, max is < " "%u", page_lvl0_idx, pg_tbl->num_extended_entries); - return 1; + return true; } if (page_lvl0_idx + num_lvl0_pages > pg_tbl->num_extended_entries) { @@ -1408,10 +1408,10 @@ static int gasket_is_extended_dev_addr_bad( "ending level 0 slot at %lu is too large, max is <= %u", page_lvl0_idx + num_lvl0_pages, pg_tbl->num_extended_entries); - return 1; + return true; } - return 0; + return false; } /* @@ -1425,17 +1425,17 @@ static int gasket_is_extended_dev_addr_bad( * * The page table mutex must be held before this call. */ -static int gasket_is_pte_range_free( +static bool gasket_is_pte_range_free( struct gasket_page_table_entry *ptes, uint num_entries) { int i; for (i = 0; i < num_entries; i++) { if (ptes[i].status != PTE_FREE) - return 0; + return false; } - return 1; + return true; } /* diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index 720ce2bc2c01..0e8afdb8c113 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h @@ -162,9 +162,9 @@ int gasket_page_table_lookup_page( * specified by both addresses and the size are valid for mapping pages into * device memory. * - * Returns 1 if true - if the mapping is bad, 0 otherwise. + * Returns true if the mapping is bad, false otherwise. */ -int gasket_page_table_are_addrs_bad( +bool gasket_page_table_are_addrs_bad( struct gasket_page_table *page_table, ulong host_addr, ulong dev_addr, ulong bytes); @@ -178,9 +178,9 @@ int gasket_page_table_are_addrs_bad( * specified by the device address and the size is valid for mapping pages into * device memory. * - * Returns 1 if true - if the address is bad, 0 otherwise. + * Returns true if the address is bad, false otherwise. */ -int gasket_page_table_is_dev_addr_bad( +bool gasket_page_table_is_dev_addr_bad( struct gasket_page_table *page_table, ulong dev_addr, ulong bytes); /* From 6d8a1d564bc01b1f3402d229acb98f779440c5e3 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:10 -0700 Subject: [PATCH 438/903] staging: gasket: remove else clause after return in if clause Else after return is unnecessary and may cause static code checkers to complain. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 2a27db658a4e..617d602b8b44 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -598,9 +598,7 @@ bool gasket_page_table_is_dev_addr_bad( if (gasket_addr_is_simple(pg_tbl, dev_addr)) return gasket_is_simple_dev_addr_bad( pg_tbl, dev_addr, num_pages); - else - return gasket_is_extended_dev_addr_bad( - pg_tbl, dev_addr, num_pages); + return gasket_is_extended_dev_addr_bad(pg_tbl, dev_addr, num_pages); } EXPORT_SYMBOL(gasket_page_table_is_dev_addr_bad); From 4e48c29fe086a14c9a15381562d1f79dbbfb10d8 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:11 -0700 Subject: [PATCH 439/903] staging: gasket: fix comment syntax in apex.h Use kernel-style multi-line comment syntax. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h index 4ef264106f50..d89cc2387b7d 100644 --- a/drivers/staging/gasket/apex.h +++ b/drivers/staging/gasket/apex.h @@ -22,9 +22,10 @@ #define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */ -/* Addresses are 2^3=8 bytes each. */ -/* page in second level page table */ -/* holds APEX_PAGE_SIZE/8 addresses */ +/* + * Addresses are 2^3=8 bytes each. Page in second level page table holds + * APEX_PAGE_SIZE/8 addresses. + */ #define APEX_ADDR_SHIFT 3 #define APEX_LEVEL_SHIFT (APEX_PAGE_SHIFT - APEX_ADDR_SHIFT) #define APEX_LEVEL_SIZE BIT(APEX_LEVEL_SHIFT) From 0b184cc86542cf6938e82c61b0951e799ceceb9b Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:12 -0700 Subject: [PATCH 440/903] staging: gasket: remove unnecessary parens in page table code gasket_alloc_coherent_memory() extra parentheses in statement. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 617d602b8b44..9f8116112e0a 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1639,7 +1639,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, dma_addr_t handle; void *mem; int j; - unsigned int num_pages = (size + PAGE_SIZE - 1) / (PAGE_SIZE); + unsigned int num_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE; const struct gasket_driver_desc *driver_desc = gasket_get_driver_desc(gasket_dev); From fd5d76ab69a565ebcab94f11f185ea3dc5588249 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:13 -0700 Subject: [PATCH 441/903] staging: gasket: gasket_mmap use PAGE_MASK gasket_mmap use PAGE_MASK, instead of performing math on PAGE_SIZE, for simplicity and clarity. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 3cf918f9d260..ae5febec8844 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1591,7 +1591,7 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) } driver_desc = gasket_dev->internal_desc->driver_desc; - if (vma->vm_start & (PAGE_SIZE - 1)) { + if (vma->vm_start & ~PAGE_MASK) { gasket_log_error( gasket_dev, "Base address not page-aligned: 0x%p\n", (void *)vma->vm_start); From 40eb35023179e90b123f8c4b0bc5e1a412ff2d21 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:14 -0700 Subject: [PATCH 442/903] staging: gasket: remove extra parens in gasket_write_mappable_regions Remove unneeded parentheses around subexpressions. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index ae5febec8844..ba48a379b0ad 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1889,7 +1889,7 @@ static ssize_t gasket_write_mappable_regions( if (bar_desc.permissions == GASKET_NOMAP) return 0; for (i = 0; - (i < bar_desc.num_mappable_regions) && (total_written < PAGE_SIZE); + i < bar_desc.num_mappable_regions && total_written < PAGE_SIZE; i++) { min_addr = bar_desc.mappable_regions[i].start - driver_desc->legacy_mmap_address_offset; From 563f3bb51f59e288879c099b2e8ee1496b7c3234 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:15 -0700 Subject: [PATCH 443/903] staging: gasket: fix multi-line comment syntax in gasket_core.h Use consistent kernel-style multi-line comment syntax. Reported-by: Guenter Roeck Signed-off-by: Simon Que Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 50ad0c885318..7ea1df123ba5 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -54,7 +54,8 @@ enum gasket_interrupt_type { PLATFORM_WIRE = 2, }; -/* Used to describe a Gasket interrupt. Contains an interrupt index, a register, +/* + * Used to describe a Gasket interrupt. Contains an interrupt index, a register, * and packing data for that interrupt. The register and packing data * fields are relevant only for PCI_MSIX interrupt type and can be * set to 0 for everything else. From ed74277bd80a47ec552ccf3581583421c3a4df5d Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:16 -0700 Subject: [PATCH 444/903] staging: gasket: always allow root open for write Always allow root to open device for writing. Drop special-casing of ioctl permissions for root vs. owner. Convert to bool types as appropriate. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 15 ++++---------- drivers/staging/gasket/gasket_core.c | 8 ++++--- drivers/staging/gasket/gasket_ioctl.c | 30 +++++++++++++-------------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index a01b1f2b827e..4c00f3609f08 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -140,7 +140,7 @@ static int apex_reset(struct gasket_dev *gasket_dev, uint type); static int apex_get_status(struct gasket_dev *gasket_dev); -static uint apex_ioctl_check_permissions(struct file *file, uint cmd); +static bool apex_ioctl_check_permissions(struct file *file, uint cmd); static long apex_ioctl(struct file *file, uint cmd, ulong arg); @@ -625,18 +625,11 @@ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) * @file: File pointer from ioctl. * @cmd: ioctl command. * - * Returns 1 if the current user may execute this ioctl, and 0 otherwise. + * Returns true if the current user may execute this ioctl, and false otherwise. */ -static uint apex_ioctl_check_permissions(struct file *filp, uint cmd) +static bool apex_ioctl_check_permissions(struct file *filp, uint cmd) { - struct gasket_dev *gasket_dev = filp->private_data; - int root = capable(CAP_SYS_ADMIN); - int is_owner = gasket_dev->dev_info.ownership.is_owned && - current->tgid == gasket_dev->dev_info.ownership.owner; - - if (root || is_owner) - return 1; - return 0; + return !!(filp->f_mode & FMODE_WRITE); } /* diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index ba48a379b0ad..254fb392c05c 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1072,6 +1072,7 @@ static int gasket_open(struct inode *inode, struct file *filp) char task_name[TASK_COMM_LEN]; struct gasket_cdev_info *dev_info = container_of(inode->i_cdev, struct gasket_cdev_info, cdev); + int is_root = capable(CAP_SYS_ADMIN); gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; @@ -1085,7 +1086,7 @@ static int gasket_open(struct inode *inode, struct file *filp) "Attempting to open with tgid %u (%s) (f_mode: 0%03o, " "fmode_write: %d is_root: %u)", current->tgid, task_name, filp->f_mode, - (filp->f_mode & FMODE_WRITE), capable(CAP_SYS_ADMIN)); + (filp->f_mode & FMODE_WRITE), is_root); /* Always allow non-writing accesses. */ if (!(filp->f_mode & FMODE_WRITE)) { @@ -1099,8 +1100,9 @@ static int gasket_open(struct inode *inode, struct file *filp) gasket_dev, "Current owner open count (owning tgid %u): %d.", ownership->owner, ownership->write_open_count); - /* Opening a node owned by another TGID is an error (even root.) */ - if (ownership->is_owned && ownership->owner != current->tgid) { + /* Opening a node owned by another TGID is an error (unless root) */ + if (ownership->is_owned && ownership->owner != current->tgid && + !is_root) { gasket_log_error( gasket_dev, "Process %u is opening a node held by %u.", diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index d0142ed048a6..8fd44979fe71 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -22,7 +22,7 @@ #define trace_gasket_ioctl_config_coherent_allocator(x, ...) #endif -static uint gasket_ioctl_check_permissions(struct file *filp, uint cmd); +static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd); static int gasket_set_event_fd(struct gasket_dev *dev, ulong arg); static int gasket_read_page_table_size( struct gasket_dev *gasket_dev, ulong arg); @@ -167,12 +167,13 @@ long gasket_is_supported_ioctl(uint cmd) * @filp: File structure pointer describing this node usage session. * @cmd: ioctl number to handle. * - * Standard permissions checker. + * Check permissions for Gasket ioctls. + * Returns true if the file opener may execute this ioctl, or false otherwise. */ -static uint gasket_ioctl_check_permissions(struct file *filp, uint cmd) +static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd) { - uint alive, root, device_owner; - fmode_t read, write; + bool alive; + bool read, write; struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data; alive = (gasket_dev->status == GASKET_STATUS_ALIVE); @@ -183,36 +184,33 @@ static uint gasket_ioctl_check_permissions(struct file *filp, uint cmd) alive, gasket_dev->status); } - root = capable(CAP_SYS_ADMIN); - read = filp->f_mode & FMODE_READ; - write = filp->f_mode & FMODE_WRITE; - device_owner = (gasket_dev->dev_info.ownership.is_owned && - current->tgid == gasket_dev->dev_info.ownership.owner); + read = !!(filp->f_mode & FMODE_READ); + write = !!(filp->f_mode & FMODE_WRITE); switch (cmd) { case GASKET_IOCTL_RESET: case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: - return root || (write && device_owner); + return write; case GASKET_IOCTL_PAGE_TABLE_SIZE: case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: case GASKET_IOCTL_NUMBER_PAGE_TABLES: - return root || read; + return read; case GASKET_IOCTL_PARTITION_PAGE_TABLE: case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: - return alive && (root || (write && device_owner)); + return alive && write; case GASKET_IOCTL_MAP_BUFFER: case GASKET_IOCTL_UNMAP_BUFFER: - return alive && (root || (write && device_owner)); + return alive && write; case GASKET_IOCTL_CLEAR_EVENTFD: case GASKET_IOCTL_SET_EVENTFD: - return alive && (root || (write && device_owner)); + return alive && write; } - return 0; /* unknown permissions */ + return false; /* unknown permissions */ } /* From 761d8db71436d8c67bcac85aa62860cb5848fecf Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:17 -0700 Subject: [PATCH 445/903] staging: gasket: top ioctl handler add __user annotations Add __user annotation to gasket_core top-level ioctl handling pointer arguments, for sparse checking. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 6 ++++-- drivers/staging/gasket/gasket_core.h | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 254fb392c05c..40e46ca5228c 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -14,6 +14,7 @@ #include "gasket_page_table.h" #include "gasket_sysfs.h" +#include #include #include #include @@ -1781,6 +1782,7 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) { struct gasket_dev *gasket_dev; const struct gasket_driver_desc *driver_desc; + void __user *argp = (void __user *)arg; char path[256]; if (!filp) @@ -1810,14 +1812,14 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) * check_and_invoke_callback. */ if (driver_desc->ioctl_handler_cb) - return driver_desc->ioctl_handler_cb(filp, cmd, arg); + return driver_desc->ioctl_handler_cb(filp, cmd, argp); gasket_log_error( gasket_dev, "Received unknown ioctl 0x%x", cmd); return -EINVAL; } - return gasket_handle_ioctl(filp, cmd, arg); + return gasket_handle_ioctl(filp, cmd, argp); } int gasket_reset(struct gasket_dev *gasket_dev, uint reset_type) diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 7ea1df123ba5..bf4ed3769efb 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -314,9 +314,12 @@ struct gasket_dev { struct hlist_node legacy_hlist_node; }; +/* Type of the ioctl handler callback. */ +typedef long (*gasket_ioctl_handler_cb_t) + (struct file *file, uint cmd, void __user *argp); /* Type of the ioctl permissions check callback. See below. */ typedef int (*gasket_ioctl_permissions_cb_t)( - struct file *filp, uint cmd, ulong arg); + struct file *filp, uint cmd, void __user *argp); /* * Device type descriptor. @@ -550,7 +553,7 @@ struct gasket_driver_desc { * return -EINVAL. Should return an error status (either -EINVAL or * the error result of the ioctl being handled). */ - long (*ioctl_handler_cb)(struct file *filp, uint cmd, ulong arg); + gasket_ioctl_handler_cb_t ioctl_handler_cb; /* * device_status_cb: Callback to determine device health. From c13435deaadca078ce5651c43ed8d7561215b20a Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:18 -0700 Subject: [PATCH 446/903] staging: gasket: apex ioctl add __user annotations Add __user annotation to ioctl pointer argument, for sparse checking. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 4c00f3609f08..3e76c4db5db2 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -5,6 +5,7 @@ * Copyright (C) 2018 Google, Inc. */ +#include #include #include #include @@ -142,9 +143,10 @@ static int apex_get_status(struct gasket_dev *gasket_dev); static bool apex_ioctl_check_permissions(struct file *file, uint cmd); -static long apex_ioctl(struct file *file, uint cmd, ulong arg); +static long apex_ioctl(struct file *file, uint cmd, void __user *argp); -static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg); +static long apex_clock_gating(struct gasket_dev *gasket_dev, + struct apex_gate_clock_ioctl __user *argp); static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type); @@ -635,7 +637,7 @@ static bool apex_ioctl_check_permissions(struct file *filp, uint cmd) /* * Apex-specific ioctl handler. */ -static long apex_ioctl(struct file *filp, uint cmd, ulong arg) +static long apex_ioctl(struct file *filp, uint cmd, void __user *argp) { struct gasket_dev *gasket_dev = filp->private_data; @@ -644,7 +646,7 @@ static long apex_ioctl(struct file *filp, uint cmd, ulong arg) switch (cmd) { case APEX_IOCTL_GATE_CLOCK: - return apex_clock_gating(gasket_dev, arg); + return apex_clock_gating(gasket_dev, argp); default: return -ENOTTY; /* unknown command */ } @@ -653,16 +655,17 @@ static long apex_ioctl(struct file *filp, uint cmd, ulong arg) /* * Gates or un-gates Apex clock. * @gasket_dev: Gasket device pointer. - * @arg: User ioctl arg, in this case to a apex_gate_clock_ioctl struct. + * @argp: User ioctl arg, pointer to a apex_gate_clock_ioctl struct. */ -static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg) +static long apex_clock_gating(struct gasket_dev *gasket_dev, + struct apex_gate_clock_ioctl __user *argp) { struct apex_gate_clock_ioctl ibuf; if (bypass_top_level || !allow_sw_clock_gating) return 0; - if (copy_from_user(&ibuf, (void __user *)arg, sizeof(ibuf))) + if (copy_from_user(&ibuf, argp, sizeof(ibuf))) return -EFAULT; gasket_log_error(gasket_dev, "%s %llu", __func__, ibuf.enable); From de3690d025fced530a587b820f00f67cd964289e Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:19 -0700 Subject: [PATCH 447/903] staging: gasket: common ioctl dispatcher add __user annotations Add __user annotation to gasket core common ioctl pointer arguments for sparse checking. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 8 +++++--- drivers/staging/gasket/gasket_ioctl.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 8fd44979fe71..998d0e215523 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -7,6 +7,7 @@ #include "gasket_interrupt.h" #include "gasket_logging.h" #include "gasket_page_table.h" +#include #include #include @@ -39,13 +40,14 @@ static int gasket_config_coherent_allocator( * standard ioctl dispatch function. * @filp: File structure pointer describing this node usage session. * @cmd: ioctl number to handle. - * @arg: ioctl-specific data pointer. + * @argp: ioctl-specific data pointer. * * Standard ioctl dispatcher; forwards operations to individual handlers. */ -long gasket_handle_ioctl(struct file *filp, uint cmd, ulong arg) +long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) { struct gasket_dev *gasket_dev; + unsigned long arg = (unsigned long)argp; int retval; gasket_dev = (struct gasket_dev *)filp->private_data; @@ -53,7 +55,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, ulong arg) if (gasket_get_ioctl_permissions_cb(gasket_dev)) { retval = gasket_get_ioctl_permissions_cb(gasket_dev)( - filp, cmd, arg); + filp, cmd, argp); if (retval < 0) { trace_gasket_ioctl_exit(-EPERM); return retval; diff --git a/drivers/staging/gasket/gasket_ioctl.h b/drivers/staging/gasket/gasket_ioctl.h index 461fab27a3e5..51f468c77f04 100644 --- a/drivers/staging/gasket/gasket_ioctl.h +++ b/drivers/staging/gasket/gasket_ioctl.h @@ -5,6 +5,8 @@ #include "gasket_core.h" +#include + /* * Handle Gasket common ioctls. * @filp: Pointer to the ioctl's file. @@ -13,7 +15,7 @@ * * Returns 0 on success and nonzero on failure. */ -long gasket_handle_ioctl(struct file *filp, uint cmd, ulong arg); +long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp); /* * Determines if an ioctl is part of the standard Gasket framework. From 56edc4e3f909cf8d37e9aa16ce0b5dbc66734995 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:20 -0700 Subject: [PATCH 448/903] staging: gasket: common ioctls add __user annotations Add __user annotation to gasket common ioctl pointer arguments for sparse checking. Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 102 ++++++++++++++------------ 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 998d0e215523..2e2c9b997093 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -24,17 +24,24 @@ #endif static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd); -static int gasket_set_event_fd(struct gasket_dev *dev, ulong arg); +static int gasket_set_event_fd(struct gasket_dev *dev, + struct gasket_interrupt_eventfd __user *argp); static int gasket_read_page_table_size( - struct gasket_dev *gasket_dev, ulong arg); + struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp); static int gasket_read_simple_page_table_size( - struct gasket_dev *gasket_dev, ulong arg); + struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp); static int gasket_partition_page_table( - struct gasket_dev *gasket_dev, ulong arg); -static int gasket_map_buffers(struct gasket_dev *gasket_dev, ulong arg); -static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, ulong arg); + struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp); +static int gasket_map_buffers(struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp); +static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp); static int gasket_config_coherent_allocator( - struct gasket_dev *gasket_dev, ulong arg); + struct gasket_dev *gasket_dev, + struct gasket_coherent_alloc_config_ioctl __user *argp); /* * standard ioctl dispatch function. @@ -80,7 +87,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) retval = gasket_reset(gasket_dev, arg); break; case GASKET_IOCTL_SET_EVENTFD: - retval = gasket_set_event_fd(gasket_dev, arg); + retval = gasket_set_event_fd(gasket_dev, argp); break; case GASKET_IOCTL_CLEAR_EVENTFD: trace_gasket_ioctl_integer_data(arg); @@ -89,31 +96,30 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) break; case GASKET_IOCTL_PARTITION_PAGE_TABLE: trace_gasket_ioctl_integer_data(arg); - retval = gasket_partition_page_table(gasket_dev, arg); + retval = gasket_partition_page_table(gasket_dev, argp); break; case GASKET_IOCTL_NUMBER_PAGE_TABLES: trace_gasket_ioctl_integer_data(gasket_dev->num_page_tables); - if (copy_to_user((void __user *)arg, - &gasket_dev->num_page_tables, + if (copy_to_user(argp, &gasket_dev->num_page_tables, sizeof(uint64_t))) retval = -EFAULT; else retval = 0; break; case GASKET_IOCTL_PAGE_TABLE_SIZE: - retval = gasket_read_page_table_size(gasket_dev, arg); + retval = gasket_read_page_table_size(gasket_dev, argp); break; case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: - retval = gasket_read_simple_page_table_size(gasket_dev, arg); + retval = gasket_read_simple_page_table_size(gasket_dev, argp); break; case GASKET_IOCTL_MAP_BUFFER: - retval = gasket_map_buffers(gasket_dev, arg); + retval = gasket_map_buffers(gasket_dev, argp); break; case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: - retval = gasket_config_coherent_allocator(gasket_dev, arg); + retval = gasket_config_coherent_allocator(gasket_dev, argp); break; case GASKET_IOCTL_UNMAP_BUFFER: - retval = gasket_unmap_buffers(gasket_dev, arg); + retval = gasket_unmap_buffers(gasket_dev, argp); break; case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: /* Clear interrupt counts doesn't take an arg, so use 0. */ @@ -218,16 +224,15 @@ static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd) /* * Associate an eventfd with an interrupt. * @gasket_dev: Pointer to the current gasket_dev we're using. - * @arg: Pointer to gasket_interrupt_eventfd struct in userspace. + * @argp: Pointer to gasket_interrupt_eventfd struct in userspace. */ -static int gasket_set_event_fd(struct gasket_dev *gasket_dev, ulong arg) +static int gasket_set_event_fd(struct gasket_dev *gasket_dev, + struct gasket_interrupt_eventfd __user *argp) { struct gasket_interrupt_eventfd die; - if (copy_from_user(&die, (void __user *)arg, - sizeof(struct gasket_interrupt_eventfd))) { + if (copy_from_user(&die, argp, sizeof(struct gasket_interrupt_eventfd))) return -EFAULT; - } trace_gasket_ioctl_eventfd_data(die.interrupt, die.event_fd); @@ -238,15 +243,16 @@ static int gasket_set_event_fd(struct gasket_dev *gasket_dev, ulong arg) /* * Reads the size of the page table. * @gasket_dev: Pointer to the current gasket_dev we're using. - * @arg: Pointer to gasket_page_table_ioctl struct in userspace. + * @argp: Pointer to gasket_page_table_ioctl struct in userspace. */ -static int gasket_read_page_table_size(struct gasket_dev *gasket_dev, ulong arg) +static int gasket_read_page_table_size( + struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp) { int ret = 0; struct gasket_page_table_ioctl ibuf; - if (copy_from_user(&ibuf, (void __user *)arg, - sizeof(struct gasket_page_table_ioctl))) + if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; if (ibuf.page_table_index >= gasket_dev->num_page_tables) @@ -259,7 +265,7 @@ static int gasket_read_page_table_size(struct gasket_dev *gasket_dev, ulong arg) ibuf.page_table_index, ibuf.size, ibuf.host_address, ibuf.device_address); - if (copy_to_user((void __user *)arg, &ibuf, sizeof(ibuf))) + if (copy_to_user(argp, &ibuf, sizeof(ibuf))) return -EFAULT; return ret; @@ -268,16 +274,16 @@ static int gasket_read_page_table_size(struct gasket_dev *gasket_dev, ulong arg) /* * Reads the size of the simple page table. * @gasket_dev: Pointer to the current gasket_dev we're using. - * @arg: Pointer to gasket_page_table_ioctl struct in userspace. + * @argp: Pointer to gasket_page_table_ioctl struct in userspace. */ static int gasket_read_simple_page_table_size( - struct gasket_dev *gasket_dev, ulong arg) + struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp) { int ret = 0; struct gasket_page_table_ioctl ibuf; - if (copy_from_user(&ibuf, (void __user *)arg, - sizeof(struct gasket_page_table_ioctl))) + if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; if (ibuf.page_table_index >= gasket_dev->num_page_tables) @@ -290,7 +296,7 @@ static int gasket_read_simple_page_table_size( ibuf.page_table_index, ibuf.size, ibuf.host_address, ibuf.device_address); - if (copy_to_user((void __user *)arg, &ibuf, sizeof(ibuf))) + if (copy_to_user(argp, &ibuf, sizeof(ibuf))) return -EFAULT; return ret; @@ -299,16 +305,17 @@ static int gasket_read_simple_page_table_size( /* * Sets the boundary between the simple and extended page tables. * @gasket_dev: Pointer to the current gasket_dev we're using. - * @arg: Pointer to gasket_page_table_ioctl struct in userspace. + * @argp: Pointer to gasket_page_table_ioctl struct in userspace. */ -static int gasket_partition_page_table(struct gasket_dev *gasket_dev, ulong arg) +static int gasket_partition_page_table( + struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp) { int ret; struct gasket_page_table_ioctl ibuf; uint max_page_table_size; - if (copy_from_user(&ibuf, (void __user *)arg, - sizeof(struct gasket_page_table_ioctl))) + if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; trace_gasket_ioctl_page_table_data( @@ -340,14 +347,14 @@ static int gasket_partition_page_table(struct gasket_dev *gasket_dev, ulong arg) /* * Maps a userspace buffer to a device virtual address. * @gasket_dev: Pointer to the current gasket_dev we're using. - * @arg: Pointer to a gasket_page_table_ioctl struct in userspace. + * @argp: Pointer to a gasket_page_table_ioctl struct in userspace. */ -static int gasket_map_buffers(struct gasket_dev *gasket_dev, ulong arg) +static int gasket_map_buffers(struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp) { struct gasket_page_table_ioctl ibuf; - if (copy_from_user(&ibuf, (void __user *)arg, - sizeof(struct gasket_page_table_ioctl))) + if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; trace_gasket_ioctl_page_table_data( @@ -370,14 +377,14 @@ static int gasket_map_buffers(struct gasket_dev *gasket_dev, ulong arg) /* * Unmaps a userspace buffer from a device virtual address. * @gasket_dev: Pointer to the current gasket_dev we're using. - * @arg: Pointer to a gasket_page_table_ioctl struct in userspace. + * @argp: Pointer to a gasket_page_table_ioctl struct in userspace. */ -static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, ulong arg) +static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, + struct gasket_page_table_ioctl __user *argp) { struct gasket_page_table_ioctl ibuf; - if (copy_from_user(&ibuf, (void __user *)arg, - sizeof(struct gasket_page_table_ioctl))) + if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; trace_gasket_ioctl_page_table_data( @@ -402,15 +409,16 @@ static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, ulong arg) * Tell the driver to reserve structures for coherent allocation, and allocate * or free the corresponding memory. * @dev: Pointer to the current gasket_dev we're using. - * @arg: Pointer to a gasket_coherent_alloc_config_ioctl struct in userspace. + * @argp: Pointer to a gasket_coherent_alloc_config_ioctl struct in userspace. */ static int gasket_config_coherent_allocator( - struct gasket_dev *gasket_dev, ulong arg) + struct gasket_dev *gasket_dev, + struct gasket_coherent_alloc_config_ioctl __user *argp) { int ret; struct gasket_coherent_alloc_config_ioctl ibuf; - if (copy_from_user(&ibuf, (void __user *)arg, + if (copy_from_user(&ibuf, argp, sizeof(struct gasket_coherent_alloc_config_ioctl))) return -EFAULT; @@ -432,7 +440,7 @@ static int gasket_config_coherent_allocator( gasket_dev, ibuf.size, &ibuf.dma_address, ibuf.page_table_index); } - if (copy_to_user((void __user *)arg, &ibuf, sizeof(ibuf))) + if (copy_to_user(argp, &ibuf, sizeof(ibuf))) return -EFAULT; return ret; From cfd645643496d4b66cde42070e7f879d2a738ebc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Jul 2018 16:23:02 +0200 Subject: [PATCH 449/903] staging: rtl8188eu: remove MacAddr_isBcst macro Use is_broadcast_ether_addr instead of the MacAddr_isBcst macro. The macro is not used anywhere else, so remove it. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 +- drivers/staging/rtl8188eu/include/wifi.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 53c65d5463c0..2edc3a8242b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -549,7 +549,7 @@ static void count_rx_stats(struct adapter *padapter, padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; - if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst))) + if (!is_broadcast_ether_addr(pattrib->dst) && !IS_MCAST(pattrib->dst)) padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; if (sta) diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index a41e8eda02fb..4a56e54e38f6 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -257,13 +257,6 @@ enum WIFI_REG_DOMAIN { #define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24)) -#define MacAddr_isBcst(addr) \ - ( \ - ((addr[0] == 0xff) && (addr[1] == 0xff) && \ - (addr[2] == 0xff) && (addr[3] == 0xff) && \ - (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ -) - static inline int IS_MCAST(unsigned char *da) { if ((*da) & 0x01) From 11790bbdf359f633cb48ba8c77f696c03505c3c7 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Jul 2018 16:23:03 +0200 Subject: [PATCH 450/903] staging: rtl8188eu: use is_multicast_ether_addr Use is_multicast_ether_addr instead of IS_MCAST. By definition the broadcast address is also a multicast address, so checking for !multicast in the conditional is sufficient. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 2edc3a8242b1..48e12b5439eb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -549,7 +549,7 @@ static void count_rx_stats(struct adapter *padapter, padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; - if (!is_broadcast_ether_addr(pattrib->dst) && !IS_MCAST(pattrib->dst)) + if (!is_multicast_ether_addr(pattrib->dst)) padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; if (sta) From 0a31edbbf886752544e3a9800c7c37e26d27022c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Jul 2018 17:04:49 +0200 Subject: [PATCH 451/903] staging: rtl8188eu: remove blank lines Remove unrequired blank lines as reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_ieee80211.c | 8 ---- .../staging/rtl8188eu/core/rtw_ioctl_set.c | 18 -------- drivers/staging/rtl8188eu/core/rtw_led.c | 1 - drivers/staging/rtl8188eu/core/rtw_mlme.c | 5 --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 45 ------------------- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 6 --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 27 ----------- 7 files changed, 110 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index fed33d9acf60..b7188fa5364a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -57,7 +57,6 @@ static u8 WIFI_OFDMRATES[] = { IEEE80211_OFDM_RATE_54MB }; - int rtw_get_bit_value_from_ieee_value(u8 val) { unsigned char dot11_rate_table[] = { @@ -218,7 +217,6 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *ie = pdev_network->ies; - /* timestamp will be inserted by hardware */ sz += 8; ie += sz; @@ -356,7 +354,6 @@ int rtw_get_wpa2_cipher_suite(u8 *s) return 0; } - int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) { int i, ret = _SUCCESS; @@ -369,7 +366,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis return _FAIL; } - if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || (memcmp(wpa_ie + 2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) return _FAIL; @@ -379,7 +375,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis pos += 8; left = wpa_ie_len - 8; - /* group_cipher */ if (left >= WPA_SELECTOR_LEN) { *group_cipher = rtw_get_wpa_cipher_suite(pos); @@ -438,7 +433,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi return _FAIL; } - if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2))) return _FAIL; @@ -501,7 +495,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, 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_; @@ -554,7 +547,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, } } - return *rsn_len + *wpa_len; } diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 733fefec134d..c040f185074b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -21,7 +21,6 @@ u8 rtw_do_join(struct adapter *padapter) struct __queue *queue = &(pmlmepriv->scanned_queue); u8 ret = _SUCCESS; - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); plist = phead->next; @@ -115,8 +114,6 @@ u8 rtw_do_join(struct adapter *padapter) } exit: - - return ret; } @@ -126,7 +123,6 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - DBG_88E_LEVEL(_drv_info_, "set bssid:%pM\n", bssid); if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && @@ -139,7 +135,6 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) spin_lock_bh(&pmlmepriv->lock); - DBG_88E("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) goto handle_tkip_countermeasure; @@ -201,7 +196,6 @@ exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("%s: status=%d\n", __func__, status)); - return status; } @@ -213,7 +207,6 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork = &pmlmepriv->cur_network; - DBG_88E_LEVEL(_drv_info_, "set ssid [%s] fw_state=0x%08x\n", ssid->Ssid, get_fwstate(pmlmepriv)); @@ -319,7 +312,6 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, struct wlan_network *cur_network = &pmlmepriv->cur_network; enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", *pold_state, networktype, get_fwstate(pmlmepriv))); @@ -376,16 +368,13 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, spin_unlock_bh(&pmlmepriv->lock); } - return true; } - u8 rtw_set_802_11_disassociate(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, _FW_LINKED)) { @@ -400,7 +389,6 @@ u8 rtw_set_802_11_disassociate(struct adapter *padapter) spin_unlock_bh(&pmlmepriv->lock); - return true; } @@ -409,7 +397,6 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 res = true; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+%s(), fw_state =%x\n", __func__, get_fwstate(pmlmepriv))); if (!padapter) { @@ -448,8 +435,6 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s spin_unlock_bh(&pmlmepriv->lock); } exit: - - return res; } @@ -459,7 +444,6 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11 int res; u8 ret; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); psecuritypriv->ndisauthtype = authmode; @@ -478,7 +462,6 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11 else ret = false; - return ret; } @@ -488,7 +471,6 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) struct security_priv *psecuritypriv = &(padapter->securitypriv); u8 ret = _SUCCESS; - keyid = wep->KeyIndex & 0x3fffffff; if (keyid >= 4) { diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 3e3038bc628e..cbef871a7679 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -69,7 +69,6 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed) INIT_WORK(&pLed->BlinkWorkItem, BlinkWorkItemCallback); } - /* */ /* Description: */ /* DeInitialize an LED_871x object. */ diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 5929edcc07aa..80f55937e3be 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -201,7 +201,6 @@ exit: return pnetwork; } - void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) { struct list_head *phead, *plist; @@ -257,7 +256,6 @@ u8 *rtw_get_capability_from_ie(u8 *ie) return ie + 8 + 2; } - u16 rtw_get_capability(struct wlan_bssid_ex *bss) { __le16 val; @@ -526,7 +524,6 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * bselected = false; } - if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) { DBG_88E("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy); bselected = false; @@ -762,7 +759,6 @@ void rtw_free_assoc_resources_locked(struct adapter *adapter) rtw_init_bcmc_stainfo(adapter); } - pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) pwlan->fixed = false; @@ -936,7 +932,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net ("\nfw_state:%x, BSSID:%pM\n", get_fwstate(pmlmepriv), pnetwork->network.MacAddress)); - /* why not use ptarget_wlan?? */ memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); /* some ies in pnetwork is wrong, so we should use ptarget_wlan ies */ diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index f05658c9239e..1115050077e4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -342,7 +342,6 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; *(fctrl) = 0; @@ -585,7 +584,6 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); } - /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); @@ -625,7 +623,6 @@ static int issue_probereq(struct adapter *padapter, pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; @@ -777,7 +774,6 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - if (psta) {/* for AP mode */ #ifdef CONFIG_88EU_AP_MODE @@ -787,7 +783,6 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, ether_addr_copy(pwlanhdr->addr3, myid(&(padapter->eeprompriv))); - /* setting auth algo number */ val16 = (u16)psta->authalg; @@ -853,7 +848,6 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, &le_tmp16, &pattrib->pktlen); - /* setting status code... */ le_tmp16 = cpu_to_le16(status); pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, &le_tmp16, @@ -882,7 +876,6 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, dump_mgntframe(padapter, pmgntframe); } - #ifdef CONFIG_88EU_AP_MODE static void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) @@ -911,7 +904,6 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; @@ -925,7 +917,6 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, myid(&(padapter->eeprompriv))); ether_addr_copy((void *)GetAddr3Ptr(pwlanhdr), pnetwork->MacAddress); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; if ((pkt_type == WIFI_ASSOCRSP) || (pkt_type == WIFI_REASSOCRSP)) @@ -1115,7 +1106,6 @@ static void issue_assocreq(struct adapter *padapter) goto exit; /* don't connect to AP if no joint supported rate */ } - if (bssrate_len > 8) { pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); @@ -1261,7 +1251,6 @@ exit: return ret; } - /* when wait_ms > 0 , this function should be called at process context */ /* da == NULL for station mode */ int issue_nulldata(struct adapter *padapter, unsigned char *da, @@ -1489,7 +1478,6 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, pattrib->last_txcmdsz = pattrib->pktlen; - if (wait_ack) { ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); } else { @@ -1727,10 +1715,8 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) if (pmlmeinfo->bwmode_updated) return; - DBG_88E("%s\n", __func__); - category = RTW_WLAN_CATEGORY_PUBLIC; action = ACT_PUBLIC_BSSCOEXIST; @@ -1764,7 +1750,6 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - /* */ if (pmlmepriv->num_FortyMHzIntolerant > 0) { u8 iedata = 0; @@ -1774,7 +1759,6 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &(pattrib->pktlen)); } - /* */ memset(ICS, 0, sizeof(ICS)); if (pmlmepriv->num_sta_no_ht > 0) { @@ -1832,7 +1816,6 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) } } - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); @@ -1935,7 +1918,6 @@ static void site_survey(struct adapter *padapter) ScanType = (ch->flags & RTW_IEEE80211_CHAN_PASSIVE_SCAN) ? SCAN_PASSIVE : SCAN_ACTIVE; } - if (survey_channel != 0) { /* PAUSE 4-AC Queue when site_survey */ /* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ @@ -1979,7 +1961,6 @@ static void site_survey(struct adapter *padapter) set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); } else { - /* 20100721:Interrupt scan operation here. */ /* For SW antenna diversity before link, it needs to switch to another antenna and scan again. */ /* It compares the scan result and select better one to do connection. */ @@ -2321,7 +2302,6 @@ static void start_clnt_auth(struct adapter *padapter) pmlmeinfo->link_count = 0; pmlmeext->retry = 0; - /* Because of AP's not receiving deauth before */ /* AP may: 1)not response auth or 2)deauth us after link is complete */ /* issue deauth before issuing auth to deal with the situation */ @@ -2335,7 +2315,6 @@ static void start_clnt_auth(struct adapter *padapter) set_link_timer(pmlmeext, REAUTH_TO); } - static void start_clnt_assoc(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -2957,7 +2936,6 @@ static unsigned int OnAssocReq(struct adapter *padapter, ie_offset = _REASOCREQ_IE_OFFSET_; } - if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset) { DBG_88E("handle_assoc(reassoc=%d) - too short payload (len=%lu)" "\n", reassoc, (unsigned long)pkt_len); @@ -2975,7 +2953,6 @@ static unsigned int OnAssocReq(struct adapter *padapter, left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset); pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset); - DBG_88E("%s\n", __func__); /* check if this stat has been successfully authenticated/assocated */ @@ -3001,7 +2978,6 @@ static unsigned int OnAssocReq(struct adapter *padapter, goto OnAssocReqFail; } - /* now we should check all the fields... */ /* checking SSID */ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, @@ -3130,7 +3106,6 @@ static unsigned int OnAssocReq(struct adapter *padapter, pstat->flags |= WLAN_STA_MAYBE_WPS; } - /* 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))) { @@ -3270,8 +3245,6 @@ static unsigned int OnAssocReq(struct adapter *padapter, else pstat->flags &= ~WLAN_STA_SHORT_PREAMBLE; - - if (status != _STATS_SUCCESSFUL_) goto OnAssocReqFail; @@ -3493,7 +3466,6 @@ static unsigned int OnDeAuth(struct adapter *padapter, associated_clients_update(padapter, updated); } - return _SUCCESS; } else #endif @@ -4089,7 +4061,6 @@ int init_mlme_ext_priv(struct adapter *padapter) pmlmeext->chan_scan_time = SURVEY_TO; pmlmeext->mlmeext_init = true; - pmlmeext->active_keep_alive_check = true; return _SUCCESS; @@ -4222,7 +4193,6 @@ void report_survey_event(struct adapter *padapter, pmlmeext = &padapter->mlmeextpriv; pcmdpriv = &padapter->cmdpriv; - pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!pcmd_obj) return; @@ -4349,10 +4319,8 @@ void report_join_res(struct adapter *padapter, int res) DBG_88E("%s(%d)\n", __func__, res); - rtw_joinbss_event_prehandle(padapter, (u8 *)&pjoinbss_evt->network); - rtw_enqueue_cmd(pcmdpriv, pcmd_obj); } @@ -4398,7 +4366,6 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, ether_addr_copy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr); memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); - psta = rtw_get_stainfo(&padapter->stapriv, MacAddr); if (psta) mac_id = (int)psta->mac_id; @@ -4457,7 +4424,6 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, rtw_enqueue_cmd(pcmdpriv, pcmd_obj); } - /**************************************************************************** Following are the event callback functions @@ -4502,7 +4468,6 @@ void update_sta_info(struct adapter *padapter, struct sta_info *psta) if (pmlmepriv->qospriv.qos_option) psta->qos_option = true; - psta->state = _FW_LINKED; } @@ -4537,7 +4502,6 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) } } - /* turn on dynamic functions */ Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); @@ -4643,7 +4607,6 @@ void mlmeext_sta_del_event_callback(struct adapter *padapter) /* SelectChannel(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset); */ set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - flush_all_cam_entry(padapter); pmlmeinfo->state = WIFI_FW_NULL_STATE; @@ -4831,7 +4794,6 @@ void survey_timer_hdl(struct timer_list *t) rtw_enqueue_cmd(pcmdpriv, ph2c); } - exit_survey_timer_hdl: return; } @@ -4923,7 +4885,6 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; /* u32 initialgain; */ - if (pparm->InfrastructureMode == Ndis802_11APMode) { #ifdef CONFIG_88EU_AP_MODE @@ -5002,7 +4963,6 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) /* set MSR to nolink -> infra. mode */ Set_MSR(padapter, _HW_STATE_STATION_); - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); } @@ -5113,7 +5073,6 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); } - /* set MSR to no link state -> infra. mode */ Set_MSR(padapter, _HW_STATE_STATION_); @@ -5386,7 +5345,6 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) u8 res = _SUCCESS; int len_diff = 0; - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { res = _FAIL; @@ -5410,10 +5368,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) res = rtw_enqueue_cmd(pcmdpriv, ph2c); - exit: - - return res; } diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 213a10c8576a..5ab6fc22a156 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -17,7 +17,6 @@ static int rtw_hw_suspend(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct net_device *pnetdev = padapter->pnetdev; - if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", @@ -79,7 +78,6 @@ static int rtw_hw_resume(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct net_device *pnetdev = padapter->pnetdev; - /* system resume */ DBG_88E("==> %s\n", __func__); mutex_lock(&pwrpriv->mutex_lock); @@ -107,7 +105,6 @@ static int rtw_hw_resume(struct adapter *padapter) mutex_unlock(&pwrpriv->mutex_lock); - return 0; error_exit: DBG_88E("%s, Open net dev failed\n", __func__); @@ -162,7 +159,6 @@ int ips_leave(struct adapter *padapter) int result = _SUCCESS; int keyid; - mutex_lock(&pwrpriv->mutex_lock); if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { @@ -342,7 +338,6 @@ static u8 PS_RDY_CHECK(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - curr_time = jiffies; delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp; @@ -412,7 +407,6 @@ s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) u8 bAwake = false; s32 err = 0; - start_time = jiffies; while (1) { rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index d16a7fa32a25..89843201a338 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -44,7 +44,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ spin_lock_init(&pxmitpriv->lock); @@ -200,8 +199,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) rtw_hal_init_xmit_priv(padapter); exit: - - return res; } @@ -585,8 +582,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p update_attrib_phy_info(pattrib, psta); exit: - - return res; } @@ -608,7 +603,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr else stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ @@ -705,7 +699,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr } } - return _SUCCESS; } @@ -713,7 +706,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi { struct pkt_attrib *pattrib = &pxmitframe->attrib; - if (pattrib->bswenc) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### %s\n", __func__)); switch (pattrib->encrypt) { @@ -734,7 +726,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); } - return _SUCCESS; } @@ -754,7 +745,6 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr int bmcst = IS_MCAST(pattrib->ra); - if (pattrib->psta) { psta = pattrib->psta; } else { @@ -1075,8 +1065,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct pattrib->vcs_mode = NONE_VCS; exit: - - return res; } @@ -1092,7 +1080,6 @@ s32 rtw_put_snap(u8 *data, u16 h_proto) struct ieee80211_snap_hdr *snap; u8 *oui; - snap = (struct ieee80211_snap_hdr *)data; snap->dsap = 0xaa; snap->ssap = 0xaa; @@ -1109,7 +1096,6 @@ s32 rtw_put_snap(u8 *data, u16 h_proto) *(__be16 *)(data + SNAP_SIZE) = htons(h_proto); - return SNAP_SIZE + sizeof(u16); } @@ -1120,7 +1106,6 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; - switch (pxmitpriv->vcs_setting) { case DISABLE_VCS: pxmitpriv->vcs = NONE_VCS; @@ -1196,7 +1181,6 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) unsigned long irql; struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; - if (!pxmitbuf) return _FAIL; @@ -1209,7 +1193,6 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) spin_unlock_irqrestore(&pfree_queue->lock, irql); - return _SUCCESS; } @@ -1264,7 +1247,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); } - return _SUCCESS; } @@ -1333,7 +1315,6 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram struct adapter *padapter = pxmitpriv->adapter; struct sk_buff *pndis_pkt = NULL; - if (!pxmitframe) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== %s:pxmitframe == NULL!!!!!!!!!!\n", __func__)); goto exit; @@ -1359,8 +1340,6 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram rtw_os_pkt_complete(padapter, pndis_pkt); exit: - - return _SUCCESS; } @@ -1369,7 +1348,6 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram struct list_head *plist, *phead; struct xmit_frame *pxmitframe; - spin_lock_bh(&pframequeue->lock); phead = get_list_head(pframequeue); @@ -1428,7 +1406,6 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi struct registry_priv *pregpriv = &padapter->registrypriv; int i, inx[4]; - inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; if (pregpriv->wifi_spec == 1) { @@ -1502,7 +1479,6 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * break; } - return ptxservq; } @@ -1520,7 +1496,6 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; int res = _SUCCESS; - if (pattrib->psta) psta = pattrib->psta; else @@ -1542,8 +1517,6 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) ptxservq->qcnt++; phwxmits[ac_index].accnt++; exit: - - return res; } From 67e6ee898e4bde9be275ed02399eac1fafe686f9 Mon Sep 17 00:00:00 2001 From: Ali Aminian Date: Fri, 20 Jul 2018 08:32:04 +0430 Subject: [PATCH 452/903] staging: rts5208: xd.c fixed a brace coding style issue Fixing a coding style issue Signed-off-by: Ali Aminian Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/xd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index 667dfe1d76bc..261d868a3072 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -787,9 +787,8 @@ static int reset_xd(struct rtsx_chip *chip) } dev_dbg(rtsx_dev(chip), "CIS block: 0x%x\n", xd_card->cis_block); - if (xd_card->cis_block == 0xFFFF) { + if (xd_card->cis_block == 0xFFFF) return STATUS_FAIL; - } chip->capacity[chip->card2lun[XD_CARD]] = xd_card->capacity; From 336b25773c4efe83dbbde2453cad6c76ba35a551 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:45 +0100 Subject: [PATCH 453/903] staging:rtl8192u: remove typedef of enumeration TR_SELECT - Style To clear a checkpatch issue removed the typedef of the enumeration TR_SELECT this should not impact runtime code as it's only a coding style change. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 3b7968681f77..e65c9967b627 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -2391,7 +2391,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb); void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending); void TsInitDelBA(struct ieee80211_device *ieee, - PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); + PTS_COMMON_INFO pTsCommonInfo, enum tr_select TxRxSelect); void BaSetupTimeOut(struct timer_list *t); void TxBaInactTimeout(struct timer_list *t); void RxBaInactTimeout(struct timer_list *t); @@ -2402,7 +2402,7 @@ bool GetTs( PTS_COMMON_INFO *ppTS, u8 *Addr, u8 TID, - TR_SELECT TxRxSelect, //Rx:1, Tx:0 + enum tr_select TxRxSelect, //Rx:1, Tx:0 bool bAddNewTs ); void TSInitialize(struct ieee80211_device *ieee); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 2dc4d0e93948..04779da803e4 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -174,7 +174,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P *function: construct DELBA frame * input: u8* dst //DELBA frame's destination * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA - * TR_SELECT TxRxSelect //TX RX direction + * enum tr_select TxRxSelect //TX RX direction * u16 ReasonCode //status code. * output: none * return: sk_buff* skb //return constructed skb to xmit @@ -183,7 +183,7 @@ static struct sk_buff *ieee80211_DELBA( struct ieee80211_device *ieee, u8 *dst, PBA_RECORD pBA, - TR_SELECT TxRxSelect, + enum tr_select TxRxSelect, u16 ReasonCode ) { @@ -290,14 +290,14 @@ static void ieee80211_send_ADDBARsp(struct ieee80211_device *ieee, u8 *dst, *function: send ADDBARSP frame out * input: u8* dst //DELBA frame's destination * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA - * TR_SELECT TxRxSelect //TX or RX + * enum tr_select TxRxSelect //TX or RX * u16 ReasonCode //DEL ReasonCode * output: none * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does ********************************************************************************************************************/ static void ieee80211_send_DELBA(struct ieee80211_device *ieee, u8 *dst, - PBA_RECORD pBA, TR_SELECT TxRxSelect, + PBA_RECORD pBA, enum tr_select TxRxSelect, u16 ReasonCode) { struct sk_buff *skb; @@ -638,7 +638,7 @@ TsInitAddBA( } void -TsInitDelBA(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect) +TsInitDelBA(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, enum tr_select TxRxSelect) { if (TxRxSelect == TX_DIR) { PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 3a0ff08c687a..c6a5ac1e647c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -10,10 +10,10 @@ #define TCLAS_NUM 4 /* This define the Tx/Rx directions */ -typedef enum _TR_SELECT { +enum tr_select { TX_DIR = 0, RX_DIR = 1, -} TR_SELECT, *PTR_SELECT; +}; typedef struct _TS_COMMON_INFO { struct list_head List; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index e60a26250682..d6ba9201028f 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -204,7 +204,7 @@ static void AdmitTS(struct ieee80211_device *ieee, static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8 *Addr, u8 TID, - TR_SELECT TxRxSelect) + enum tr_select TxRxSelect) { //DIRECTION_VALUE dir; u8 dir; @@ -291,7 +291,7 @@ bool GetTs( PTS_COMMON_INFO *ppTS, u8 *Addr, u8 TID, - TR_SELECT TxRxSelect, //Rx:1, Tx:0 + enum tr_select TxRxSelect, //Rx:1, Tx:0 bool bAddNewTs ) { @@ -408,7 +408,7 @@ bool GetTs( } static void RemoveTsEntry(struct ieee80211_device *ieee, PTS_COMMON_INFO pTs, - TR_SELECT TxRxSelect) + enum tr_select TxRxSelect) { //u32 flags = 0; unsigned long flags = 0; From 6ae62698ee42ac1a368d33b0d95d38335c0d0e2f Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:46 +0100 Subject: [PATCH 454/903] staging:rtl8192u: remove typedef of struct TS_COMMON_INFO - Style To clear a checkpatch issue removed the typedef of the structure TS_COMMON_INFO. This change removes the previous declaration, which defined two types, both TS_COMMON_INFO and a pointer type PTS_COMMON_INFO: typedef struct _TS_COMMON_INFO { ... } TS_COMMON_INFO, *PTS_COMMON_INFO; The pointer type has been completely removed from the code, as: "(so-called Hungarian notation) is brain damaged" according to the coding standard. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211.h | 4 ++-- .../staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- .../staging/rtl8192u/ieee80211/ieee80211_tx.c | 4 ++-- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 10 ++++---- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 8 +++---- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 24 +++++++++---------- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index e65c9967b627..bb4bb68bb3dd 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -2391,7 +2391,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb); void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending); void TsInitDelBA(struct ieee80211_device *ieee, - PTS_COMMON_INFO pTsCommonInfo, enum tr_select TxRxSelect); + struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect); void BaSetupTimeOut(struct timer_list *t); void TxBaInactTimeout(struct timer_list *t); void RxBaInactTimeout(struct timer_list *t); @@ -2399,7 +2399,7 @@ void ResetBaEntry(PBA_RECORD pBA); //function in TS.c bool GetTs( struct ieee80211_device *ieee, - PTS_COMMON_INFO *ppTS, + struct ts_common_info **ppTS, u8 *Addr, u8 TID, enum tr_select TxRxSelect, //Rx:1, Tx:0 diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 172165f4461a..a84de8c52a2b 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -1021,7 +1021,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__func__, tid); if(GetTs( ieee, - (PTS_COMMON_INFO *) &pRxTS, + (struct ts_common_info **) &pRxTS, hdr->addr2, Frame_QoSTID((u8 *)(skb->data)), RX_DIR, @@ -1266,7 +1266,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, { TID = Frame_QoSTID(skb->data); SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee,(PTS_COMMON_INFO *) &pTS,hdr->addr2,TID,RX_DIR,true); + GetTs(ieee,(struct ts_common_info **) &pTS,hdr->addr2,TID,RX_DIR,true); if (TID !=0 && TID !=3) { ieee->bis_any_nonbepkts = true; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 9a1a84548bc6..010b53b45825 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -330,7 +330,7 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, } if(pHTInfo->bCurrentAMPDUEnable) { - if (!GetTs(ieee, (PTS_COMMON_INFO *)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)) + if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)) { printk("===>can't get TS\n"); return; @@ -585,7 +585,7 @@ static void ieee80211_query_seqnum(struct ieee80211_device *ieee, if (IsQoSDataFrame(skb->data)) //we deal qos data only { PTX_TS_RECORD pTS = NULL; - if (!GetTs(ieee, (PTS_COMMON_INFO *)(&pTS), dst, skb->priority, TX_DIR, true)) + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, skb->priority, TX_DIR, true)) { return; } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 04779da803e4..950f827a1740 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -360,7 +360,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) // If there is no matched TS, reject the ADDBA request. if (!GetTs( ieee, - (PTS_COMMON_INFO *)(&pTS), + (struct ts_common_info **)(&pTS), dst, (u8)(pBaParamSet->field.TID), RX_DIR, @@ -459,7 +459,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) // if (!GetTs( ieee, - (PTS_COMMON_INFO *)(&pTS), + (struct ts_common_info **)(&pTS), dst, (u8)(pBaParamSet->field.TID), TX_DIR, @@ -570,7 +570,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) if (!GetTs( ieee, - (PTS_COMMON_INFO *)&pRxTs, + (struct ts_common_info **)&pRxTs, dst, (u8)pDelBaParamSet->field.TID, RX_DIR, @@ -585,7 +585,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) if (!GetTs( ieee, - (PTS_COMMON_INFO *)&pTxTs, + (struct ts_common_info **)&pTxTs, dst, (u8)pDelBaParamSet->field.TID, TX_DIR, @@ -638,7 +638,7 @@ TsInitAddBA( } void -TsInitDelBA(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, enum tr_select TxRxSelect) +TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect) { if (TxRxSelect == TX_DIR) { PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index c6a5ac1e647c..5d2fb52a8072 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -15,7 +15,7 @@ enum tr_select { RX_DIR = 1, }; -typedef struct _TS_COMMON_INFO { +struct ts_common_info { struct list_head List; struct timer_list SetupTimer; struct timer_list InactTimer; @@ -24,10 +24,10 @@ typedef struct _TS_COMMON_INFO { QOS_TCLAS TClass[TCLAS_NUM]; u8 TClasProc; u8 TClasNum; -} TS_COMMON_INFO, *PTS_COMMON_INFO; +}; typedef struct _TX_TS_RECORD { - TS_COMMON_INFO TsCommonInfo; + struct ts_common_info TsCommonInfo; u16 TxCurSeq; BA_RECORD TxPendingBARecord; /* For BA Originator */ BA_RECORD TxAdmittedBARecord; /* For BA Originator */ @@ -40,7 +40,7 @@ typedef struct _TX_TS_RECORD { } TX_TS_RECORD, *PTX_TS_RECORD; typedef struct _RX_TS_RECORD { - TS_COMMON_INFO TsCommonInfo; + struct ts_common_info TsCommonInfo; u16 RxIndicateSeq; u16 RxTimeoutIndicateSeq; struct list_head RxPendingPktList; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index d6ba9201028f..fd3347dca025 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -101,7 +101,7 @@ static void TsAddBaProcess(struct timer_list *t) } -static void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo) +static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { eth_zero_addr(pTsCommonInfo->Addr); memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); @@ -191,7 +191,7 @@ void TSInitialize(struct ieee80211_device *ieee) } static void AdmitTS(struct ieee80211_device *ieee, - PTS_COMMON_INFO pTsCommonInfo, u32 InactTime) + struct ts_common_info *pTsCommonInfo, u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); @@ -202,15 +202,15 @@ static void AdmitTS(struct ieee80211_device *ieee, } -static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, - u8 *Addr, u8 TID, - enum tr_select TxRxSelect) +static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, + u8 *Addr, u8 TID, + enum tr_select TxRxSelect) { //DIRECTION_VALUE dir; u8 dir; bool search_dir[4] = {0}; struct list_head *psearch_list; //FIXME - PTS_COMMON_INFO pRet = NULL; + struct ts_common_info *pRet = NULL; if(ieee->iw_mode == IW_MODE_MASTER) { //ap mode if(TxRxSelect == TX_DIR) { search_dir[DIR_DOWN] = true; @@ -264,7 +264,7 @@ static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, return NULL; } -static void MakeTSEntry(PTS_COMMON_INFO pTsCommonInfo, u8 *Addr, +static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, PTSPEC_BODY pTSPEC, PQOS_TCLAS pTCLAS, u8 TCLAS_Num, u8 TCLAS_Proc) { @@ -288,7 +288,7 @@ static void MakeTSEntry(PTS_COMMON_INFO pTsCommonInfo, u8 *Addr, bool GetTs( struct ieee80211_device *ieee, - PTS_COMMON_INFO *ppTS, + struct ts_common_info **ppTS, u8 *Addr, u8 TID, enum tr_select TxRxSelect, //Rx:1, Tx:0 @@ -371,7 +371,7 @@ bool GetTs( ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); IEEE80211_DEBUG(IEEE80211_DL_TS, "to add Ts\n"); if(!list_empty(pUnusedList)) { - (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List); + (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, List); list_del_init(&(*ppTS)->List); if(TxRxSelect==TX_DIR) { PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo); @@ -407,7 +407,7 @@ bool GetTs( } } -static void RemoveTsEntry(struct ieee80211_device *ieee, PTS_COMMON_INFO pTs, +static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info *pTs, enum tr_select TxRxSelect) { //u32 flags = 0; @@ -454,7 +454,7 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, PTS_COMMON_INFO pTs, void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) { - PTS_COMMON_INFO pTS, pTmpTS; + struct ts_common_info *pTS, *pTmpTS; printk("===========>RemovePeerTS,%pM\n", Addr); list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { @@ -493,7 +493,7 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) void RemoveAllTS(struct ieee80211_device *ieee) { - PTS_COMMON_INFO pTS, pTmpTS; + struct ts_common_info *pTS, *pTmpTS; list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); From d48cc3c3981165303b8d3d7a3c1ede9ffe17a3df Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:47 +0100 Subject: [PATCH 455/903] staging:rtl8192u: Rename List > list - Coding style In struct TS_COMMON_INFO rename the member List to list. This clears the checkpatch issue concerning CamelCase naming of variables. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 64 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 5d2fb52a8072..0a0420aa91cf 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -16,7 +16,7 @@ enum tr_select { }; struct ts_common_info { - struct list_head List; + struct list_head list; struct timer_list SetupTimer; struct timer_list InactTimer; u8 Addr[6]; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index fd3347dca025..24abdad52ed6 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -156,7 +156,7 @@ void TSInitialize(struct ieee80211_device *ieee) timer_setup(&pTxTS->TxAdmittedBARecord.Timer, TxBaInactTimeout, 0); ResetTxTsEntry(pTxTS); - list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List); + list_add_tail(&pTxTS->TsCommonInfo.list, &ieee->Tx_TS_Unused_List); pTxTS++; } @@ -175,7 +175,7 @@ void TSInitialize(struct ieee80211_device *ieee) RxBaInactTimeout, 0); timer_setup(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, 0); ResetRxTsEntry(pRxTS); - list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); + list_add_tail(&pRxTS->TsCommonInfo.list, &ieee->Rx_TS_Unused_List); pRxTS++; } // Initialize unused Rx Reorder List. @@ -245,7 +245,7 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, for(dir = 0; dir <= DIR_BI_DIR; dir++) { if (!search_dir[dir]) continue; - list_for_each_entry(pRet, psearch_list, List){ + list_for_each_entry(pRet, psearch_list, list){ // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); if (memcmp(pRet->Addr, Addr, 6) == 0) if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) @@ -254,11 +254,11 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, break; } } - if(&pRet->List != psearch_list) + if(&pRet->list != psearch_list) break; } - if(&pRet->List != psearch_list) + if(&pRet->list != psearch_list) return pRet ; else return NULL; @@ -371,8 +371,8 @@ bool GetTs( ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); IEEE80211_DEBUG(IEEE80211_DL_TS, "to add Ts\n"); if(!list_empty(pUnusedList)) { - (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, List); - list_del_init(&(*ppTS)->List); + (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, list); + list_del_init(&(*ppTS)->list); if(TxRxSelect==TX_DIR) { PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo); ResetTxTsEntry(tmp); @@ -395,7 +395,7 @@ bool GetTs( MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0); AdmitTS(ieee, *ppTS, 0); - list_add_tail(&((*ppTS)->List), pAddmitList); + list_add_tail(&((*ppTS)->list), pAddmitList); // if there is DirectLink, we need to do additional operation here!! return true; @@ -457,36 +457,36 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) struct ts_common_info *pTS, *pTmpTS; printk("===========>RemovePeerTS,%pM\n", Addr); - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, list) { if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, list) { if (memcmp(pTS->Addr, Addr, 6) == 0) { printk("====>remove Tx_TS_admin_list\n"); RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, list) { if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Rx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, list) { if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Rx_TS_Unused_List); } } } @@ -495,28 +495,28 @@ void RemoveAllTS(struct ieee80211_device *ieee) { struct ts_common_info *pTS, *pTmpTS; - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, list) { RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, list) { RemoveTsEntry(ieee, pTS, TX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, list) { RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Rx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, list) { RemoveTsEntry(ieee, pTS, RX_DIR); - list_del_init(&pTS->List); - list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); + list_del_init(&pTS->list); + list_add_tail(&pTS->list, &ieee->Rx_TS_Unused_List); } } From 36cf191fd45047cd30083c7e3aa4d3f7cd3f604a Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:48 +0100 Subject: [PATCH 456/903] staging:rtl8192u: rename SetupTimer > setup_timer - Style Rename the struct TS_COMMON_INFO member SetupTimer to setup_timer. This clears the checkpatch issue with CamelCase variable names. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 0a0420aa91cf..26384566d4f3 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -17,7 +17,7 @@ enum tr_select { struct ts_common_info { struct list_head list; - struct timer_list SetupTimer; + struct timer_list setup_timer; struct timer_list InactTimer; u8 Addr[6]; TSPEC_BODY TSpec; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 24abdad52ed6..efe8392043c1 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -146,7 +146,7 @@ void TSInitialize(struct ieee80211_device *ieee) pTxTS->num = count; // The timers for the operation of Traffic Stream and Block Ack. // DLS related timer will be add here in the future!! - timer_setup(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, + timer_setup(&pTxTS->TsCommonInfo.setup_timer, TsSetupTimeOut, 0); timer_setup(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout, 0); @@ -167,7 +167,7 @@ void TSInitialize(struct ieee80211_device *ieee) for(count = 0; count < TOTAL_TS_NUM; count++) { pRxTS->num = count; INIT_LIST_HEAD(&pRxTS->RxPendingPktList); - timer_setup(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, + timer_setup(&pRxTS->TsCommonInfo.setup_timer, TsSetupTimeOut, 0); timer_setup(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout, 0); @@ -193,7 +193,7 @@ void TSInitialize(struct ieee80211_device *ieee) static void AdmitTS(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, u32 InactTime) { - del_timer_sync(&pTsCommonInfo->SetupTimer); + del_timer_sync(&pTsCommonInfo->setup_timer); del_timer_sync(&pTsCommonInfo->InactTimer); if(InactTime!=0) @@ -412,7 +412,7 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info * { //u32 flags = 0; unsigned long flags = 0; - del_timer_sync(&pTs->SetupTimer); + del_timer_sync(&pTs->setup_timer); del_timer_sync(&pTs->InactTimer); TsInitDelBA(ieee, pTs, TxRxSelect); From 27c4a9bb9628e7d892de0b5fa80def9cc1894608 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:49 +0100 Subject: [PATCH 457/903] staging:rtl8192u: Rename InactTimer > inact_timer - Style Rename the struct TS_COMMON_INFO member InactTimer to inact_timer. This change clears the checkpatch issue with CamelCase naming. The change should not have any impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 26384566d4f3..1613c3c5d447 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -18,7 +18,7 @@ enum tr_select { struct ts_common_info { struct list_head list; struct timer_list setup_timer; - struct timer_list InactTimer; + struct timer_list inact_timer; u8 Addr[6]; TSPEC_BODY TSpec; QOS_TCLAS TClass[TCLAS_NUM]; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index efe8392043c1..175d91218af8 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -148,7 +148,7 @@ void TSInitialize(struct ieee80211_device *ieee) // DLS related timer will be add here in the future!! timer_setup(&pTxTS->TsCommonInfo.setup_timer, TsSetupTimeOut, 0); - timer_setup(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout, + timer_setup(&pTxTS->TsCommonInfo.inact_timer, TsInactTimeout, 0); timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0); timer_setup(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut, @@ -169,7 +169,7 @@ void TSInitialize(struct ieee80211_device *ieee) INIT_LIST_HEAD(&pRxTS->RxPendingPktList); timer_setup(&pRxTS->TsCommonInfo.setup_timer, TsSetupTimeOut, 0); - timer_setup(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout, + timer_setup(&pRxTS->TsCommonInfo.inact_timer, TsInactTimeout, 0); timer_setup(&pRxTS->RxAdmittedBARecord.Timer, RxBaInactTimeout, 0); @@ -194,10 +194,10 @@ static void AdmitTS(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, u32 InactTime) { del_timer_sync(&pTsCommonInfo->setup_timer); - del_timer_sync(&pTsCommonInfo->InactTimer); + del_timer_sync(&pTsCommonInfo->inact_timer); if(InactTime!=0) - mod_timer(&pTsCommonInfo->InactTimer, + mod_timer(&pTsCommonInfo->inact_timer, jiffies + msecs_to_jiffies(InactTime)); } @@ -413,7 +413,7 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info * //u32 flags = 0; unsigned long flags = 0; del_timer_sync(&pTs->setup_timer); - del_timer_sync(&pTs->InactTimer); + del_timer_sync(&pTs->inact_timer); TsInitDelBA(ieee, pTs, TxRxSelect); if(TxRxSelect == RX_DIR) { From 12a540c3f41153bbaf26eb831316c4c81c4654fe Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:50 +0100 Subject: [PATCH 458/903] staging:rtl8192u: Rename Addr > addr - Style Rename the TX_COMMON_INFO structure's member Addr to addr. This change clears the checkpatch issue with CamelCase naming. This is a coding style change only and should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 950f827a1740..297c498aef6a 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -634,7 +634,7 @@ TsInitAddBA( ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT); - ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA); + ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.addr, pBA); } void @@ -646,7 +646,7 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, if (TxTsDeleteBA(ieee, pTxTs)) ieee80211_send_DELBA( ieee, - pTsCommonInfo->Addr, + pTsCommonInfo->addr, (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), TxRxSelect, DELBA_REASON_END_BA); @@ -655,7 +655,7 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, if (RxTsDeleteBA(ieee, pRxTs)) ieee80211_send_DELBA( ieee, - pTsCommonInfo->Addr, + pTsCommonInfo->addr, &pRxTs->RxAdmittedBARecord, TxRxSelect, DELBA_REASON_END_BA); @@ -683,7 +683,7 @@ void TxBaInactTimeout(struct timer_list *t) TxTsDeleteBA(ieee, pTxTs); ieee80211_send_DELBA( ieee, - pTxTs->TsCommonInfo.Addr, + pTxTs->TsCommonInfo.addr, &pTxTs->TxAdmittedBARecord, TX_DIR, DELBA_REASON_TIMEOUT); @@ -697,7 +697,7 @@ void RxBaInactTimeout(struct timer_list *t) RxTsDeleteBA(ieee, pRxTs); ieee80211_send_DELBA( ieee, - pRxTs->TsCommonInfo.Addr, + pRxTs->TsCommonInfo.addr, &pRxTs->RxAdmittedBARecord, RX_DIR, DELBA_REASON_TIMEOUT); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 1613c3c5d447..62c6fc513540 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -19,7 +19,7 @@ struct ts_common_info { struct list_head list; struct timer_list setup_timer; struct timer_list inact_timer; - u8 Addr[6]; + u8 addr[6]; TSPEC_BODY TSpec; QOS_TCLAS TClass[TCLAS_NUM]; u8 TClasProc; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 175d91218af8..72a5fc0bbb47 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -103,7 +103,7 @@ static void TsAddBaProcess(struct timer_list *t) static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { - eth_zero_addr(pTsCommonInfo->Addr); + eth_zero_addr(pTsCommonInfo->addr); memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); pTsCommonInfo->TClasProc = 0; @@ -247,7 +247,7 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, continue; list_for_each_entry(pRet, psearch_list, list){ // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); - if (memcmp(pRet->Addr, Addr, 6) == 0) + if (memcmp(pRet->addr, Addr, 6) == 0) if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) if(pRet->TSpec.f.TSInfo.field.ucDirection == dir) { // printk("Bingo! got it\n"); @@ -273,7 +273,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, if(pTsCommonInfo == NULL) return; - memcpy(pTsCommonInfo->Addr, Addr, 6); + memcpy(pTsCommonInfo->addr, Addr, 6); if(pTSPEC != NULL) memcpy((u8 *)(&(pTsCommonInfo->TSpec)), (u8 *)pTSPEC, sizeof(TSPEC_BODY)); @@ -458,7 +458,7 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) printk("===========>RemovePeerTS,%pM\n", Addr); list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, list) { - if (memcmp(pTS->Addr, Addr, 6) == 0) { + if (memcmp(pTS->addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->list); list_add_tail(&pTS->list, &ieee->Tx_TS_Unused_List); @@ -466,7 +466,7 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) } list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, list) { - if (memcmp(pTS->Addr, Addr, 6) == 0) { + if (memcmp(pTS->addr, Addr, 6) == 0) { printk("====>remove Tx_TS_admin_list\n"); RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->list); @@ -475,7 +475,7 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) } list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, list) { - if (memcmp(pTS->Addr, Addr, 6) == 0) { + if (memcmp(pTS->addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->list); list_add_tail(&pTS->list, &ieee->Rx_TS_Unused_List); @@ -483,7 +483,7 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) } list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, list) { - if (memcmp(pTS->Addr, Addr, 6) == 0) { + if (memcmp(pTS->addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->list); list_add_tail(&pTS->list, &ieee->Rx_TS_Unused_List); From 912a9e0230bb20c4cfd5c537864acfd7c517f547 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:51 +0100 Subject: [PATCH 459/903] staging:rtl8192u: Rename TSpec > t_spec - Style Rename the TS_COMMON_INFO structure's member TSpec to t_spec. This change clears the checkpatch issue with CamelCase naming of variables. There should be no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 297c498aef6a..2c7d3ab1b5f7 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -626,7 +626,7 @@ TsInitAddBA( pBA->DialogToken++; // DialogToken: Only keep the latest dialog token pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!! pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate - pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; // TID + pBA->BaParamSet.field.TID = pTS->TsCommonInfo.t_spec.f.TSInfo.field.ucTSID; // TID // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 62c6fc513540..4c1b2e27cf94 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -20,7 +20,7 @@ struct ts_common_info { struct timer_list setup_timer; struct timer_list inact_timer; u8 addr[6]; - TSPEC_BODY TSpec; + TSPEC_BODY t_spec; QOS_TCLAS TClass[TCLAS_NUM]; u8 TClasProc; u8 TClasNum; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 72a5fc0bbb47..f9f4196f43fa 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -104,7 +104,7 @@ static void TsAddBaProcess(struct timer_list *t) static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { eth_zero_addr(pTsCommonInfo->addr); - memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); + memset(&pTsCommonInfo->t_spec, 0, sizeof(TSPEC_BODY)); memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); pTsCommonInfo->TClasProc = 0; pTsCommonInfo->TClasNum = 0; @@ -248,8 +248,8 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, list_for_each_entry(pRet, psearch_list, list){ // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); if (memcmp(pRet->addr, Addr, 6) == 0) - if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) - if(pRet->TSpec.f.TSInfo.field.ucDirection == dir) { + if (pRet->t_spec.f.TSInfo.field.ucTSID == TID) + if(pRet->t_spec.f.TSInfo.field.ucDirection == dir) { // printk("Bingo! got it\n"); break; } @@ -276,7 +276,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, memcpy(pTsCommonInfo->addr, Addr, 6); if(pTSPEC != NULL) - memcpy((u8 *)(&(pTsCommonInfo->TSpec)), (u8 *)pTSPEC, sizeof(TSPEC_BODY)); + memcpy((u8 *)(&(pTsCommonInfo->t_spec)), (u8 *)pTSPEC, sizeof(TSPEC_BODY)); for(count = 0; count < TCLAS_Num; count++) memcpy((u8 *)(&(pTsCommonInfo->TClass[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS)); From 288e0a7c22ee7fb210d93ed7a9a7c9563c8eb02e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 16 Jul 2018 20:04:52 +0100 Subject: [PATCH 460/903] staging:rtl8192u: Rename TClass > t_class - Style Rename the struct TS_COMMON_INFO member variable from TClass to t_class. This change clears the checkpatch issue with CamelCase Variable names. There should be no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 4c1b2e27cf94..3bf48a04a68e 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -21,7 +21,7 @@ struct ts_common_info { struct timer_list inact_timer; u8 addr[6]; TSPEC_BODY t_spec; - QOS_TCLAS TClass[TCLAS_NUM]; + QOS_TCLAS t_class[TCLAS_NUM]; u8 TClasProc; u8 TClasNum; }; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index f9f4196f43fa..b5fede650b81 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -105,7 +105,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { eth_zero_addr(pTsCommonInfo->addr); memset(&pTsCommonInfo->t_spec, 0, sizeof(TSPEC_BODY)); - memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); + memset(&pTsCommonInfo->t_class, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); pTsCommonInfo->TClasProc = 0; pTsCommonInfo->TClasNum = 0; } @@ -279,7 +279,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, memcpy((u8 *)(&(pTsCommonInfo->t_spec)), (u8 *)pTSPEC, sizeof(TSPEC_BODY)); for(count = 0; count < TCLAS_Num; count++) - memcpy((u8 *)(&(pTsCommonInfo->TClass[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS)); + memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS)); pTsCommonInfo->TClasProc = TCLAS_Proc; pTsCommonInfo->TClasNum = TCLAS_Num; From b613aac2dc0eb6d3c4372e6255549931f1823134 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 20 Jul 2018 21:21:29 +0100 Subject: [PATCH 461/903] staging:rtl8192u: Remove multiple blank lines - Style Remove multiple blank lines which cause checkpatch issues. These are purely coding style changes which should not impact execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 88bc298305bd..23ab2dae8347 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -4,7 +4,6 @@ #include "ieee80211.h" - typedef struct _CHNL_TXPOWER_TRIPLE { u8 FirstChnl; u8 NumChnls; @@ -59,7 +58,6 @@ typedef struct _RT_DOT11D_INFO { #define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE) - void Dot11d_Init( struct ieee80211_device *dev From 1f1590f25efda14dabdade01149f39b0bca37237 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 20 Jul 2018 21:21:30 +0100 Subject: [PATCH 462/903] staging:rtl8192u: Remove typedef from structure - Style Remove the typedef directive from struct _CHNL_TXPOWER_TRIPLE. This is a coding style change which clears a checkpatch issue with declaring new types. There should be no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/dot11d.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index ba284bfb3b6d..8ac08ee5256e 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -54,13 +54,13 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, { PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); u8 i, j, NumTriples, MaxChnlNum; - PCHNL_TXPOWER_TRIPLE pTriple; + struct chnl_txpower_triple *pTriple; memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); MaxChnlNum = 0; NumTriples = (CoutryIeLen - 3) / 3; /* skip 3-byte country string. */ - pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3); + pTriple = (struct chnl_txpower_triple *)(pCoutryIe + 3); for (i = 0; i < NumTriples; i++) { if (MaxChnlNum >= pTriple->FirstChnl) { /* It is not in a monotonically increasing order, so @@ -83,7 +83,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, MaxChnlNum = pTriple->FirstChnl + j; } - pTriple = (PCHNL_TXPOWER_TRIPLE)((u8 *)pTriple + 3); + pTriple = (struct chnl_txpower_triple *)((u8 *)pTriple + 3); } netdev_info(dev->dev, "Channel List:"); for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 23ab2dae8347..9471279cf8e6 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -4,11 +4,11 @@ #include "ieee80211.h" -typedef struct _CHNL_TXPOWER_TRIPLE { +struct chnl_txpower_triple { u8 FirstChnl; u8 NumChnls; u8 MaxTxPowerInDbm; -} CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE; +}; typedef enum _DOT11D_STATE { DOT11D_STATE_NONE = 0, From 85f24df0b4ef85318951411189b917c1aced6b3d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 20 Jul 2018 21:21:31 +0100 Subject: [PATCH 463/903] staging:rtl8192u: Rename structure member FirstChnl - Style Rename structure member FirstChnl to first_channel. This coding style change clears a checkpatch issue with CamelCase naming. This change should not impact the runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index 8ac08ee5256e..f24dae97bc0d 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -62,14 +62,14 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, NumTriples = (CoutryIeLen - 3) / 3; /* skip 3-byte country string. */ pTriple = (struct chnl_txpower_triple *)(pCoutryIe + 3); for (i = 0; i < NumTriples; i++) { - if (MaxChnlNum >= pTriple->FirstChnl) { + if (MaxChnlNum >= pTriple->first_channel) { /* It is not in a monotonically increasing order, so * stop processing. */ netdev_err(dev->dev, "Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n"); return; } - if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls)) { + if (MAX_CHANNEL_NUMBER < (pTriple->first_channel + pTriple->NumChnls)) { /* It is not a valid set of channel id, so stop * processing. */ @@ -78,9 +78,9 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, } for (j = 0; j < pTriple->NumChnls; j++) { - pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1; - pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm; - MaxChnlNum = pTriple->FirstChnl + j; + pDot11dInfo->channel_map[pTriple->first_channel + j] = 1; + pDot11dInfo->MaxTxPwrDbmList[pTriple->first_channel + j] = pTriple->MaxTxPowerInDbm; + MaxChnlNum = pTriple->first_channel + j; } pTriple = (struct chnl_txpower_triple *)((u8 *)pTriple + 3); diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 9471279cf8e6..968c622137df 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -5,7 +5,7 @@ #include "ieee80211.h" struct chnl_txpower_triple { - u8 FirstChnl; + u8 first_channel; u8 NumChnls; u8 MaxTxPowerInDbm; }; From 321639a74a9a9a03285c426c5a6a688f1df83572 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 20 Jul 2018 21:21:32 +0100 Subject: [PATCH 464/903] staging:rtl8192u: Rename variable NumChnls - Style Rename the member variable NumChnls to num_channels. This change clears the checkpatch issue with CamelCase naming. The change should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index f24dae97bc0d..17bccb7bf594 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -69,7 +69,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, netdev_err(dev->dev, "Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n"); return; } - if (MAX_CHANNEL_NUMBER < (pTriple->first_channel + pTriple->NumChnls)) { + if (MAX_CHANNEL_NUMBER < (pTriple->first_channel + pTriple->num_channels)) { /* It is not a valid set of channel id, so stop * processing. */ @@ -77,7 +77,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, return; } - for (j = 0; j < pTriple->NumChnls; j++) { + for (j = 0; j < pTriple->num_channels; j++) { pDot11dInfo->channel_map[pTriple->first_channel + j] = 1; pDot11dInfo->MaxTxPwrDbmList[pTriple->first_channel + j] = pTriple->MaxTxPowerInDbm; MaxChnlNum = pTriple->first_channel + j; diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 968c622137df..8c2b11d12185 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -6,7 +6,7 @@ struct chnl_txpower_triple { u8 first_channel; - u8 NumChnls; + u8 num_channels; u8 MaxTxPowerInDbm; }; From 8132962a11a5747dd75641f4a5766f9ae311a419 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 20 Jul 2018 21:21:33 +0100 Subject: [PATCH 465/903] staging:rtl8192u: Rename variable MaxTxPowerInDbm - Style Rename the variable MaxTxPowerInDbm to max_tx_pwr_dbm. This change clears a checkpatch issue with CamelCase naming. This coding style change should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 2 +- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index 17bccb7bf594..44b5e506b140 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -79,7 +79,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, for (j = 0; j < pTriple->num_channels; j++) { pDot11dInfo->channel_map[pTriple->first_channel + j] = 1; - pDot11dInfo->MaxTxPwrDbmList[pTriple->first_channel + j] = pTriple->MaxTxPowerInDbm; + pDot11dInfo->MaxTxPwrDbmList[pTriple->first_channel + j] = pTriple->max_tx_pwr_dbm; MaxChnlNum = pTriple->first_channel + j; } diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 8c2b11d12185..1b377faa53e0 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -7,7 +7,7 @@ struct chnl_txpower_triple { u8 first_channel; u8 num_channels; - u8 MaxTxPowerInDbm; + u8 max_tx_pwr_dbm; }; typedef enum _DOT11D_STATE { From e24411b3a099faa8ca7efcda589a08e3d60698f9 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 20 Jul 2018 21:21:34 +0100 Subject: [PATCH 466/903] staging:rtl8192u: Remove typedef and rename DOT11D_STATE - Style Remove typedef from enumerated type DOT11D_STATE to clear checkpatch issue with declaring new types. Rename the enumertion from DOT11D_STATE to dot11d_state. These changes are coding style changes which should not effect runtime execution of code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 1b377faa53e0..9402c05cb24f 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -10,11 +10,11 @@ struct chnl_txpower_triple { u8 max_tx_pwr_dbm; }; -typedef enum _DOT11D_STATE { +enum dot11d_state { DOT11D_STATE_NONE = 0, DOT11D_STATE_LEARNED, DOT11D_STATE_DONE, -} DOT11D_STATE; +}; typedef struct _RT_DOT11D_INFO { /* DECLARE_RT_OBJECT(RT_DOT11D_INFO); */ @@ -29,7 +29,7 @@ typedef struct _RT_DOT11D_INFO { u8 channel_map[MAX_CHANNEL_NUMBER+1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; - DOT11D_STATE State; + enum dot11d_state State; } RT_DOT11D_INFO, *PRT_DOT11D_INFO; #define eqMacAddr(a, b) (((a)[0] == (b)[0] && \ (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && \ From c3bfe9f186a57f7eca7e9846c4a68666228e40d5 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:14:57 +0530 Subject: [PATCH 467/903] staging: wilc1000: remove unused enum declaration Cleanup patch to remove unused enums. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 8 ------- drivers/staging/wilc1000/host_interface.h | 6 ----- drivers/staging/wilc1000/wilc_wlan_if.h | 26 --------------------- 3 files changed, 40 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 44816024f79c..006389587152 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -4,14 +4,6 @@ #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ BEACON_INTERVAL_LEN + CAP_INFO_LEN) -enum basic_frame_type { - FRAME_TYPE_CONTROL = 0x04, - FRAME_TYPE_DATA = 0x08, - FRAME_TYPE_MANAGEMENT = 0x00, - FRAME_TYPE_RESERVED = 0x0C, - FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF -}; - enum sub_frame_type { ASSOC_REQ = 0x00, ASSOC_RSP = 0x10, diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 0ea22abd66a3..3cd97dd5c317 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -252,12 +252,6 @@ struct reg_frame { u8 reg_id; }; -enum p2p_listen_state { - P2P_IDLE, - P2P_LISTEN, - P2P_GRP_FORMATION -}; - struct wilc; struct host_if_drv { struct user_scan_req usr_scan_req; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index e4a7bf5df65b..85ac87846928 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -175,12 +175,6 @@ enum { NO_ACK, }; -enum { - DONT_RESET = 0, - DO_RESET = 1, - NO_REQUEST = 2, -}; - enum { REKEY_DISABLE = 1, REKEY_TIME_BASE, @@ -194,17 +188,6 @@ enum { FILTER_STA_ONLY = 0x02 }; -enum { - PRI_HIGH_RSSI = 0x00, - PRI_LOW_RSSI = 0x04, - PRI_DETECT = 0x08 -}; - -enum { - CH_FILTER_OFF = 0x00, - CH_FILTER_ON = 0x10 -}; - enum { AUTO_PROT = 0, /* Auto */ NO_PROT, /* Do not use any protection */ @@ -244,15 +227,6 @@ enum { MIMO_MODE = 3, /* power save disable */ }; -enum { - DISABLE_SELF_CTS, - ENABLE_SELF_CTS, - DISABLE_TX_ABORT, - ENABLE_TX_ABORT, - HW_TRIGGER_ABORT, - SW_TRIGGER_ABORT, -}; - enum wid_type { WID_CHAR = 0, WID_SHORT = 1, From d300da185096353a45e76cd8faebc311a7ab4026 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:14:58 +0530 Subject: [PATCH 468/903] staging: wilc1000: remove enum connect_status instead use ieee80211_statuscode Cleanup patch to remove the use of enum 'connect_status' and instead use predefined 'ieee80211_statuscode' for error code values. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 4 +++- drivers/staging/wilc1000/coreconfigurator.h | 20 ------------------- drivers/staging/wilc1000/host_interface.c | 6 +++--- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 006389587152..a9879536b6a6 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -1,4 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#include + #include "coreconfigurator.h" #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ @@ -316,7 +318,7 @@ s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, u16 ies_len = 0; ret_conn_info->status = get_asoc_status(buffer); - if (ret_conn_info->status == SUCCESSFUL_STATUSCODE) { + if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; ies_len = buffer_len - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 55b5531856f8..90d3d656e8cd 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -24,26 +24,6 @@ #define MAKE_WORD16(lsb, msb) ((((u16)(msb) << 8) & 0xFF00) | (lsb)) #define MAKE_WORD32(lsw, msw) ((((u32)(msw) << 16) & 0xFFFF0000) | (lsw)) -enum connect_status { - SUCCESSFUL_STATUSCODE = 0, - UNSPEC_FAIL = 1, - UNSUP_CAP = 10, - REASOC_NO_ASOC = 11, - FAIL_OTHER = 12, - UNSUPT_ALG = 13, - AUTH_SEQ_FAIL = 14, - CHLNG_FAIL = 15, - AUTH_TIMEOUT = 16, - AP_FULL = 17, - UNSUP_RATE = 18, - SHORT_PREAMBLE_UNSUP = 19, - PBCC_UNSUP = 20, - CHANNEL_AGIL_UNSUP = 21, - SHORT_SLOT_UNSUP = 25, - OFDM_DSSS_UNSUP = 26, - CONNECT_STS_FORCE_16_BIT = 0xFFFF -}; - struct rssi_history_buffer { bool full; u8 index; diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 918d06e8cd34..9b5bf3cad599 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1336,7 +1336,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, } if (mac_status == MAC_STATUS_CONNECTED && - conn_info.status != SUCCESSFUL_STATUSCODE) { + conn_info.status != WLAN_STATUS_SUCCESS) { netdev_err(vif->ndev, "Received MAC status is MAC_STATUS_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n"); eth_zero_addr(wilc_connected_ssid); @@ -1349,7 +1349,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, memcpy(conn_info.bssid, hif_drv->usr_conn_req.bssid, 6); if (mac_status == MAC_STATUS_CONNECTED && - conn_info.status == SUCCESSFUL_STATUSCODE) { + conn_info.status == WLAN_STATUS_SUCCESS) { memcpy(hif_drv->assoc_bssid, hif_drv->usr_conn_req.bssid, ETH_ALEN); } @@ -1369,7 +1369,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, hif_drv->usr_conn_req.arg); if (mac_status == MAC_STATUS_CONNECTED && - conn_info.status == SUCCESSFUL_STATUSCODE) { + conn_info.status == WLAN_STATUS_SUCCESS) { wilc_set_power_mgmt(vif, 0, 0); hif_drv->hif_state = HOST_IF_CONNECTED; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index e96163f38e7b..f90b9b68e9e0 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -489,7 +489,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, connect_status = conn_info->status; if (mac_status == MAC_STATUS_DISCONNECTED && - conn_info->status == SUCCESSFUL_STATUSCODE) { + conn_info->status == WLAN_STATUS_SUCCESS) { connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE; wilc_wlan_set_bssid(priv->dev, null_bssid, STATION_MODE); From b69845eaef2c5044d6e49ecfb11021cdfe6ffe1f Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:14:59 +0530 Subject: [PATCH 469/903] staging: wilc1000: remove extra enum defined for data rates Cleanup patch to remove extra enum defined to handle data rates. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wlan_if.h | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 0019bb8df6c1..032afc25ebe2 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -378,7 +378,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0)) goto fail; - c_val[0] = RATE_AUTO; + c_val[0] = AUTORATE; if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) goto fail; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 85ac87846928..b23f86c0d8fb 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -87,22 +87,6 @@ enum bss_types { AP, }; -enum { - RATE_AUTO = 0, - RATE_1MB = 1, - RATE_2MB = 2, - RATE_5MB = 5, - RATE_6MB = 6, - RATE_9MB = 9, - RATE_11MB = 11, - RATE_12MB = 12, - RATE_18MB = 18, - RATE_24MB = 24, - RATE_26MB = 36, - RATE_48MB = 48, - RATE_54MB = 54 -}; - enum { B_ONLY_MODE = 0, /* 1, 2 M, otherwise 5, 11 M */ G_ONLY_MODE, /* 6,12,24 otherwise 9,18,36,48,54 */ From 8c67e814fadc84e38ff6873081b0859ae2eb8025 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:00 +0530 Subject: [PATCH 470/903] staging: wilc1000: remove extra enums defined for ieee80211_eid Cleanup patch to make use of existing enum 'ieee80211_eid' instead of adding new enum in WILC for element ID's. The below mapping is same to remove extra enum in WILC. SUPP_RATES_IE -> WLAN_EID_SUPP_RATES EXT_SUPP_RATES_IE -> WLAN_EID_EXT_SUPP_RATES HT_CAPABILITY_IE -> WLAN_EID_HT_CAPABILITY RSN_IE -> WLAN_EID_RSN WPA_IE -> WLAN_EID_VENDOR_SPECIFIC WMM_IE -> WLAN_EID_VENDOR_SPECIFIC P2P_IE -> WLAN_EID_VENDOR_SPECIFIC Also remove enum 'info_element_id' as its same as 'ieee80211_eid', below the mapping of elements of enums which are used. ITIM -> WLAN_EID_TIM IDSPARMS -> WLAN_EID_DS_PARAMS Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 47 +-------------------- drivers/staging/wilc1000/host_interface.c | 19 +++++---- drivers/staging/wilc1000/wilc_wlan_if.h | 10 ----- 3 files changed, 12 insertions(+), 64 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index a9879536b6a6..5933e4d20339 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -45,49 +45,6 @@ enum sub_frame_type { FRAME_SUBTYPE_FORCE_32BIT = 0xFFFFFFFF }; -enum info_element_id { - ISSID = 0, /* Service Set Identifier */ - ISUPRATES = 1, /* Supported Rates */ - IFHPARMS = 2, /* FH parameter set */ - IDSPARMS = 3, /* DS parameter set */ - ICFPARMS = 4, /* CF parameter set */ - ITIM = 5, /* Traffic Information Map */ - IIBPARMS = 6, /* IBSS parameter set */ - ICOUNTRY = 7, /* Country element */ - IEDCAPARAMS = 12, /* EDCA parameter set */ - ITSPEC = 13, /* Traffic Specification */ - ITCLAS = 14, /* Traffic Classification */ - ISCHED = 15, /* Schedule */ - ICTEXT = 16, /* Challenge Text */ - IPOWERCONSTRAINT = 32, /* Power Constraint */ - IPOWERCAPABILITY = 33, /* Power Capability */ - ITPCREQUEST = 34, /* TPC Request */ - ITPCREPORT = 35, /* TPC Report */ - ISUPCHANNEL = 36, /* Supported channel list */ - ICHSWANNOUNC = 37, /* Channel Switch Announcement */ - IMEASUREMENTREQUEST = 38, /* Measurement request */ - IMEASUREMENTREPORT = 39, /* Measurement report */ - IQUIET = 40, /* Quiet element Info */ - IIBSSDFS = 41, /* IBSS DFS */ - IERPINFO = 42, /* ERP Information */ - ITSDELAY = 43, /* TS Delay */ - ITCLASPROCESS = 44, /* TCLAS Processing */ - IHTCAP = 45, /* HT Capabilities */ - IQOSCAP = 46, /* QoS Capability */ - IRSNELEMENT = 48, /* RSN Information Element */ - IEXSUPRATES = 50, /* Extended Supported Rates */ - IEXCHSWANNOUNC = 60, /* Extended Ch Switch Announcement*/ - IHTOPERATION = 61, /* HT Information */ - ISECCHOFF = 62, /* Secondary Channel Offeset */ - I2040COEX = 72, /* 20/40 Coexistence IE */ - I2040INTOLCHREPORT = 73, /* 20/40 Intolerant channel report*/ - IOBSSSCAN = 74, /* OBSS Scan parameters */ - IEXTCAP = 127, /* Extended capability */ - IWMM = 221, /* WMM parameters */ - IWPAELEMENT = 221, /* WPA Information Element */ - INFOELEM_ID_FORCE_32BIT = 0xFFFFFFFF -}; - static inline u16 get_beacon_period(u8 *data) { u16 bcn_per; @@ -216,7 +173,7 @@ static u8 *get_tim_elm(u8 *msa, u16 rx_len, u16 tag_param_offset) index = tag_param_offset; while (index < (rx_len - FCS_LEN)) { - if (msa[index] == ITIM) + if (msa[index] == WLAN_EID_TIM) return &msa[index]; index += (IE_HDR_LEN + msa[index + 1]); } @@ -230,7 +187,7 @@ static u8 get_current_channel_802_11n(u8 *msa, u16 rx_len) index = TAG_PARAM_OFFSET; while (index < (rx_len - FCS_LEN)) { - if (msa[index] == IDSPARMS) + if (msa[index] == WLAN_EID_DS_PARAMS) return msa[index + 2]; index += msa[index + 1] + IE_HDR_LEN; } diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 9b5bf3cad599..7309b7eee8e6 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3861,7 +3861,7 @@ static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, u8 i, j; u16 index = *out_index; - if (ies[index] == SUPP_RATES_IE) { + if (ies[index] == WLAN_EID_SUPP_RATES) { *rates_no = ies[index + 1]; param->supp_rates[0] = *rates_no; index += 2; @@ -3870,7 +3870,7 @@ static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, param->supp_rates[i + 1] = ies[index + i]; index += *rates_no; - } else if (ies[index] == EXT_SUPP_RATES_IE) { + } else if (ies[index] == WLAN_EID_EXT_SUPP_RATES) { ext_rates_no = ies[index + 1]; if (ext_rates_no > (MAX_RATES_SUPPORTED - *rates_no)) param->supp_rates[0] = MAX_RATES_SUPPORTED; @@ -3881,10 +3881,10 @@ static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, param->supp_rates[*rates_no + i + 1] = ies[index + i]; index += ext_rates_no; - } else if (ies[index] == HT_CAPABILITY_IE) { + } else if (ies[index] == WLAN_EID_HT_CAPABILITY) { param->ht_capable = true; index += ies[index + 1] + 2; - } else if ((ies[index] == WMM_IE) && + } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && (ies[index + 2] == 0x00) && (ies[index + 3] == 0x50) && (ies[index + 4] == 0xF2) && (ies[index + 5] == 0x02) && ((ies[index + 6] == 0x00) || (ies[index + 6] == 0x01)) && @@ -3894,7 +3894,7 @@ static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, if (ies[index + 8] & BIT(7)) param->uapsd_cap = true; index += ies[index + 1] + 2; - } else if ((ies[index] == P2P_IE) && + } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && (ies[index + 2] == 0x50) && (ies[index + 3] == 0x6f) && (ies[index + 4] == 0x9a) && (ies[index + 5] == 0x09) && (ies[index + 6] == 0x0c)) { @@ -3923,13 +3923,14 @@ static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, memcpy(param->start_time, ies + p2p_cnt, 4); index += ies[index + 1] + 2; - } else if ((ies[index] == RSN_IE) || - ((ies[index] == WPA_IE) && (ies[index + 2] == 0x00) && + } else if ((ies[index] == WLAN_EID_RSN) || + ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && + (ies[index + 2] == 0x00) && (ies[index + 3] == 0x50) && (ies[index + 4] == 0xF2) && (ies[index + 5] == 0x01))) { u16 rsn_idx = index; - if (ies[rsn_idx] == RSN_IE) { + if (ies[rsn_idx] == WLAN_EID_RSN) { param->mode_802_11i = 2; } else { if (param->mode_802_11i == 0) @@ -3970,7 +3971,7 @@ static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, *auth_total_cnt += auth_cnt; rsn_idx += offset; - if (ies[index] == RSN_IE) { + if (ies[index] == WLAN_EID_RSN) { param->rsn_cap[0] = ies[rsn_idx]; param->rsn_cap[1] = ies[rsn_idx + 1]; rsn_idx += 2; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index b23f86c0d8fb..af414d7387e7 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -71,16 +71,6 @@ typedef void (*wilc_tx_complete_func_t)(void *, int); #define MAX_SSID_LEN 33 #define MAX_RATES_SUPPORTED 12 -enum { - SUPP_RATES_IE = 1, - EXT_SUPP_RATES_IE = 50, - HT_CAPABILITY_IE = 45, - RSN_IE = 48, - WPA_IE = 221, - WMM_IE = 221, - P2P_IE = 221, -}; - enum bss_types { INFRASTRUCTURE = 0, INDEPENDENT, From 18da9e4ad2cb02291b3f2d2c4f53790b50286557 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:01 +0530 Subject: [PATCH 471/903] staging: wilc1000: rename goto to avoid leading '_' in label name Cleanup patch to avoid use of leading '_' in goto label name. Also used proper string for lable names. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 8 ++++---- drivers/staging/wilc1000/wilc_wlan.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index f90b9b68e9e0..73606c3d840f 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -2196,11 +2196,11 @@ static struct wireless_dev *wilc_wfi_cfg_alloc(void) wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); if (!wdev) - goto _fail_; + goto out; wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv)); if (!wdev->wiphy) - goto _fail_mem_; + goto free_mem; wilc_band_2ghz.ht_cap.ht_supported = 1; wilc_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); @@ -2212,9 +2212,9 @@ static struct wireless_dev *wilc_wfi_cfg_alloc(void) return wdev; -_fail_mem_: +free_mem: kfree(wdev); -_fail_: +out: return NULL; } diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 85af36595e69..8e71c282ecda 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -850,13 +850,13 @@ static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status) if (wilc->rx_buffer) buffer = &wilc->rx_buffer[offset]; else - goto _end_; + goto end; wilc->hif_func->hif_clear_int_ext(wilc, DATA_INT_CLR | ENABLE_RX_VMM); ret = wilc->hif_func->hif_block_rx_ext(wilc, 0, buffer, size); -_end_: +end: if (ret) { offset += size; wilc->rx_buffer_offset = offset; From 05b9eaa7fc656a5612e3a0bdbe680e291402241e Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:02 +0530 Subject: [PATCH 472/903] staging: wilc1000: rename enum CURRENT_TXRATE to use lowercase Cleanup patch to rename enums in lowercase to follow linux coding style. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 2 +- drivers/staging/wilc1000/host_interface.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 7309b7eee8e6..cc64b14eadf9 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -695,7 +695,7 @@ static void handle_cfg_param(struct work_struct *work) i++; } if (param->flag & CURRENT_TX_RATE) { - enum CURRENT_TXRATE curr_tx_rate = param->curr_tx_rate; + enum current_tx_rate curr_tx_rate = param->curr_tx_rate; if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 || diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 3cd97dd5c317..64fc269ae7f9 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -81,7 +81,7 @@ struct host_if_pmkid_attr { struct host_if_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; }; -enum CURRENT_TXRATE { +enum current_tx_rate { AUTORATE = 0, MBPS_1 = 1, MBPS_2 = 2, @@ -118,7 +118,7 @@ struct cfg_param_attr { u8 scan_source; u16 active_scan_time; u16 passive_scan_time; - enum CURRENT_TXRATE curr_tx_rate; + enum current_tx_rate curr_tx_rate; }; From 90824b7cdfd517295b5db532cb27c5f25b081470 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:03 +0530 Subject: [PATCH 473/903] staging: wilc1000: rename enum SITESURVEY to use lowercase Cleanup patch to have enum in lowercase as per linux coding style. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 2 +- drivers/staging/wilc1000/host_interface.h | 2 +- drivers/staging/wilc1000/wilc_wlan_if.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index cc64b14eadf9..a5c0ac5a89c4 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -635,7 +635,7 @@ static void handle_cfg_param(struct work_struct *work) i++; } if (param->flag & SITE_SURVEY) { - enum SITESURVEY enabled = param->site_survey_enabled; + enum site_survey enabled = param->site_survey_enabled; if (enabled < 3) { wid_list[i].id = WID_SITE_SURVEY; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 64fc269ae7f9..7f3e48cc009e 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -113,7 +113,7 @@ struct cfg_param_attr { u8 txop_prot_disabled; u16 beacon_interval; u16 dtim_period; - enum SITESURVEY site_survey_enabled; + enum site_survey site_survey_enabled; u16 site_survey_scan_time; u8 scan_source; u16 active_scan_time; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index af414d7387e7..b82e149ba2f3 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -138,7 +138,7 @@ enum AUTHTYPE { IEEE8021 = 5 }; -enum SITESURVEY { +enum site_survey { SITE_SURVEY_1CH = 0, SITE_SURVEY_ALL_CH = 1, SITE_SURVEY_OFF = 2 From ecba6b7477b2c52ea319a22f0c772196a1904812 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:04 +0530 Subject: [PATCH 474/903] staging: wilc1000: rename enum AUTHTYPE to use lowercase Cleanup patch to rename enum AUTHTYPE to lowercase. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 8 ++++---- drivers/staging/wilc1000/host_interface.h | 6 +++--- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- drivers/staging/wilc1000/wilc_wlan_if.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index a5c0ac5a89c4..0ffe205dad75 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -26,7 +26,7 @@ struct host_if_wep_attr { u8 key_len; u8 index; u8 mode; - enum AUTHTYPE auth_type; + enum authtype auth_type; }; union host_if_key_attr { @@ -62,7 +62,7 @@ struct connect_attr { u8 security; wilc_connect_result result; void *arg; - enum AUTHTYPE auth_type; + enum authtype auth_type; u8 ch; void *params; }; @@ -2632,7 +2632,7 @@ free_msg: } int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, - u8 index, u8 mode, enum AUTHTYPE auth_type) + u8 index, u8 mode, enum authtype auth_type) { int result; struct host_if_msg *msg; @@ -2876,7 +2876,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, size_t ssid_len, const u8 *ies, size_t ies_len, wilc_connect_result connect_result, void *user_arg, - u8 security, enum AUTHTYPE auth_type, + u8 security, enum authtype auth_type, u8 channel, void *join_params) { int result = 0; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 7f3e48cc009e..79166a5fb96d 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -207,7 +207,7 @@ struct user_conn_req { u8 *bssid; u8 *ssid; u8 security; - enum AUTHTYPE auth_type; + enum authtype auth_type; size_t ssid_len; u8 *ies; size_t ies_len; @@ -298,7 +298,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index); int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, u8 index); int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, - u8 index, u8 mode, enum AUTHTYPE auth_type); + u8 index, u8 mode, enum authtype auth_type); int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, u8 mode, u8 cipher_mode, u8 index); @@ -314,7 +314,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr); int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, size_t ssid_len, const u8 *ies, size_t ies_len, wilc_connect_result connect_result, void *user_arg, - u8 security, enum AUTHTYPE auth_type, + u8 security, enum authtype auth_type, u8 channel, void *join_params); int wilc_disconnect(struct wilc_vif *vif, u16 reason_code); int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 73606c3d840f..8f1c59507962 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -678,7 +678,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, u32 i; u32 sel_bssi_idx = UINT_MAX; u8 security = NO_ENCRYPT; - enum AUTHTYPE auth_type = ANY; + enum authtype auth_type = ANY; u32 cipher_group; struct wilc_priv *priv; struct host_if_drv *wfi_drv; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index b82e149ba2f3..73b57fb623b6 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -131,7 +131,7 @@ enum { WPA2_AES_TKIP = 0x71, /* Aes or Tkip */ }; -enum AUTHTYPE { +enum authtype { OPEN_SYSTEM = 1, SHARED_KEY = 2, ANY = 3, From 9fdc7420f2824c7b00887aaaea767975c7eadf4d Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:05 +0530 Subject: [PATCH 475/903] staging: wilc1000: remove unused elements in 'wilc' struct Cleanup patch to remove unused elements from 'wilc' struct. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 ---- drivers/staging/wilc1000/wilc_wlan.c | 6 ------ 2 files changed, 10 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index fe18ae9843db..22f348626d0a 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -157,12 +157,8 @@ struct wilc { struct txq_entry_t txq_head; int txq_entries; - int txq_exit; struct rxq_entry_t rxq_head; - int rxq_exit; - - unsigned char eth_src_address[NUM_CONCURRENT_IFC][6]; const struct firmware *firmware; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 8e71c282ecda..c77e5c827c4d 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -527,7 +527,6 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) wilc = vif->wilc; txb = wilc->tx_buffer; - wilc->txq_exit = 0; if (wilc->quit) goto out; @@ -713,7 +712,6 @@ out_release_bus: out: mutex_unlock(&wilc->txq_add_to_head_cs); - wilc->txq_exit = 1; *txq_count = wilc->txq_entries; return ret; } @@ -780,8 +778,6 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc) u8 *buffer; struct rxq_entry_t *rqe; - wilc->rxq_exit = 0; - do { if (wilc->quit) { complete(&wilc->cfg_event); @@ -797,8 +793,6 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc) kfree(rqe); } while (1); - - wilc->rxq_exit = 1; } static void wilc_unknown_isr_ext(struct wilc *wilc) From 37d1a6dbb49248b5e9fb8c007736bc4351a90633 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:06 +0530 Subject: [PATCH 476/903] staging: wilc1000: remove unnecessary elements from 'wilc_priv' struct Remove unused elements from 'wilc_priv' structure. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ---- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 7 ------- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 8f1c59507962..1a27e81637ea 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -2276,8 +2276,6 @@ int wilc_init_host_int(struct net_device *net) } op_ifcs++; - priv->auto_rate_adjusted = false; - priv->p2p_listen_state = false; mutex_init(&priv->scan_req_lock); @@ -2297,8 +2295,6 @@ int wilc_deinit_host_int(struct net_device *net) priv = wdev_priv(net->ieee80211_ptr); vif = netdev_priv(priv->dev); - priv->auto_rate_adjusted = false; - priv->p2p_listen_state = false; op_ifcs--; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 22f348626d0a..87f8cdc2acec 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -74,14 +74,10 @@ struct wilc_priv { u8 associated_bss[ETH_ALEN]; struct sta_info assoc_stainfo; - struct net_device_stats stats; - u8 monitor_flag; - int status; struct sk_buff *skb; struct net_device *dev; struct host_if_drv *hif_drv; struct host_if_pmkid_attr pmkid_list; - struct wilc_wfi_stats netstats; u8 wep_key[4][WLAN_KEY_LEN_WEP104]; u8 wep_key_len[4]; /* The real interface that the monitor is on */ @@ -91,9 +87,6 @@ struct wilc_priv { u8 wilc_groupkey; /* mutexes */ struct mutex scan_req_lock; - /* */ - bool auto_rate_adjusted; - bool p2p_listen_state; }; From cf15e3dc8fbec6d91a77ed858a538ba924c819de Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:07 +0530 Subject: [PATCH 477/903] staging: wilc1000: removed unused element from wilc_cfg_frame struct Cleanup up patch to remove the unused structure elements in 'wilc_cfg_frame' struct. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index dbdebf009024..f29d1ea73551 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -255,9 +255,6 @@ struct wilc_hif_func { #define MAX_CFG_FRAME_SIZE 1468 struct wilc_cfg_frame { - u8 ether_header[14]; - u8 ip_header[20]; - u8 udp_header[8]; u8 wid_header[8]; u8 frame[MAX_CFG_FRAME_SIZE]; }; From e3da5d9d255f3d6919be5db8c0e7c80743e65be7 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:08 +0530 Subject: [PATCH 478/903] staging: wilc1000: remove the mutliple #define used for same macro Moved the same #define in common header file instead of having their declartion in different files. Below macros are moved to header file: TCP_ACK_FILTER_LINK_SPEED_THRESH DEFAULT_LINK_SPEED GET_PKT_OFFSET Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 3 --- drivers/staging/wilc1000/linux_mon.c | 1 - drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 5 ----- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 5 +++++ 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0ffe205dad75..86492252ae89 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -6,9 +6,6 @@ #define FALSE_FRMWR_CHANNEL 100 -#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 -#define DEFAULT_LINK_SPEED 72 - #define REAL_JOIN_REQ 0 struct host_if_wpa_attr { diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index 1c7e6e15809c..bd09611424e0 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -20,7 +20,6 @@ static u8 bssid[6]; #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive*/ -#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) #define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) | \ (1 << IEEE80211_RADIOTAP_TX_FLAGS)) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 1a27e81637ea..e561dce1ef4b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -77,11 +77,6 @@ static const struct wiphy_wowlan_support wowlan_support = { .flags = WIPHY_WOWLAN_ANY }; -#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 -#define DEFAULT_LINK_SPEED 72 - -#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) - static struct network_info last_scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; static u32 last_scanned_cnt; struct timer_list wilc_during_ip_timer; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 87f8cdc2acec..765681a78105 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -21,6 +21,11 @@ #define NUM_REG_FRAME 2 +#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 +#define DEFAULT_LINK_SPEED 72 + +#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) + struct wilc_wfi_stats { unsigned long rx_packets; unsigned long tx_packets; From 742a48699ea65c196865560a7240d5fda3e1fc63 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:09 +0530 Subject: [PATCH 479/903] staging: wilc1000: use lowercase for 'IFC_UP' struct element name Cleanup patch to use lowercase for structure element name to follow linux coding style. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.h | 2 +- drivers/staging/wilc1000/linux_wlan.c | 4 ++-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 79166a5fb96d..9a016c56a62f 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -277,7 +277,7 @@ struct host_if_drv { struct timer_list remain_on_ch_timer; struct wilc_vif *remain_on_ch_timer_vif; - bool IFC_UP; + bool ifc_up; int driver_handler_id; }; diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 032afc25ebe2..84d314547908 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -45,7 +45,7 @@ static int dev_state_ev_handler(struct notifier_block *this, switch (event) { case NETDEV_UP: if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { - hif_drv->IFC_UP = 1; + hif_drv->ifc_up = 1; wilc_optaining_ip = false; del_timer(&wilc_during_ip_timer); } @@ -65,7 +65,7 @@ static int dev_state_ev_handler(struct notifier_block *this, case NETDEV_DOWN: if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { - hif_drv->IFC_UP = 0; + hif_drv->ifc_up = 0; wilc_optaining_ip = false; } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index e561dce1ef4b..ebe7adc275c2 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -535,9 +535,9 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, if (!wfi_drv->p2p_connect) wlan_channel = INVALID_CHANNEL; - if (wfi_drv->IFC_UP && dev == wl->vif[1]->ndev) + if (wfi_drv->ifc_up && dev == wl->vif[1]->ndev) disconn_info->reason = 3; - else if (!wfi_drv->IFC_UP && dev == wl->vif[1]->ndev) + else if (!wfi_drv->ifc_up && dev == wl->vif[1]->ndev) disconn_info->reason = 1; cfg80211_disconnected(dev, disconn_info->reason, From 9542c441a71454d00a876d8f870af33671424ab9 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:10 +0530 Subject: [PATCH 480/903] staging: wilc1000: remove unnecessary blank line between variable declaration Cleanup patch to remove the unnecessary blank line between variables declaration inside the function. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_mon.c | 1 - drivers/staging/wilc1000/linux_wlan.c | 1 - drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ---- 3 files changed, 6 deletions(-) diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index bd09611424e0..14405bf1d8fa 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -147,7 +147,6 @@ static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb, { u32 rtap_len, ret = 0; struct wilc_wfi_mon_priv *mon_priv; - struct sk_buff *skb2; struct wilc_wfi_radiotap_cb_hdr *cb_hdr; diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 84d314547908..8f7743576ead 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -780,7 +780,6 @@ static int mac_init_fn(struct net_device *ndev) static int wilc_mac_open(struct net_device *ndev) { struct wilc_vif *vif; - unsigned char mac_add[ETH_ALEN] = {0}; int ret = 0; int i = 0; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index ebe7adc275c2..43003d89a1e1 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1250,7 +1250,6 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, { u32 i; s32 ret = 0; - struct wilc_priv *priv = wiphy_priv(wiphy); for (i = 0; i < priv->pmkid_list.numpmkid; i++) { @@ -1315,7 +1314,6 @@ static inline void wilc_wfi_cfg_parse_ch_attr(u8 *buf, u8 ch_list_attr_idx, static void wilc_wfi_cfg_parse_rx_action(u8 *buf, u32 len) { u32 index = 0; - u8 op_channel_attr_index = 0; u8 channel_list_attr_index = 0; @@ -1338,7 +1336,6 @@ static void wilc_wfi_cfg_parse_tx_action(u8 *buf, u32 len, bool oper_ch, u8 iftype) { u32 index = 0; - u8 op_channel_attr_index = 0; u8 channel_list_attr_index = 0; @@ -2261,7 +2258,6 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, int wilc_init_host_int(struct net_device *net) { int ret = 0; - struct wilc_priv *priv; priv = wdev_priv(net->ieee80211_ptr); From 74cffafb668404daffb0ee46b711f0712a6823fa Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:11 +0530 Subject: [PATCH 481/903] staging: wilc1000: use single space before opening brances '{' Cleanup patch to use single space instead of multiple space before the '{'. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 6 +++--- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- drivers/staging/wilc1000/wilc_wlan.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 86492252ae89..2f25175af63d 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -799,7 +799,7 @@ static void handle_scan(struct work_struct *work) scan_info->ch_list_len > 0) { int i; - for (i = 0; i < scan_info->ch_list_len; i++) { + for (i = 0; i < scan_info->ch_list_len; i++) { if (scan_info->ch_freq_list[i] > 0) scan_info->ch_freq_list[i] -= 1; } @@ -3337,7 +3337,7 @@ int wilc_deinit(struct wilc_vif *vif) int result = 0; struct host_if_drv *hif_drv = vif->hif_drv; - if (!hif_drv) { + if (!hif_drv) { netdev_err(vif->ndev, "hif_drv = NULL\n"); return -EFAULT; } @@ -3404,7 +3404,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; hif_drv = vif->hif_drv; - if (!hif_drv || hif_drv == terminated_handle) { + if (!hif_drv || hif_drv == terminated_handle) { netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv); return; } diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 8f7743576ead..5667a543029c 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -604,7 +604,7 @@ static void wilc_wlan_deinitialize(struct net_device *dev) return; } - if (wl->initialized) { + if (wl->initialized) { netdev_info(dev, "Deinitializing wilc1000...\n"); if (!wl->dev_irq_num && diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 43003d89a1e1..96aaf14faa92 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -524,7 +524,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, conn_info->resp_ies, conn_info->resp_ies_len, connect_status, GFP_KERNEL); - } else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) { + } else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) { wilc_optaining_ip = false; p2p_local_random = 0x01; p2p_recv_random = 0x00; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index c77e5c827c4d..cb8bfd2e42bd 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -436,7 +436,7 @@ void chip_wakeup(struct wilc *wilc) wilc_get_chipid(wilc, true); } while (wilc_get_chipid(wilc, true) == 0); } while (wilc_get_chipid(wilc, true) == 0); - } else if ((wilc->io_type & 0x1) == HIF_SDIO) { + } else if ((wilc->io_type & 0x1) == HIF_SDIO) { wilc->hif_func->hif_write_reg(wilc, 0xfa, 1); udelay(200); wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); From 674650fd643ed551e78af047381b6e30508b0f12 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:12 +0530 Subject: [PATCH 482/903] staging: wilc1000: remove unnecessary type used for wid id Cleanup patch to remove unnecessary typecast used while assigning the WID ID. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 84 +++++++++++------------ 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2f25175af63d..85ecba8974cb 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -264,7 +264,7 @@ static void handle_set_channel(struct work_struct *work) int ret = 0; struct wid wid; - wid.id = (u16)WID_CURRENT_CHANNEL; + wid.id = WID_CURRENT_CHANNEL; wid.type = WID_CHAR; wid.val = (char *)&hif_set_ch->set_ch; wid.size = sizeof(char); @@ -307,7 +307,7 @@ static void handle_set_wfi_drv_handler(struct work_struct *work) currbyte++; *currbyte = (hif_drv_handler->name | (hif_drv_handler->mode << 1)); - wid.id = (u16)WID_SET_DRV_HANDLER; + wid.id = WID_SET_DRV_HANDLER; wid.type = WID_STR; wid.val = (s8 *)buffer; wid.size = DRV_HANDLER_SIZE; @@ -332,7 +332,7 @@ static void handle_set_operation_mode(struct work_struct *work) int ret = 0; struct wid wid; - wid.id = (u16)WID_SET_OPERATION_MODE; + wid.id = WID_SET_OPERATION_MODE; wid.type = WID_INT; wid.val = (s8 *)&hif_op_mode->mode; wid.size = sizeof(u32); @@ -363,7 +363,7 @@ static void handle_set_ip_address(struct work_struct *work) memcpy(set_ip[idx], ip_addr, IP_ALEN); - wid.id = (u16)WID_IP_ADDRESS; + wid.id = WID_IP_ADDRESS; wid.type = WID_STR; wid.val = ip_addr; wid.size = IP_ALEN; @@ -386,7 +386,7 @@ static void handle_get_ip_address(struct work_struct *work) int ret = 0; struct wid wid; - wid.id = (u16)WID_IP_ADDRESS; + wid.id = WID_IP_ADDRESS; wid.type = WID_STR; wid.val = kmalloc(IP_ALEN, GFP_KERNEL); wid.size = IP_ALEN; @@ -414,7 +414,7 @@ static void handle_get_mac_address(struct work_struct *work) int ret = 0; struct wid wid; - wid.id = (u16)WID_MAC_ADDR; + wid.id = WID_MAC_ADDR; wid.type = WID_STR; wid.val = get_mac_addr->mac_addr; wid.size = ETH_ALEN; @@ -757,7 +757,7 @@ static void handle_scan(struct work_struct *work) hif_drv->usr_scan_req.rcvd_ch_cnt = 0; - wid_list[index].id = (u16)WID_SSID_PROBE_REQ; + wid_list[index].id = WID_SSID_PROBE_REQ; wid_list[index].type = WID_STR; for (i = 0; i < hidden_net->n_ssids; i++) @@ -851,7 +851,7 @@ static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) if (evt == SCAN_EVENT_ABORTED) { abort_running_scan = 1; - wid.id = (u16)WID_ABORT_RUNNING_SCAN; + wid.id = WID_ABORT_RUNNING_SCAN; wid.type = WID_CHAR; wid.val = (s8 *)&abort_running_scan; wid.size = sizeof(char); @@ -976,19 +976,19 @@ static void handle_connect(struct work_struct *work) wid_list[wid_cnt].size = hif_drv->usr_conn_req.ies_len; wid_cnt++; - wid_list[wid_cnt].id = (u16)WID_11I_MODE; + wid_list[wid_cnt].id = WID_11I_MODE; wid_list[wid_cnt].type = WID_CHAR; wid_list[wid_cnt].size = sizeof(char); wid_list[wid_cnt].val = (s8 *)&hif_drv->usr_conn_req.security; wid_cnt++; - wid_list[wid_cnt].id = (u16)WID_AUTH_TYPE; + wid_list[wid_cnt].id = WID_AUTH_TYPE; wid_list[wid_cnt].type = WID_CHAR; wid_list[wid_cnt].size = sizeof(char); wid_list[wid_cnt].val = (s8 *)&hif_drv->usr_conn_req.auth_type; wid_cnt++; - wid_list[wid_cnt].id = (u16)WID_JOIN_REQ_EXTENDED; + wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED; wid_list[wid_cnt].type = WID_STR; wid_list[wid_cnt].size = 112; wid_list[wid_cnt].val = kmalloc(wid_list[wid_cnt].size, GFP_KERNEL); @@ -1192,7 +1192,7 @@ static void handle_connect_timeout(struct work_struct *work) netdev_err(vif->ndev, "Connect callback is NULL\n"); } - wid.id = (u16)WID_DISCONNECT; + wid.id = WID_DISCONNECT; wid.type = WID_CHAR; wid.val = (s8 *)&dummy_reason_code; wid.size = sizeof(char); @@ -1496,7 +1496,7 @@ static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) hif_key->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN); } - wid.id = (u16)WID_PMKID_INFO; + wid.id = WID_PMKID_INFO; wid.type = WID_STR; wid.val = (s8 *)key_buf; wid.size = (hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1; @@ -1524,7 +1524,7 @@ static void handle_key(struct work_struct *work) case WEP: if (hif_key->action & ADDKEY_AP) { - wid_list[0].id = (u16)WID_11I_MODE; + wid_list[0].id = WID_11I_MODE; wid_list[0].type = WID_CHAR; wid_list[0].size = sizeof(char); wid_list[0].val = (s8 *)&hif_key->attr.wep.mode; @@ -1547,7 +1547,7 @@ static void handle_key(struct work_struct *work) memcpy(&key_buf[2], hif_key->attr.wep.key, hif_key->attr.wep.key_len); - wid_list[2].id = (u16)WID_WEP_KEY_VALUE; + wid_list[2].id = WID_WEP_KEY_VALUE; wid_list[2].type = WID_STR; wid_list[2].size = hif_key->attr.wep.key_len + 2; wid_list[2].val = (s8 *)key_buf; @@ -1568,7 +1568,7 @@ static void handle_key(struct work_struct *work) memcpy(key_buf + 2, hif_key->attr.wep.key, hif_key->attr.wep.key_len); - wid.id = (u16)WID_ADD_WEP_KEY; + wid.id = WID_ADD_WEP_KEY; wid.type = WID_STR; wid.val = (s8 *)key_buf; wid.size = hif_key->attr.wep.key_len + 2; @@ -1578,7 +1578,7 @@ static void handle_key(struct work_struct *work) wilc_get_vif_idx(vif)); kfree(key_buf); } else if (hif_key->action & REMOVEKEY) { - wid.id = (u16)WID_REMOVE_WEP_KEY; + wid.id = WID_REMOVE_WEP_KEY; wid.type = WID_STR; wid.val = (s8 *)&hif_key->attr.wep.index; @@ -1588,7 +1588,7 @@ static void handle_key(struct work_struct *work) &wid, 1, wilc_get_vif_idx(vif)); } else if (hif_key->action & DEFAULTKEY) { - wid.id = (u16)WID_KEY_ID; + wid.id = WID_KEY_ID; wid.type = WID_CHAR; wid.val = (s8 *)&hif_key->attr.wep.index; wid.size = sizeof(char); @@ -1617,12 +1617,12 @@ out_wep: memcpy(key_buf + 16, hif_key->attr.wpa.key, hif_key->attr.wpa.key_len); - wid_list[0].id = (u16)WID_11I_MODE; + wid_list[0].id = WID_11I_MODE; wid_list[0].type = WID_CHAR; wid_list[0].size = sizeof(char); wid_list[0].val = (s8 *)&hif_key->attr.wpa.mode; - wid_list[1].id = (u16)WID_ADD_RX_GTK; + wid_list[1].id = WID_ADD_RX_GTK; wid_list[1].type = WID_STR; wid_list[1].val = (s8 *)key_buf; wid_list[1].size = RX_MIC_KEY_MSG_LEN; @@ -1650,7 +1650,7 @@ out_wep: memcpy(key_buf + 16, hif_key->attr.wpa.key, hif_key->attr.wpa.key_len); - wid.id = (u16)WID_ADD_RX_GTK; + wid.id = WID_ADD_RX_GTK; wid.type = WID_STR; wid.val = (s8 *)key_buf; wid.size = RX_MIC_KEY_MSG_LEN; @@ -1679,12 +1679,12 @@ out_wpa_rx_gtk: memcpy(key_buf + 8, hif_key->attr.wpa.key, hif_key->attr.wpa.key_len); - wid_list[0].id = (u16)WID_11I_MODE; + wid_list[0].id = WID_11I_MODE; wid_list[0].type = WID_CHAR; wid_list[0].size = sizeof(char); wid_list[0].val = (s8 *)&hif_key->attr.wpa.mode; - wid_list[1].id = (u16)WID_ADD_PTK; + wid_list[1].id = WID_ADD_PTK; wid_list[1].type = WID_STR; wid_list[1].val = (s8 *)key_buf; wid_list[1].size = PTK_KEY_MSG_LEN + 1; @@ -1705,7 +1705,7 @@ out_wpa_rx_gtk: memcpy(key_buf + 7, hif_key->attr.wpa.key, hif_key->attr.wpa.key_len); - wid.id = (u16)WID_ADD_PTK; + wid.id = WID_ADD_PTK; wid.type = WID_STR; wid.val = (s8 *)key_buf; wid.size = PTK_KEY_MSG_LEN; @@ -1745,7 +1745,7 @@ static void handle_disconnect(struct work_struct *work) s32 result = 0; u16 dummy_reason_code = 0; - wid.id = (u16)WID_DISCONNECT; + wid.id = WID_DISCONNECT; wid.type = WID_CHAR; wid.val = (s8 *)&dummy_reason_code; wid.size = sizeof(char); @@ -1823,7 +1823,7 @@ static void handle_get_rssi(struct work_struct *work) s32 result = 0; struct wid wid; - wid.id = (u16)WID_RSSI; + wid.id = WID_RSSI; wid.type = WID_CHAR; wid.val = msg->body.data; wid.size = sizeof(char); @@ -1903,7 +1903,7 @@ static void handle_get_inactive_time(struct work_struct *work) s32 result = 0; struct wid wid; - wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME; + wid.id = WID_SET_STA_MAC_INACTIVE_TIME; wid.type = WID_STR; wid.size = ETH_ALEN; wid.val = kmalloc(wid.size, GFP_KERNEL); @@ -1921,7 +1921,7 @@ static void handle_get_inactive_time(struct work_struct *work) goto out; } - wid.id = (u16)WID_GET_INACTIVE_TIME; + wid.id = WID_GET_INACTIVE_TIME; wid.type = WID_INT; wid.val = (s8 *)&hif_sta_inactive->inactive_time; wid.size = sizeof(u32); @@ -1946,7 +1946,7 @@ static void handle_add_beacon(struct work_struct *work) struct wid wid; u8 *cur_byte; - wid.id = (u16)WID_ADD_BEACON; + wid.id = WID_ADD_BEACON; wid.type = WID_BIN; wid.size = param->head_len + param->tail_len + 16; wid.val = kmalloc(wid.size, GFP_KERNEL); @@ -2001,7 +2001,7 @@ static void handle_del_beacon(struct work_struct *work) struct wid wid; u8 del_beacon = 0; - wid.id = (u16)WID_DEL_BEACON; + wid.id = WID_DEL_BEACON; wid.type = WID_CHAR; wid.size = sizeof(char); wid.val = &del_beacon; @@ -2052,7 +2052,7 @@ static void handle_add_station(struct work_struct *work) struct wid wid; u8 *cur_byte; - wid.id = (u16)WID_ADD_STA; + wid.id = WID_ADD_STA; wid.type = WID_BIN; wid.size = WILC_ADD_STA_LENGTH + param->rates_len; @@ -2085,7 +2085,7 @@ static void handle_del_all_sta(struct work_struct *work) u8 i; u8 zero_buff[6] = {0}; - wid.id = (u16)WID_DEL_ALL_STA; + wid.id = WID_DEL_ALL_STA; wid.type = WID_STR; wid.size = (param->assoc_sta * ETH_ALEN) + 1; @@ -2126,7 +2126,7 @@ static void handle_del_station(struct work_struct *work) s32 result = 0; struct wid wid; - wid.id = (u16)WID_REMOVE_STA; + wid.id = WID_REMOVE_STA; wid.type = WID_BIN; wid.size = ETH_ALEN; @@ -2155,7 +2155,7 @@ static void handle_edit_station(struct work_struct *work) struct wid wid; u8 *cur_byte; - wid.id = (u16)WID_EDIT_STA; + wid.id = WID_EDIT_STA; wid.type = WID_BIN; wid.size = WILC_ADD_STA_LENGTH + param->rates_len; @@ -2211,7 +2211,7 @@ static int handle_remain_on_chan(struct wilc_vif *vif, } remain_on_chan_flag = true; - wid.id = (u16)WID_REMAIN_ON_CHAN; + wid.id = WID_REMAIN_ON_CHAN; wid.type = WID_STR; wid.size = 2; wid.val = kmalloc(wid.size, GFP_KERNEL); @@ -2253,7 +2253,7 @@ static void handle_register_frame(struct work_struct *work) struct wid wid; u8 *cur_byte; - wid.id = (u16)WID_REGISTER_FRAME; + wid.id = WID_REGISTER_FRAME; wid.type = WID_STR; wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL); if (!wid.val) @@ -2289,7 +2289,7 @@ static void handle_listen_state_expired(struct work_struct *work) if (p2p_listen_state) { remain_on_chan_flag = false; - wid.id = (u16)WID_REMAIN_ON_CHAN; + wid.id = WID_REMAIN_ON_CHAN; wid.type = WID_STR; wid.size = 2; wid.val = kmalloc(wid.size, GFP_KERNEL); @@ -2353,7 +2353,7 @@ static void handle_power_management(struct work_struct *work) struct wid wid; s8 power_mode; - wid.id = (u16)WID_POWER_MANAGEMENT; + wid.id = WID_POWER_MANAGEMENT; if (pm_param->enabled) power_mode = MIN_FAST_PS; @@ -2379,7 +2379,7 @@ static void handle_set_mcast_filter(struct work_struct *work) struct wid wid; u8 *cur_byte; - wid.id = (u16)WID_SETUP_MULTICAST_FILTER; + wid.id = WID_SETUP_MULTICAST_FILTER; wid.type = WID_BIN; wid.size = sizeof(struct set_multicast) + (hif_set_mc->cnt * ETH_ALEN); wid.val = kmalloc(wid.size, GFP_KERNEL); @@ -2419,7 +2419,7 @@ static void handle_set_tx_pwr(struct work_struct *work) int ret; struct wid wid; - wid.id = (u16)WID_TX_POWER; + wid.id = WID_TX_POWER; wid.type = WID_CHAR; wid.val = &tx_pwr; wid.size = sizeof(char); @@ -2440,7 +2440,7 @@ static void handle_get_tx_pwr(struct work_struct *work) int ret = 0; struct wid wid; - wid.id = (u16)WID_TX_POWER; + wid.id = WID_TX_POWER; wid.type = WID_CHAR; wid.val = (s8 *)tx_pwr; wid.size = sizeof(char); @@ -2988,7 +2988,7 @@ static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, s32 result = 0; struct wid wid; - wid.id = (u16)WID_ASSOC_RES_INFO; + wid.id = WID_ASSOC_RES_INFO; wid.type = WID_STR; wid.val = assoc_resp_info; wid.size = max_assoc_resp_info_len; From 2653aade480741c38e0aacbf1fc21e5662d63ae6 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:13 +0530 Subject: [PATCH 483/903] staging: wilc1000: avoid forward declaration for handle_scan_done() Reorder the function position in host interface to avoid forward declaration of handle_scan_done(). Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 77 +++++++++++------------ 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 85ecba8974cb..eabe5c75788d 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -199,7 +199,6 @@ static u32 clients_count; static void *host_int_parse_join_bss_param(struct network_info *info); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); -static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt); /* 'msg' should be free by the caller for syc */ static struct host_if_msg* @@ -724,6 +723,44 @@ unlock: kfree(msg); } +static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) +{ + s32 result = 0; + u8 abort_running_scan; + struct wid wid; + struct host_if_drv *hif_drv = vif->hif_drv; + struct user_scan_req *scan_req; + + if (evt == SCAN_EVENT_ABORTED) { + abort_running_scan = 1; + wid.id = WID_ABORT_RUNNING_SCAN; + wid.type = WID_CHAR; + wid.val = (s8 *)&abort_running_scan; + wid.size = sizeof(char); + + result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + + if (result) { + netdev_err(vif->ndev, "Failed to set abort running\n"); + result = -EFAULT; + } + } + + if (!hif_drv) { + netdev_err(vif->ndev, "Driver handler is NULL\n"); + return result; + } + + scan_req = &hif_drv->usr_scan_req; + if (scan_req->scan_result) { + scan_req->scan_result(evt, NULL, scan_req->arg, NULL); + scan_req->scan_result = NULL; + } + + return result; +} + static void handle_scan(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -841,44 +878,6 @@ error: kfree(msg); } -static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) -{ - s32 result = 0; - u8 abort_running_scan; - struct wid wid; - struct host_if_drv *hif_drv = vif->hif_drv; - struct user_scan_req *scan_req; - - if (evt == SCAN_EVENT_ABORTED) { - abort_running_scan = 1; - wid.id = WID_ABORT_RUNNING_SCAN; - wid.type = WID_CHAR; - wid.val = (s8 *)&abort_running_scan; - wid.size = sizeof(char); - - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - - if (result) { - netdev_err(vif->ndev, "Failed to set abort running\n"); - result = -EFAULT; - } - } - - if (!hif_drv) { - netdev_err(vif->ndev, "Driver handler is NULL\n"); - return result; - } - - scan_req = &hif_drv->usr_scan_req; - if (scan_req->scan_result) { - scan_req->scan_result(evt, NULL, scan_req->arg, NULL); - scan_req->scan_result = NULL; - } - - return result; -} - u8 wilc_connected_ssid[6] = {0}; static void handle_connect(struct work_struct *work) { From 8bdc6bbc0996886afd5b400b42fa654b518da58f Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:14 +0530 Subject: [PATCH 484/903] staging: wilc1000: avoid host_int_get_assoc_res_info() forward declaration Reorder the function position in host interface to avoid forward declaration of host_int_get_assoc_res_info(). Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 47 ++++++++++------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index eabe5c75788d..f49e8498ed6d 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1287,7 +1287,27 @@ done: static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, u8 *assoc_resp_info, u32 max_assoc_resp_info_len, - u32 *rcvd_assoc_resp_info_len); + u32 *rcvd_assoc_resp_info_len) +{ + s32 result; + struct wid wid; + + wid.id = WID_ASSOC_RES_INFO; + wid.type = WID_STR; + wid.val = assoc_resp_info; + wid.size = max_assoc_resp_info_len; + + result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) { + *rcvd_assoc_resp_info_len = 0; + netdev_err(vif->ndev, "Failed to send association response\n"); + return -EINVAL; + } + + *rcvd_assoc_resp_info_len = wid.size; + return result; +} static inline void host_int_free_user_conn_req(struct host_if_drv *hif_drv) { @@ -2979,31 +2999,6 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) return result; } -static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, - u8 *assoc_resp_info, - u32 max_assoc_resp_info_len, - u32 *rcvd_assoc_resp_info_len) -{ - s32 result = 0; - struct wid wid; - - wid.id = WID_ASSOC_RES_INFO; - wid.type = WID_STR; - wid.val = assoc_resp_info; - wid.size = max_assoc_resp_info_len; - - result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) { - *rcvd_assoc_resp_info_len = 0; - netdev_err(vif->ndev, "Failed to send association response\n"); - return -EINVAL; - } - - *rcvd_assoc_resp_info_len = wid.size; - return result; -} - int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) { int result; From 448d078449b70f73a6caabd804099e51801483d9 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:15 +0530 Subject: [PATCH 485/903] staging: wilc1000: avoid forward declaration of host_int_parse_join_bss_param() Reorder the functions position in host interface to avoid forward declaration of host_int_parse_join_bss_param(). Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 333 +++++++++++----------- 1 file changed, 166 insertions(+), 167 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index f49e8498ed6d..895a12691499 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -197,7 +197,6 @@ static u8 set_ip[2][4]; static u8 get_ip[2][4]; static u32 clients_count; -static void *host_int_parse_join_bss_param(struct network_info *info); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); /* 'msg' should be free by the caller for syc */ @@ -1216,6 +1215,172 @@ out: kfree(msg); } +static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, + u16 *out_index, u8 *pcipher_tc, + u8 *auth_total_cnt, u32 tsf_lo, + u8 *rates_no) +{ + u8 ext_rates_no; + u16 offset; + u8 pcipher_cnt; + u8 auth_cnt; + u8 i, j; + u16 index = *out_index; + + if (ies[index] == WLAN_EID_SUPP_RATES) { + *rates_no = ies[index + 1]; + param->supp_rates[0] = *rates_no; + index += 2; + + for (i = 0; i < *rates_no; i++) + param->supp_rates[i + 1] = ies[index + i]; + + index += *rates_no; + } else if (ies[index] == WLAN_EID_EXT_SUPP_RATES) { + ext_rates_no = ies[index + 1]; + if (ext_rates_no > (MAX_RATES_SUPPORTED - *rates_no)) + param->supp_rates[0] = MAX_RATES_SUPPORTED; + else + param->supp_rates[0] += ext_rates_no; + index += 2; + for (i = 0; i < (param->supp_rates[0] - *rates_no); i++) + param->supp_rates[*rates_no + i + 1] = ies[index + i]; + + index += ext_rates_no; + } else if (ies[index] == WLAN_EID_HT_CAPABILITY) { + param->ht_capable = true; + index += ies[index + 1] + 2; + } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && + (ies[index + 2] == 0x00) && (ies[index + 3] == 0x50) && + (ies[index + 4] == 0xF2) && (ies[index + 5] == 0x02) && + ((ies[index + 6] == 0x00) || (ies[index + 6] == 0x01)) && + (ies[index + 7] == 0x01)) { + param->wmm_cap = true; + + if (ies[index + 8] & BIT(7)) + param->uapsd_cap = true; + index += ies[index + 1] + 2; + } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && + (ies[index + 2] == 0x50) && (ies[index + 3] == 0x6f) && + (ies[index + 4] == 0x9a) && + (ies[index + 5] == 0x09) && (ies[index + 6] == 0x0c)) { + u16 p2p_cnt; + + param->tsf = tsf_lo; + param->noa_enabled = 1; + param->idx = ies[index + 9]; + + if (ies[index + 10] & BIT(7)) { + param->opp_enabled = 1; + param->ct_window = ies[index + 10]; + } else { + param->opp_enabled = 0; + } + + param->cnt = ies[index + 11]; + p2p_cnt = index + 12; + + memcpy(param->duration, ies + p2p_cnt, 4); + p2p_cnt += 4; + + memcpy(param->interval, ies + p2p_cnt, 4); + p2p_cnt += 4; + + memcpy(param->start_time, ies + p2p_cnt, 4); + + index += ies[index + 1] + 2; + } else if ((ies[index] == WLAN_EID_RSN) || + ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && + (ies[index + 2] == 0x00) && + (ies[index + 3] == 0x50) && (ies[index + 4] == 0xF2) && + (ies[index + 5] == 0x01))) { + u16 rsn_idx = index; + + if (ies[rsn_idx] == WLAN_EID_RSN) { + param->mode_802_11i = 2; + } else { + if (param->mode_802_11i == 0) + param->mode_802_11i = 1; + rsn_idx += 4; + } + + rsn_idx += 7; + param->rsn_grp_policy = ies[rsn_idx]; + rsn_idx++; + offset = ies[rsn_idx] * 4; + pcipher_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx]; + rsn_idx += 2; + + i = *pcipher_tc; + j = 0; + for (; i < (pcipher_cnt + *pcipher_tc) && i < 3; i++, j++) { + u8 *policy = ¶m->rsn_pcip_policy[i]; + + *policy = ies[rsn_idx + ((j + 1) * 4) - 1]; + } + + *pcipher_tc += pcipher_cnt; + rsn_idx += offset; + + offset = ies[rsn_idx] * 4; + + auth_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx]; + rsn_idx += 2; + i = *auth_total_cnt; + j = 0; + for (; i < (*auth_total_cnt + auth_cnt); i++, j++) { + u8 *policy = ¶m->rsn_auth_policy[i]; + + *policy = ies[rsn_idx + ((j + 1) * 4) - 1]; + } + + *auth_total_cnt += auth_cnt; + rsn_idx += offset; + + if (ies[index] == WLAN_EID_RSN) { + param->rsn_cap[0] = ies[rsn_idx]; + param->rsn_cap[1] = ies[rsn_idx + 1]; + rsn_idx += 2; + } + param->rsn_found = true; + index += ies[index + 1] + 2; + } else { + index += ies[index + 1] + 2; + } + + *out_index = index; +} + +static void *host_int_parse_join_bss_param(struct network_info *info) +{ + struct join_bss_param *param; + u16 index = 0; + u8 rates_no = 0; + u8 pcipher_total_cnt = 0; + u8 auth_total_cnt = 0; + + param = kzalloc(sizeof(*param), GFP_KERNEL); + if (!param) + return NULL; + + param->dtim_period = info->dtim_period; + param->beacon_period = info->beacon_period; + param->cap_info = info->cap_info; + memcpy(param->bssid, info->bssid, 6); + memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1); + param->ssid_len = info->ssid_len; + memset(param->rsn_pcip_policy, 0xFF, 3); + memset(param->rsn_auth_policy, 0xFF, 3); + + while (index < info->ies_len) + host_int_fill_join_bss_param(param, info->ies, &index, + &pcipher_total_cnt, + &auth_total_cnt, info->tsf_lo, + &rates_no); + + return (void *)param; +} + static void handle_rcvd_ntwrk_info(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -3840,172 +4005,6 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, return result; } -static void host_int_fill_join_bss_param(struct join_bss_param *param, u8 *ies, - u16 *out_index, u8 *pcipher_tc, - u8 *auth_total_cnt, u32 tsf_lo, - u8 *rates_no) -{ - u8 ext_rates_no; - u16 offset; - u8 pcipher_cnt; - u8 auth_cnt; - u8 i, j; - u16 index = *out_index; - - if (ies[index] == WLAN_EID_SUPP_RATES) { - *rates_no = ies[index + 1]; - param->supp_rates[0] = *rates_no; - index += 2; - - for (i = 0; i < *rates_no; i++) - param->supp_rates[i + 1] = ies[index + i]; - - index += *rates_no; - } else if (ies[index] == WLAN_EID_EXT_SUPP_RATES) { - ext_rates_no = ies[index + 1]; - if (ext_rates_no > (MAX_RATES_SUPPORTED - *rates_no)) - param->supp_rates[0] = MAX_RATES_SUPPORTED; - else - param->supp_rates[0] += ext_rates_no; - index += 2; - for (i = 0; i < (param->supp_rates[0] - *rates_no); i++) - param->supp_rates[*rates_no + i + 1] = ies[index + i]; - - index += ext_rates_no; - } else if (ies[index] == WLAN_EID_HT_CAPABILITY) { - param->ht_capable = true; - index += ies[index + 1] + 2; - } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && - (ies[index + 2] == 0x00) && (ies[index + 3] == 0x50) && - (ies[index + 4] == 0xF2) && (ies[index + 5] == 0x02) && - ((ies[index + 6] == 0x00) || (ies[index + 6] == 0x01)) && - (ies[index + 7] == 0x01)) { - param->wmm_cap = true; - - if (ies[index + 8] & BIT(7)) - param->uapsd_cap = true; - index += ies[index + 1] + 2; - } else if ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && - (ies[index + 2] == 0x50) && (ies[index + 3] == 0x6f) && - (ies[index + 4] == 0x9a) && - (ies[index + 5] == 0x09) && (ies[index + 6] == 0x0c)) { - u16 p2p_cnt; - - param->tsf = tsf_lo; - param->noa_enabled = 1; - param->idx = ies[index + 9]; - - if (ies[index + 10] & BIT(7)) { - param->opp_enabled = 1; - param->ct_window = ies[index + 10]; - } else { - param->opp_enabled = 0; - } - - param->cnt = ies[index + 11]; - p2p_cnt = index + 12; - - memcpy(param->duration, ies + p2p_cnt, 4); - p2p_cnt += 4; - - memcpy(param->interval, ies + p2p_cnt, 4); - p2p_cnt += 4; - - memcpy(param->start_time, ies + p2p_cnt, 4); - - index += ies[index + 1] + 2; - } else if ((ies[index] == WLAN_EID_RSN) || - ((ies[index] == WLAN_EID_VENDOR_SPECIFIC) && - (ies[index + 2] == 0x00) && - (ies[index + 3] == 0x50) && (ies[index + 4] == 0xF2) && - (ies[index + 5] == 0x01))) { - u16 rsn_idx = index; - - if (ies[rsn_idx] == WLAN_EID_RSN) { - param->mode_802_11i = 2; - } else { - if (param->mode_802_11i == 0) - param->mode_802_11i = 1; - rsn_idx += 4; - } - - rsn_idx += 7; - param->rsn_grp_policy = ies[rsn_idx]; - rsn_idx++; - offset = ies[rsn_idx] * 4; - pcipher_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx]; - rsn_idx += 2; - - i = *pcipher_tc; - j = 0; - for (; i < (pcipher_cnt + *pcipher_tc) && i < 3; i++, j++) { - u8 *policy = ¶m->rsn_pcip_policy[i]; - - *policy = ies[rsn_idx + ((j + 1) * 4) - 1]; - } - - *pcipher_tc += pcipher_cnt; - rsn_idx += offset; - - offset = ies[rsn_idx] * 4; - - auth_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx]; - rsn_idx += 2; - i = *auth_total_cnt; - j = 0; - for (; i < (*auth_total_cnt + auth_cnt); i++, j++) { - u8 *policy = ¶m->rsn_auth_policy[i]; - - *policy = ies[rsn_idx + ((j + 1) * 4) - 1]; - } - - *auth_total_cnt += auth_cnt; - rsn_idx += offset; - - if (ies[index] == WLAN_EID_RSN) { - param->rsn_cap[0] = ies[rsn_idx]; - param->rsn_cap[1] = ies[rsn_idx + 1]; - rsn_idx += 2; - } - param->rsn_found = true; - index += ies[index + 1] + 2; - } else { - index += ies[index + 1] + 2; - } - - *out_index = index; -} - -static void *host_int_parse_join_bss_param(struct network_info *info) -{ - struct join_bss_param *param = NULL; - u16 index = 0; - u8 rates_no = 0; - u8 pcipher_total_cnt = 0; - u8 auth_total_cnt = 0; - - param = kzalloc(sizeof(*param), GFP_KERNEL); - if (!param) - return NULL; - - param->dtim_period = info->dtim_period; - param->beacon_period = info->beacon_period; - param->cap_info = info->cap_info; - memcpy(param->bssid, info->bssid, 6); - memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1); - param->ssid_len = info->ssid_len; - memset(param->rsn_pcip_policy, 0xFF, 3); - memset(param->rsn_auth_policy, 0xFF, 3); - - while (index < info->ies_len) - host_int_fill_join_bss_param(param, info->ies, &index, - &pcipher_total_cnt, - &auth_total_cnt, info->tsf_lo, - &rates_no); - - return (void *)param; -} - int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) { int result = 0; From d241877a1aca7e48f8da7ed3e8191e98c9675ebf Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:16 +0530 Subject: [PATCH 486/903] staging: wilc1000: avoid setting default value for variable at declaration Cleanup patch to avoid setting default value for local variables and also clubbed similar variables together. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 25 ++-- drivers/staging/wilc1000/host_interface.c | 122 +++++++++--------- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 20 +-- 3 files changed, 79 insertions(+), 88 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 5933e4d20339..e09f10da036d 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -123,9 +123,7 @@ static inline void get_BSSID(u8 *data, u8 *bssid) static inline void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len) { - u8 len = 0; - u8 i = 0; - u8 j = 0; + u8 i, j, len; len = data[TAG_PARAM_OFFSET + 1]; j = TAG_PARAM_OFFSET + 2; @@ -198,18 +196,11 @@ static u8 get_current_channel_802_11n(u8 *msa, u16 rx_len) s32 wilc_parse_network_info(u8 *msg_buffer, struct network_info **ret_network_info) { - struct network_info *network_info = NULL; - u8 msg_type = 0; - u16 wid_len = 0; - u8 *wid_val = NULL; - u8 *msa = NULL; - u16 rx_len = 0; - u8 *tim_elm = NULL; - u8 *ies = NULL; - u16 ies_len = 0; - u8 index = 0; - u32 tsf_lo; - u32 tsf_hi; + struct network_info *network_info; + u8 *wid_val, *msa, *tim_elm, *ies; + u32 tsf_lo, tsf_hi; + u16 wid_len, rx_len, ies_len; + u8 msg_type, index; msg_type = msg_buffer[0]; @@ -271,8 +262,8 @@ s32 wilc_parse_network_info(u8 *msg_buffer, s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, struct connect_info *ret_conn_info) { - u8 *ies = NULL; - u16 ies_len = 0; + u8 *ies; + u16 ies_len; ret_conn_info->status = get_asoc_status(buffer); if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 895a12691499..d251a641015c 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -259,7 +259,7 @@ static void handle_set_channel(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct channel_attr *hif_set_ch = &msg->body.channel_info; - int ret = 0; + int ret; struct wid wid; wid.id = WID_CURRENT_CHANNEL; @@ -280,10 +280,10 @@ static void handle_set_wfi_drv_handler(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct drv_handler *hif_drv_handler = &msg->body.drv; - int ret = 0; + int ret; struct wid wid; u8 *currbyte, *buffer; - struct host_if_drv *hif_drv = NULL; + struct host_if_drv *hif_drv; if (!vif->hif_drv || !hif_drv_handler) goto free_msg; @@ -327,7 +327,7 @@ static void handle_set_operation_mode(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct op_mode *hif_op_mode = &msg->body.mode; - int ret = 0; + int ret; struct wid wid; wid.id = WID_SET_OPERATION_MODE; @@ -352,7 +352,7 @@ static void handle_set_ip_address(struct work_struct *work) struct wilc_vif *vif = msg->vif; u8 *ip_addr = msg->body.ip_info.ip_addr; u8 idx = msg->body.ip_info.idx; - int ret = 0; + int ret; struct wid wid; char firmware_ip_addr[4] = {0}; @@ -381,7 +381,7 @@ static void handle_get_ip_address(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; u8 idx = msg->body.ip_info.idx; - int ret = 0; + int ret; struct wid wid; wid.id = WID_IP_ADDRESS; @@ -409,7 +409,7 @@ static void handle_get_mac_address(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct get_mac_addr *get_mac_addr = &msg->body.get_mac_info; - int ret = 0; + int ret; struct wid wid; wid.id = WID_MAC_ADDR; @@ -431,7 +431,7 @@ static void handle_cfg_param(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct cfg_param_attr *param = &msg->body.cfg_info; - int ret = 0; + int ret; struct wid wid_list[32]; struct host_if_drv *hif_drv = vif->hif_drv; int i = 0; @@ -1148,7 +1148,7 @@ static void handle_connect_timeout(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; - s32 result = 0; + s32 result; struct connect_info info; struct wid wid; u16 dummy_reason_code = 0; @@ -1389,7 +1389,7 @@ static void handle_rcvd_ntwrk_info(struct work_struct *work) u32 i; bool found; struct network_info *info = NULL; - void *params = NULL; + void *params; struct host_if_drv *hif_drv = vif->hif_drv; struct user_scan_req *scan_req = &hif_drv->usr_scan_req; @@ -1608,7 +1608,7 @@ static void handle_rcvd_gnrl_async_info(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct rcvd_async_info *rcvd_info = &msg->body.async_info; - u8 msg_type = 0; + u8 msg_type; u8 mac_status; struct host_if_drv *hif_drv = vif->hif_drv; @@ -1926,7 +1926,7 @@ static void handle_disconnect(struct work_struct *work) struct disconnect_info disconn_info; struct user_scan_req *scan_req; struct user_conn_req *conn_req; - s32 result = 0; + s32 result; u16 dummy_reason_code = 0; wid.id = WID_DISCONNECT; @@ -2004,7 +2004,7 @@ static void handle_get_rssi(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; - s32 result = 0; + s32 result; struct wid wid; wid.id = WID_RSSI; @@ -2026,7 +2026,7 @@ static void handle_get_statistics(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct wid wid_list[5]; - u32 wid_cnt = 0, result = 0; + u32 wid_cnt = 0, result; struct rf_info *stats = (struct rf_info *)msg->body.data; wid_list[wid_cnt].id = WID_LINKSPEED; @@ -2084,7 +2084,7 @@ static void handle_get_inactive_time(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct sta_inactive_t *hif_sta_inactive = &msg->body.mac_info; - s32 result = 0; + s32 result; struct wid wid; wid.id = WID_SET_STA_MAC_INACTIVE_TIME; @@ -2126,7 +2126,7 @@ static void handle_add_beacon(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct beacon_attr *param = &msg->body.beacon_info; - s32 result = 0; + s32 result; struct wid wid; u8 *cur_byte; @@ -2181,7 +2181,7 @@ static void handle_del_beacon(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; - s32 result = 0; + s32 result; struct wid wid; u8 del_beacon = 0; @@ -2232,7 +2232,7 @@ static void handle_add_station(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct add_sta_param *param = &msg->body.add_sta_info; - s32 result = 0; + s32 result; struct wid wid; u8 *cur_byte; @@ -2263,7 +2263,7 @@ static void handle_del_all_sta(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct del_all_sta *param = &msg->body.del_all_sta_info; - s32 result = 0; + s32 result; struct wid wid; u8 *curr_byte; u8 i; @@ -2307,7 +2307,7 @@ static void handle_del_station(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct del_sta *param = &msg->body.del_sta_info; - s32 result = 0; + s32 result; struct wid wid; wid.id = WID_REMOVE_STA; @@ -2335,7 +2335,7 @@ static void handle_edit_station(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct add_sta_param *param = &msg->body.edit_sta_info; - s32 result = 0; + s32 result; struct wid wid; u8 *cur_byte; @@ -2364,7 +2364,7 @@ error: static int handle_remain_on_chan(struct wilc_vif *vif, struct remain_ch *hif_remain_ch) { - s32 result = 0; + s32 result; u8 remain_on_chan_flag; struct wid wid; struct host_if_drv *hif_drv = vif->hif_drv; @@ -2433,7 +2433,7 @@ static void handle_register_frame(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct reg_frame *hif_reg_frame = &msg->body.reg_frame; - s32 result = 0; + s32 result; struct wid wid; u8 *cur_byte; @@ -2468,7 +2468,7 @@ static void handle_listen_state_expired(struct work_struct *work) struct remain_ch *hif_remain_ch = &msg->body.remain_on_ch; u8 remain_on_chan_flag; struct wid wid; - s32 result = 0; + s32 result; struct host_if_drv *hif_drv = vif->hif_drv; if (p2p_listen_state) { @@ -2510,7 +2510,7 @@ static void listen_timer_cb(struct timer_list *t) struct host_if_drv *hif_drv = from_timer(hif_drv, t, remain_on_ch_timer); struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif; - s32 result = 0; + s32 result; struct host_if_msg *msg; del_timer(&vif->hif_drv->remain_on_ch_timer); @@ -2533,7 +2533,7 @@ static void handle_power_management(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct power_mgmt_param *pm_param = &msg->body.pwr_mgmt_info; - s32 result = 0; + s32 result; struct wid wid; s8 power_mode; @@ -2559,7 +2559,7 @@ static void handle_set_mcast_filter(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct set_multicast *hif_set_mc = &msg->body.multicast_info; - s32 result = 0; + s32 result; struct wid wid; u8 *cur_byte; @@ -2621,7 +2621,7 @@ static void handle_get_tx_pwr(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; u8 *tx_pwr = &msg->body.tx_power.tx_pwr; - int ret = 0; + int ret; struct wid wid; wid.id = WID_TX_POWER; @@ -2713,7 +2713,7 @@ static void timer_connect_cb(struct timer_list *t) int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) { - int result = 0; + int result; struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; @@ -2743,7 +2743,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) { - int result = 0; + int result; struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; @@ -3005,7 +3005,7 @@ free_msg: int wilc_set_pmkid_info(struct wilc_vif *vif, struct host_if_pmkid_attr *pmkid) { - int result = 0; + int result; struct host_if_msg *msg; int i; @@ -3034,7 +3034,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_get_mac_address, true); @@ -3060,7 +3060,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, u8 security, enum authtype auth_type, u8 channel, void *join_params) { - int result = 0; + int result; struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; @@ -3141,7 +3141,7 @@ free_msg: int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) { - int result = 0; + int result; struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; @@ -3187,7 +3187,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, u8 ifc_id) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_set_wfi_drv_handler, false); @@ -3209,7 +3209,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_set_operation_mode, false); @@ -3229,7 +3229,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) { - s32 result = 0; + s32 result; struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; @@ -3258,7 +3258,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) { - int result = 0; + int result; struct host_if_msg *msg; if (!rssi_level) { @@ -3293,7 +3293,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_get_statistics, is_sync); @@ -3322,7 +3322,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, size_t ies_len, wilc_scan_result scan_result, void *user_arg, struct hidden_network *hidden_network) { - int result = 0; + int result; struct host_if_msg *msg; struct scan_attr *scan_info; struct host_if_drv *hif_drv = vif->hif_drv; @@ -3548,10 +3548,10 @@ int wilc_deinit(struct wilc_vif *vif) void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) { - s32 result = 0; + s32 result; struct host_if_msg *msg; int id; - struct host_if_drv *hif_drv = NULL; + struct host_if_drv *hif_drv; struct wilc_vif *vif; id = buffer[length - 4]; @@ -3589,10 +3589,10 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) { - s32 result = 0; + s32 result; struct host_if_msg *msg; int id; - struct host_if_drv *hif_drv = NULL; + struct host_if_drv *hif_drv; struct wilc_vif *vif; mutex_lock(&hif_deinit_lock); @@ -3646,9 +3646,9 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) { - s32 result = 0; + s32 result; int id; - struct host_if_drv *hif_drv = NULL; + struct host_if_drv *hif_drv; struct wilc_vif *vif; id = buffer[length - 4]; @@ -3684,7 +3684,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, wilc_remain_on_chan_ready ready, void *user_arg) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_remain_on_chan_work, false); @@ -3709,7 +3709,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) { - int result = 0; + int result; struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; @@ -3737,7 +3737,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_register_frame, false); @@ -3771,7 +3771,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, u32 head_len, u8 *head, u32 tail_len, u8 *tail) { - int result = 0; + int result; struct host_if_msg *msg; struct beacon_attr *beacon_info; @@ -3816,7 +3816,7 @@ error: int wilc_del_beacon(struct wilc_vif *vif) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_del_beacon, false); @@ -3834,7 +3834,7 @@ int wilc_del_beacon(struct wilc_vif *vif) int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) { - int result = 0; + int result; struct host_if_msg *msg; struct add_sta_param *add_sta_info; @@ -3865,7 +3865,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) { - int result = 0; + int result; struct host_if_msg *msg; struct del_sta *del_sta_info; @@ -3890,7 +3890,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) { - int result = 0; + int result; struct host_if_msg *msg; struct del_all_sta *del_all_sta_info; u8 zero_addr[ETH_ALEN] = {0}; @@ -3931,7 +3931,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) int wilc_edit_station(struct wilc_vif *vif, struct add_sta_param *sta_param) { - int result = 0; + int result; struct host_if_msg *msg; struct add_sta_param *add_sta_info; @@ -3963,7 +3963,7 @@ int wilc_edit_station(struct wilc_vif *vif, int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) { - int result = 0; + int result; struct host_if_msg *msg; if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled) @@ -3987,7 +3987,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_set_mcast_filter, false); @@ -4007,7 +4007,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_set_ip_address, false); @@ -4028,7 +4028,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) { - int result = 0; + int result; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_get_ip_address, false); @@ -4049,7 +4049,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) { - int ret = 0; + int ret; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_set_tx_pwr, false); @@ -4069,7 +4069,7 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) { - int ret = 0; + int ret; struct host_if_msg *msg; msg = wilc_alloc_work(vif, handle_get_tx_pwr, true); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 96aaf14faa92..e7e529f0dc1c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -669,7 +669,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) static int connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { - s32 ret = 0; + s32 ret; u32 i; u32 sel_bssi_idx = UINT_MAX; u8 security = NO_ENCRYPT; @@ -677,7 +677,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, u32 cipher_group; struct wilc_priv *priv; struct host_if_drv *wfi_drv; - struct network_info *nw_info = NULL; + struct network_info *nw_info; struct wilc_vif *vif; wilc_connecting = 1; @@ -818,7 +818,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) { - s32 ret = 0; + s32 ret; struct wilc_priv *priv; struct host_if_drv *wfi_drv; struct wilc_vif *vif; @@ -1174,7 +1174,7 @@ static int change_bss(struct wiphy *wiphy, struct net_device *dev, static int set_wiphy_params(struct wiphy *wiphy, u32 changed) { - s32 ret = 0; + s32 ret; struct cfg_param_attr cfg_param_val; struct wilc_priv *priv; struct wilc_vif *vif; @@ -1879,7 +1879,7 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ap_settings *settings) { struct cfg80211_beacon_data *beacon = &settings->beacon; - s32 ret = 0; + s32 ret; struct wilc *wl; struct wilc_vif *vif; @@ -1916,7 +1916,7 @@ static int change_beacon(struct wiphy *wiphy, struct net_device *dev, static int stop_ap(struct wiphy *wiphy, struct net_device *dev) { - s32 ret = 0; + s32 ret; struct wilc_priv *priv; struct wilc_vif *vif; u8 null_bssid[ETH_ALEN] = {0}; @@ -2049,7 +2049,7 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, { struct wilc_vif *vif; struct wilc_priv *priv; - struct net_device *new_ifc = NULL; + struct net_device *new_ifc; priv = wiphy_priv(wiphy); vif = netdev_priv(priv->wdev->netdev); @@ -2215,7 +2215,7 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, { struct wilc_priv *priv; struct wireless_dev *wdev; - s32 ret = 0; + s32 ret; wdev = wilc_wfi_cfg_alloc(); if (!wdev) { @@ -2257,7 +2257,7 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, int wilc_init_host_int(struct net_device *net) { - int ret = 0; + int ret; struct wilc_priv *priv; priv = wdev_priv(net->ieee80211_ptr); @@ -2279,7 +2279,7 @@ int wilc_init_host_int(struct net_device *net) int wilc_deinit_host_int(struct net_device *net) { - int ret = 0; + int ret; struct wilc_vif *vif; struct wilc_priv *priv; From 82120ec7afc3d6d36fe47e11007637048d1dd6f6 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:17 +0530 Subject: [PATCH 487/903] staging: wilc1000: use 'int' inplace of 's32' date type Cleanup patch to use 'int' instead of 's32' to have the same data type based on its usage. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 48 +++++++++---------- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 28 +++++------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index d251a641015c..fb063e5912f3 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -722,9 +722,9 @@ unlock: kfree(msg); } -static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) +static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) { - s32 result = 0; + int result = 0; u8 abort_running_scan; struct wid wid; struct host_if_drv *hif_drv = vif->hif_drv; @@ -765,7 +765,7 @@ static void handle_scan(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct scan_attr *scan_info = &msg->body.scan_info; - s32 result = 0; + int result = 0; struct wid wid_list[5]; u32 index = 0; u32 i; @@ -883,7 +883,7 @@ static void handle_connect(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct connect_attr *conn_attr = &msg->body.con_info; - s32 result = 0; + int result = 0; struct wid wid_list[8]; u32 wid_cnt = 0, dummyval = 0; u8 *cur_byte = NULL; @@ -1148,7 +1148,7 @@ static void handle_connect_timeout(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; - s32 result; + int result; struct connect_info info; struct wid wid; u16 dummy_reason_code = 0; @@ -1454,7 +1454,7 @@ static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, u32 max_assoc_resp_info_len, u32 *rcvd_assoc_resp_info_len) { - s32 result; + int result; struct wid wid; wid.id = WID_ASSOC_RES_INFO; @@ -1926,7 +1926,7 @@ static void handle_disconnect(struct work_struct *work) struct disconnect_info disconn_info; struct user_scan_req *scan_req; struct user_conn_req *conn_req; - s32 result; + int result; u16 dummy_reason_code = 0; wid.id = WID_DISCONNECT; @@ -2004,7 +2004,7 @@ static void handle_get_rssi(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; - s32 result; + int result; struct wid wid; wid.id = WID_RSSI; @@ -2084,7 +2084,7 @@ static void handle_get_inactive_time(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct sta_inactive_t *hif_sta_inactive = &msg->body.mac_info; - s32 result; + int result; struct wid wid; wid.id = WID_SET_STA_MAC_INACTIVE_TIME; @@ -2126,7 +2126,7 @@ static void handle_add_beacon(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct beacon_attr *param = &msg->body.beacon_info; - s32 result; + int result; struct wid wid; u8 *cur_byte; @@ -2181,7 +2181,7 @@ static void handle_del_beacon(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; - s32 result; + int result; struct wid wid; u8 del_beacon = 0; @@ -2232,7 +2232,7 @@ static void handle_add_station(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct add_sta_param *param = &msg->body.add_sta_info; - s32 result; + int result; struct wid wid; u8 *cur_byte; @@ -2263,7 +2263,7 @@ static void handle_del_all_sta(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct del_all_sta *param = &msg->body.del_all_sta_info; - s32 result; + int result; struct wid wid; u8 *curr_byte; u8 i; @@ -2307,7 +2307,7 @@ static void handle_del_station(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct del_sta *param = &msg->body.del_sta_info; - s32 result; + int result; struct wid wid; wid.id = WID_REMOVE_STA; @@ -2335,7 +2335,7 @@ static void handle_edit_station(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct add_sta_param *param = &msg->body.edit_sta_info; - s32 result; + int result; struct wid wid; u8 *cur_byte; @@ -2364,7 +2364,7 @@ error: static int handle_remain_on_chan(struct wilc_vif *vif, struct remain_ch *hif_remain_ch) { - s32 result; + int result; u8 remain_on_chan_flag; struct wid wid; struct host_if_drv *hif_drv = vif->hif_drv; @@ -2433,7 +2433,7 @@ static void handle_register_frame(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct reg_frame *hif_reg_frame = &msg->body.reg_frame; - s32 result; + int result; struct wid wid; u8 *cur_byte; @@ -2468,7 +2468,7 @@ static void handle_listen_state_expired(struct work_struct *work) struct remain_ch *hif_remain_ch = &msg->body.remain_on_ch; u8 remain_on_chan_flag; struct wid wid; - s32 result; + int result; struct host_if_drv *hif_drv = vif->hif_drv; if (p2p_listen_state) { @@ -2510,7 +2510,7 @@ static void listen_timer_cb(struct timer_list *t) struct host_if_drv *hif_drv = from_timer(hif_drv, t, remain_on_ch_timer); struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif; - s32 result; + int result; struct host_if_msg *msg; del_timer(&vif->hif_drv->remain_on_ch_timer); @@ -2533,7 +2533,7 @@ static void handle_power_management(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct power_mgmt_param *pm_param = &msg->body.pwr_mgmt_info; - s32 result; + int result; struct wid wid; s8 power_mode; @@ -2559,7 +2559,7 @@ static void handle_set_mcast_filter(struct work_struct *work) struct host_if_msg *msg = container_of(work, struct host_if_msg, work); struct wilc_vif *vif = msg->vif; struct set_multicast *hif_set_mc = &msg->body.multicast_info; - s32 result; + int result; struct wid wid; u8 *cur_byte; @@ -3548,7 +3548,7 @@ int wilc_deinit(struct wilc_vif *vif) void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) { - s32 result; + int result; struct host_if_msg *msg; int id; struct host_if_drv *hif_drv; @@ -3589,7 +3589,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) { - s32 result; + int result; struct host_if_msg *msg; int id; struct host_if_drv *hif_drv; @@ -3646,7 +3646,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) { - s32 result; + int result; int id; struct host_if_drv *hif_drv; struct wilc_vif *vif; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index e7e529f0dc1c..ba6f9ed07779 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -615,7 +615,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) { struct wilc_priv *priv; u32 i; - s32 ret = 0; + int ret = 0; u8 scan_ch_list[MAX_NUM_SCANNED_NETWORKS]; struct hidden_network hidden_ntwk; struct wilc_vif *vif; @@ -669,7 +669,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) static int connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { - s32 ret; + int ret; u32 i; u32 sel_bssi_idx = UINT_MAX; u8 security = NO_ENCRYPT; @@ -818,7 +818,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) { - s32 ret; + int ret; struct wilc_priv *priv; struct host_if_drv *wfi_drv; struct wilc_vif *vif; @@ -914,7 +914,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool pairwise, const u8 *mac_addr, struct key_params *params) { - s32 ret = 0, keylen = params->key_len; + int ret = 0, keylen = params->key_len; struct wilc_priv *priv; const u8 *rx_mic = NULL; const u8 *tx_mic = NULL; @@ -1174,7 +1174,7 @@ static int change_bss(struct wiphy *wiphy, struct net_device *dev, static int set_wiphy_params(struct wiphy *wiphy, u32 changed) { - s32 ret; + int ret; struct cfg_param_attr cfg_param_val; struct wilc_priv *priv; struct wilc_vif *vif; @@ -1213,7 +1213,7 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { u32 i; - s32 ret = 0; + int ret = 0; u8 flag = 0; struct wilc_vif *vif; struct wilc_priv *priv = wiphy_priv(wiphy); @@ -1249,7 +1249,7 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { u32 i; - s32 ret = 0; + int ret = 0; struct wilc_priv *priv = wiphy_priv(wiphy); for (i = 0; i < priv->pmkid_list.numpmkid; i++) { @@ -1505,7 +1505,7 @@ static int remain_on_channel(struct wiphy *wiphy, struct ieee80211_channel *chan, unsigned int duration, u64 *cookie) { - s32 ret = 0; + int ret = 0; struct wilc_priv *priv; struct wilc_vif *vif; @@ -1879,7 +1879,7 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ap_settings *settings) { struct cfg80211_beacon_data *beacon = &settings->beacon; - s32 ret; + int ret; struct wilc *wl; struct wilc_vif *vif; @@ -1916,7 +1916,7 @@ static int change_beacon(struct wiphy *wiphy, struct net_device *dev, static int stop_ap(struct wiphy *wiphy, struct net_device *dev) { - s32 ret; + int ret; struct wilc_priv *priv; struct wilc_vif *vif; u8 null_bssid[ETH_ALEN] = {0}; @@ -1940,7 +1940,7 @@ static int stop_ap(struct wiphy *wiphy, struct net_device *dev) static int add_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_parameters *params) { - s32 ret = 0; + int ret = 0; struct wilc_priv *priv; struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif; @@ -1981,7 +1981,7 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev, struct station_del_parameters *params) { const u8 *mac = params->mac; - s32 ret = 0; + int ret = 0; struct wilc_priv *priv; struct wilc_vif *vif; struct sta_info *info; @@ -2009,7 +2009,7 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev, static int change_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_parameters *params) { - s32 ret = 0; + int ret = 0; struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif; @@ -2215,7 +2215,7 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, { struct wilc_priv *priv; struct wireless_dev *wdev; - s32 ret; + int ret; wdev = wilc_wfi_cfg_alloc(); if (!wdev) { From cd46d1b11433d92bcbecaccd48ba4860ed5f4c25 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:18 +0530 Subject: [PATCH 488/903] staging: wilc1000: remove unnecessary 'NULL' check from cfg80211_ops callbacks Cleanup patch to remove the unnecessary 'NULL' check used in 'cfg80211_ops' callback functions. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index ba6f9ed07779..2d44333d5ce3 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1781,9 +1781,6 @@ static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, struct wilc_priv *priv; struct wilc_vif *vif; - if (!wiphy) - return -ENOENT; - priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); if (!priv->hif_drv) @@ -1921,9 +1918,6 @@ static int stop_ap(struct wiphy *wiphy, struct net_device *dev) struct wilc_vif *vif; u8 null_bssid[ETH_ALEN] = {0}; - if (!wiphy) - return -EFAULT; - priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); @@ -1945,9 +1939,6 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev, struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif; - if (!wiphy) - return -EFAULT; - priv = wiphy_priv(wiphy); vif = netdev_priv(dev); @@ -1986,9 +1977,6 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev, struct wilc_vif *vif; struct sta_info *info; - if (!wiphy) - return -EFAULT; - priv = wiphy_priv(wiphy); vif = netdev_priv(dev); @@ -2013,9 +2001,6 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif; - if (!wiphy) - return -EFAULT; - vif = netdev_priv(dev); if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { From 6bcba96e8543a2c7edaf3fb7c0673680b7de92bf Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 19 Jul 2018 04:15:19 +0530 Subject: [PATCH 489/903] staging: wilc1000: move variable assignment along with its declaration Cleanup patch to club the variable assignment along with the variable declaration especially for private data. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 7 +- drivers/staging/wilc1000/linux_wlan.c | 113 +++------ .../staging/wilc1000/wilc_wfi_cfgoperations.c | 229 ++++++------------ drivers/staging/wilc1000/wilc_wlan.c | 53 ++-- 4 files changed, 118 insertions(+), 284 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index fb063e5912f3..c78b51a2f841 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3429,13 +3429,10 @@ static void get_periodic_rssi(struct timer_list *unused) int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) { struct host_if_drv *hif_drv; - struct wilc_vif *vif; - struct wilc *wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; int i; - vif = netdev_priv(dev); - wilc = vif->wilc; - hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); if (!hif_drv) return -ENOMEM; diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 5667a543029c..2f4bf8e1f33e 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -94,12 +94,9 @@ static int dev_state_ev_handler(struct notifier_block *this, static irqreturn_t isr_uh_routine(int irq, void *user_data) { - struct wilc_vif *vif; - struct wilc *wilc; struct net_device *dev = user_data; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; if (wilc->close) { netdev_err(dev, "Can't handle UH interrupt\n"); @@ -110,12 +107,9 @@ static irqreturn_t isr_uh_routine(int irq, void *user_data) static irqreturn_t isr_bh_routine(int irq, void *userdata) { - struct wilc_vif *vif; - struct wilc *wilc; struct net_device *dev = userdata; - - vif = netdev_priv(userdata); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(userdata); + struct wilc *wilc = vif->wilc; if (wilc->close) { netdev_err(dev, "Can't handle BH interrupt\n"); @@ -130,11 +124,8 @@ static irqreturn_t isr_bh_routine(int irq, void *userdata) static int init_irq(struct net_device *dev) { int ret = 0; - struct wilc_vif *vif; - struct wilc *wl; - - vif = netdev_priv(dev); - wl = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; if ((gpio_request(wl->gpio, "WILC_INTR") == 0) && (gpio_direction_input(wl->gpio) == 0)) { @@ -163,11 +154,8 @@ static int init_irq(struct net_device *dev) static void deinit_irq(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; /* Deinitialize IRQ */ if (wilc->dev_irq_num) { @@ -238,12 +226,9 @@ static int linux_wlan_txq_task(void *vp) { int ret; u32 txq_count; - struct wilc_vif *vif; - struct wilc *wl; struct net_device *dev = vp; - - vif = netdev_priv(dev); - wl = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; complete(&wl->txq_thread_started); while (1) { @@ -271,15 +256,12 @@ static int linux_wlan_txq_task(void *vp) static int wilc_wlan_get_firmware(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; int chip_id, ret = 0; const struct firmware *wilc_firmware; char *firmware; - vif = netdev_priv(dev); - wilc = vif->wilc; - chip_id = wilc_get_chipid(wilc, false); if (chip_id < 0x1003a0) @@ -306,13 +288,10 @@ fail: static int linux_wlan_start_firmware(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; int ret = 0; - vif = netdev_priv(dev); - wilc = vif->wilc; - ret = wilc_wlan_start(wilc); if (ret < 0) return ret; @@ -326,13 +305,10 @@ static int linux_wlan_start_firmware(struct net_device *dev) static int wilc1000_firmware_download(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; int ret = 0; - vif = netdev_priv(dev); - wilc = vif->wilc; - if (!wilc->firmware) { netdev_err(dev, "Firmware buffer is NULL\n"); return -ENOBUFS; @@ -560,11 +536,8 @@ fail: static int wlan_deinit_locks(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; mutex_destroy(&wilc->hif_cs); mutex_destroy(&wilc->rxq_cs); @@ -575,11 +548,8 @@ static int wlan_deinit_locks(struct net_device *dev) static void wlan_deinitialize_threads(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wl; - - vif = netdev_priv(dev); - wl = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; wl->close = 1; @@ -593,11 +563,8 @@ static void wlan_deinitialize_threads(struct net_device *dev) static void wilc_wlan_deinitialize(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wl; - - vif = netdev_priv(dev); - wl = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; if (!wl) { netdev_err(dev, "wl is NULL\n"); @@ -632,11 +599,8 @@ static void wilc_wlan_deinitialize(struct net_device *dev) static int wlan_init_locks(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wl; - - vif = netdev_priv(dev); - wl = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; mutex_init(&wl->hif_cs); mutex_init(&wl->rxq_cs); @@ -655,11 +619,8 @@ static int wlan_init_locks(struct net_device *dev) static int wlan_initialize_threads(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev, "K_TXQ_TASK"); @@ -779,14 +740,11 @@ static int mac_init_fn(struct net_device *ndev) static int wilc_mac_open(struct net_device *ndev) { - struct wilc_vif *vif; + struct wilc_vif *vif = netdev_priv(ndev); + struct wilc *wl = vif->wilc; unsigned char mac_add[ETH_ALEN] = {0}; int ret = 0; int i = 0; - struct wilc *wl; - - vif = netdev_priv(ndev); - wl = vif->wilc; if (!wl || !wl->dev) { netdev_err(ndev, "device not ready\n"); @@ -850,11 +808,9 @@ static struct net_device_stats *mac_stats(struct net_device *dev) static void wilc_set_multicast_list(struct net_device *dev) { struct netdev_hw_addr *ha; - struct wilc_vif *vif; + struct wilc_vif *vif = netdev_priv(dev); int i = 0; - vif = netdev_priv(dev); - if (dev->flags & IFF_PROMISC) return; @@ -894,16 +850,13 @@ static void linux_wlan_tx_complete(void *priv, int status) netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) { - struct wilc_vif *vif; + struct wilc_vif *vif = netdev_priv(ndev); + struct wilc *wilc = vif->wilc; struct tx_complete_data *tx_data = NULL; int queue_count; char *udp_buf; struct iphdr *ih; struct ethhdr *eth_h; - struct wilc *wilc; - - vif = netdev_priv(ndev); - wilc = vif->wilc; if (skb->dev != ndev) { netdev_err(ndev, "Packet not destined to this device\n"); @@ -951,12 +904,10 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) static int wilc_mac_close(struct net_device *ndev) { struct wilc_priv *priv; - struct wilc_vif *vif; + struct wilc_vif *vif = netdev_priv(ndev); struct host_if_drv *hif_drv; struct wilc *wl; - vif = netdev_priv(ndev); - if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr || !vif->ndev->ieee80211_ptr->wiphy) return 0; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 2d44333d5ce3..42c01280ff91 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -463,21 +463,15 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, struct disconnect_info *disconn_info, void *priv_data) { - struct wilc_priv *priv; - struct net_device *dev; - struct host_if_drv *wfi_drv; + struct wilc_priv *priv = priv_data; + struct net_device *dev = priv->dev; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; + struct host_if_drv *wfi_drv = priv->hif_drv; u8 null_bssid[ETH_ALEN] = {0}; - struct wilc *wl; - struct wilc_vif *vif; wilc_connecting = 0; - priv = priv_data; - dev = priv->dev; - vif = netdev_priv(dev); - wl = vif->wilc; - wfi_drv = (struct host_if_drv *)priv->hif_drv; - if (conn_disconn_evt == CONN_DISCONN_EVENT_CONN_RESP) { u16 connect_status; @@ -550,12 +544,9 @@ static int set_channel(struct wiphy *wiphy, struct cfg80211_chan_def *chandef) { u32 channelnum = 0; - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); int result = 0; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); @@ -613,15 +604,12 @@ out: static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) { - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); u32 i; int ret = 0; u8 scan_ch_list[MAX_NUM_SCANNED_NETWORKS]; struct hidden_network hidden_ntwk; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); priv->scan_req = request; @@ -669,21 +657,18 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) static int connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); + struct host_if_drv *wfi_drv = priv->hif_drv; + struct network_info *nw_info; int ret; u32 i; u32 sel_bssi_idx = UINT_MAX; u8 security = NO_ENCRYPT; enum authtype auth_type = ANY; u32 cipher_group; - struct wilc_priv *priv; - struct host_if_drv *wfi_drv; - struct network_info *nw_info; - struct wilc_vif *vif; wilc_connecting = 1; - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); - wfi_drv = (struct host_if_drv *)priv->hif_drv; if (!(strncmp(sme->ssid, "DIRECT-", 7))) wfi_drv->p2p_connect = 1; @@ -818,17 +803,14 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) { - int ret; - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc *wilc = vif->wilc; struct host_if_drv *wfi_drv; - struct wilc_vif *vif; - struct wilc *wilc; + int ret; u8 null_bssid[ETH_ALEN] = {0}; wilc_connecting = 0; - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); - wilc = vif->wilc; if (!wilc) return -EIO; @@ -915,15 +897,12 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, { int ret = 0, keylen = params->key_len; - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(wiphy); const u8 *rx_mic = NULL; const u8 *tx_mic = NULL; u8 mode = NO_ENCRYPT; u8 op_mode; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(netdev); + struct wilc_vif *vif = netdev_priv(netdev); switch (params->cipher) { case WLAN_CIPHER_SUITE_WEP40: @@ -1028,13 +1007,9 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev, bool pairwise, const u8 *mac_addr) { - struct wilc_priv *priv; - struct wilc *wl; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(netdev); - wl = vif->wilc; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc *wl = vif->wilc; if (netdev == wl->vif[0]->ndev) { if (priv->wilc_gtk[key_index]) { @@ -1071,11 +1046,9 @@ static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool pairwise, const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *)) { - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(wiphy); struct key_params key_params; - priv = wiphy_priv(wiphy); - if (!pairwise) { key_params.key = priv->wilc_gtk[key_index]->key; key_params.cipher = priv->wilc_gtk[key_index]->cipher; @@ -1098,11 +1071,8 @@ static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool unicast, bool multicast) { - struct wilc_priv *priv; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); wilc_set_wep_default_keyid(vif, key_index); @@ -1112,15 +1082,12 @@ static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, static int get_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_info *sinfo) { - struct wilc_priv *priv; - struct wilc_vif *vif; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(dev); u32 i = 0; u32 associatedsta = ~0; u32 inactive_time = 0; - priv = wiphy_priv(wiphy); - vif = netdev_priv(dev); - if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { for (i = 0; i < NUM_STA_ASSOCIATED; i++) { if (!(memcmp(mac, @@ -1176,11 +1143,8 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) { int ret; struct cfg_param_attr cfg_param_val; - struct wilc_priv *priv; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); cfg_param_val.flag = 0; @@ -1212,13 +1176,11 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); u32 i; int ret = 0; u8 flag = 0; - struct wilc_vif *vif; - struct wilc_priv *priv = wiphy_priv(wiphy); - - vif = netdev_priv(priv->dev); for (i = 0; i < priv->pmkid_list.numpmkid; i++) { if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, @@ -1397,14 +1359,11 @@ static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff, void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) { - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(dev->ieee80211_ptr->wiphy); + struct host_if_drv *wfi_drv = priv->hif_drv; u32 header, pkt_offset; - struct host_if_drv *wfi_drv; s32 freq; - priv = wiphy_priv(dev->ieee80211_ptr->wiphy); - wfi_drv = (struct host_if_drv *)priv->hif_drv; - memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); pkt_offset = GET_PKT_OFFSET(header); @@ -1506,11 +1465,8 @@ static int remain_on_channel(struct wiphy *wiphy, unsigned int duration, u64 *cookie) { int ret = 0; - struct wilc_priv *priv; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); if (wdev->iftype == NL80211_IFTYPE_AP) { netdev_dbg(vif->ndev, "Required while in AP mode\n"); @@ -1535,11 +1491,8 @@ static int cancel_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie) { - struct wilc_priv *priv; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); return wilc_listen_state_expired(vif, priv->remain_on_ch_params.listen_session_id); @@ -1605,16 +1558,12 @@ static int mgmt_tx(struct wiphy *wiphy, size_t len = params->len; const struct ieee80211_mgmt *mgmt; struct p2p_mgmt_data *mgmt_tx; - struct wilc_priv *priv; - struct host_if_drv *wfi_drv; - struct wilc_vif *vif; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct host_if_drv *wfi_drv = priv->hif_drv; + struct wilc_vif *vif = netdev_priv(wdev->netdev); u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(p2p_local_random); int ret = 0; - vif = netdev_priv(wdev->netdev); - priv = wiphy_priv(wiphy); - wfi_drv = (struct host_if_drv *)priv->hif_drv; - *cookie = (unsigned long)buf; priv->tx_cookie = *cookie; mgmt = (const struct ieee80211_mgmt *)buf; @@ -1694,11 +1643,9 @@ static int mgmt_tx_cancel_wait(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie) { - struct wilc_priv *priv; - struct host_if_drv *wfi_drv; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct host_if_drv *wfi_drv = priv->hif_drv; - priv = wiphy_priv(wiphy); - wfi_drv = (struct host_if_drv *)priv->hif_drv; wfi_drv->p2p_timeout = jiffies; if (!priv->p2p_listen_state) { @@ -1718,13 +1665,9 @@ static int mgmt_tx_cancel_wait(struct wiphy *wiphy, void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, u16 frame_type, bool reg) { - struct wilc_priv *priv; - struct wilc_vif *vif; - struct wilc *wl; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->wdev->netdev); - wl = vif->wilc; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->wdev->netdev); + struct wilc *wl = vif->wilc; if (!frame_type) return; @@ -1758,15 +1701,12 @@ static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, static int dump_station(struct wiphy *wiphy, struct net_device *dev, int idx, u8 *mac, struct station_info *sinfo) { - struct wilc_priv *priv; - struct wilc_vif *vif; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); if (idx != 0) return -ENOENT; - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); wilc_get_rssi(vif, &sinfo->signal); @@ -1778,11 +1718,9 @@ static int dump_station(struct wiphy *wiphy, struct net_device *dev, static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, bool enabled, int timeout) { - struct wilc_priv *priv; - struct wilc_vif *vif; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); if (!priv->hif_drv) return -EIO; @@ -1796,13 +1734,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, enum nl80211_iftype type, struct vif_params *params) { - struct wilc_priv *priv; - struct wilc_vif *vif; - struct wilc *wl; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; - vif = netdev_priv(dev); - priv = wiphy_priv(wiphy); - wl = vif->wilc; p2p_local_random = 0x01; p2p_recv_random = 0x00; wilc_ie = false; @@ -1875,13 +1810,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, static int start_ap(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ap_settings *settings) { + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; struct cfg80211_beacon_data *beacon = &settings->beacon; int ret; - struct wilc *wl; - struct wilc_vif *vif; - - vif = netdev_priv(dev); - wl = vif->wilc; ret = set_channel(wiphy, &settings->chandef); @@ -1900,11 +1832,8 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, static int change_beacon(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_beacon_data *beacon) { - struct wilc_priv *priv; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); return wilc_add_beacon(vif, 0, 0, beacon->head_len, (u8 *)beacon->head, beacon->tail_len, @@ -1914,13 +1843,10 @@ static int change_beacon(struct wiphy *wiphy, struct net_device *dev, static int stop_ap(struct wiphy *wiphy, struct net_device *dev) { int ret; - struct wilc_priv *priv; - struct wilc_vif *vif; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->dev); u8 null_bssid[ETH_ALEN] = {0}; - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->dev); - wilc_wlan_set_bssid(dev, null_bssid, AP_MODE); ret = wilc_del_beacon(vif); @@ -1935,12 +1861,9 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_parameters *params) { int ret = 0; - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(wiphy); struct add_sta_param sta_params = { {0} }; - struct wilc_vif *vif; - - priv = wiphy_priv(wiphy); - vif = netdev_priv(dev); + struct wilc_vif *vif = netdev_priv(dev); if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { memcpy(sta_params.bssid, mac, ETH_ALEN); @@ -1973,13 +1896,10 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev, { const u8 *mac = params->mac; int ret = 0; - struct wilc_priv *priv; - struct wilc_vif *vif; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(dev); struct sta_info *info; - priv = wiphy_priv(wiphy); - vif = netdev_priv(dev); - if (!(vif->iftype == AP_MODE || vif->iftype == GO_MODE)) return ret; @@ -1999,9 +1919,7 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, { int ret = 0; struct add_sta_param sta_params = { {0} }; - struct wilc_vif *vif; - - vif = netdev_priv(dev); + struct wilc_vif *vif = netdev_priv(dev); if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { memcpy(sta_params.bssid, mac, ETH_ALEN); @@ -2032,13 +1950,10 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, enum nl80211_iftype type, struct vif_params *params) { - struct wilc_vif *vif; - struct wilc_priv *priv; + struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(priv->wdev->netdev); struct net_device *new_ifc; - priv = wiphy_priv(wiphy); - vif = netdev_priv(priv->wdev->netdev); - if (type == NL80211_IFTYPE_MONITOR) { new_ifc = wilc_wfi_init_mon_interface(name, vif->ndev); if (new_ifc) { @@ -2109,9 +2024,7 @@ static int get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, int ret; struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(priv->dev); - struct wilc *wl; - - wl = vif->wilc; + struct wilc *wl = vif->wilc; /* If firmware is not started, return. */ if (!wl->initialized) @@ -2243,9 +2156,8 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, int wilc_init_host_int(struct net_device *net) { int ret; - struct wilc_priv *priv; + struct wilc_priv *priv = wdev_priv(net->ieee80211_ptr); - priv = wdev_priv(net->ieee80211_ptr); if (op_ifcs == 0) { timer_setup(&aging_timer, remove_network_from_shadow, 0); timer_setup(&wilc_during_ip_timer, clear_during_ip, 0); @@ -2265,11 +2177,8 @@ int wilc_init_host_int(struct net_device *net) int wilc_deinit_host_int(struct net_device *net) { int ret; - struct wilc_vif *vif; - struct wilc_priv *priv; - - priv = wdev_priv(net->ieee80211_ptr); - vif = netdev_priv(priv->dev); + struct wilc_priv *priv = wdev_priv(net->ieee80211_ptr); + struct wilc_vif *vif = netdev_priv(priv->dev); priv->p2p_listen_state = false; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index cb8bfd2e42bd..ea2e77f30aeb 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -31,11 +31,8 @@ wilc_wlan_txq_remove_from_head(struct net_device *dev) { struct txq_entry_t *tqe = NULL; unsigned long flags; - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -53,11 +50,8 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, struct txq_entry_t *tqe) { unsigned long flags; - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -156,11 +150,8 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) const struct ethhdr *eth_hdr_ptr = buffer; int i; unsigned long flags; - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -202,15 +193,12 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) { - struct wilc_vif *vif; - struct wilc *wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; u32 i = 0; u32 dropped = 0; unsigned long flags; - vif = netdev_priv(dev); - wilc = vif->wilc; - spin_lock_irqsave(&wilc->txq_spinlock, flags); for (i = pending_base; i < (pending_base + pending_acks); i++) { u32 session_index; @@ -511,7 +499,6 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) int i, entries = 0; u32 sum; u32 reg; - u8 *txb; u32 offset = 0; int vmm_sz = 0; struct txq_entry_t *tqe; @@ -519,14 +506,10 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) int counter; int timeout; u32 vmm_table[WILC_VMM_TBL_SIZE]; - struct wilc_vif *vif; - struct wilc *wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; const struct wilc_hif_func *func; - - vif = netdev_priv(dev); - wilc = vif->wilc; - - txb = wilc->tx_buffer; + u8 *txb = wilc->tx_buffer; if (wilc->quit) goto out; @@ -1081,11 +1064,8 @@ void wilc_wlan_cleanup(struct net_device *dev) struct rxq_entry_t *rqe; u32 reg = 0; int ret; - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; wilc->quit = 1; do { @@ -1281,11 +1261,8 @@ static u32 init_chip(struct net_device *dev) { u32 chipid; u32 reg, ret = 0; - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(dev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; acquire_bus(wilc, ACQUIRE_ONLY); From 9005feae4785436db61837e26a391015da7401d9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 20 Jul 2018 19:32:29 +0100 Subject: [PATCH 490/903] staging: rtl8712: remove redundant pointer 'nic' Pointer 'nic' is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'nic' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_led.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c index e9077347837e..0aa97c9dcced 100644 --- a/drivers/staging/rtl8712/rtl8712_led.c +++ b/drivers/staging/rtl8712/rtl8712_led.c @@ -89,9 +89,6 @@ static void BlinkWorkItemCallback(struct work_struct *work); static void InitLed871x(struct _adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin) { - struct net_device *nic; - - nic = padapter->pnetdev; pLed->padapter = padapter; pLed->LedPin = LedPin; pLed->CurrLedState = LED_STATE_OFF; From c73314e6ebb2651a70ca8a3ff08d4bd6b9f9ade1 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 20 Jul 2018 19:34:25 +0200 Subject: [PATCH 491/903] iio: Add channel for Phase Add new channel type support for phase. This channel may be used by Time-of-flight sensors to express the phase difference between emitted and received signals. Those sensor will then use the phase shift of return signals to approximate the distance to objects. Signed-off-by: Mathieu Othacehe Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++ drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + tools/iio/iio_event_monitor.c | 2 ++ 4 files changed, 11 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index c7353030670a..c9cfa833cf47 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1675,3 +1675,10 @@ KernelVersion: 4.12 Contact: linux-iio@vger.kernel.org Description: Raw counter device counters direction for channel Y. + +What: /sys/bus/iio/devices/iio:deviceX/in_phaseY_raw +KernelVersion: 4.18 +Contact: linux-iio@vger.kernel.org +Description: + Raw (unscaled) phase difference reading from channel Y + that can be processed to radians. \ No newline at end of file diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index ed1b3ebade94..a16ad5a4ab0c 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -86,6 +86,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_INDEX] = "index", [IIO_GRAVITY] = "gravity", [IIO_POSITIONRELATIVE] = "positionrelative", + [IIO_PHASE] = "phase", }; static const char * const iio_modifier_names[] = { diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index 033c7d28924e..e4df3cc268db 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -45,6 +45,7 @@ enum iio_chan_type { IIO_INDEX, IIO_GRAVITY, IIO_POSITIONRELATIVE, + IIO_PHASE, }; enum iio_modifier { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 148f69dfae75..f478f5558720 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -59,6 +59,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_UVINDEX] = "uvindex", [IIO_GRAVITY] = "gravity", [IIO_POSITIONRELATIVE] = "positionrelative", + [IIO_PHASE] = "phase", }; static const char * const iio_ev_type_text[] = { @@ -153,6 +154,7 @@ static bool event_is_known(struct iio_event_data *event) case IIO_UVINDEX: case IIO_GRAVITY: case IIO_POSITIONRELATIVE: + case IIO_PHASE: break; default: return false; From 1c28799257bca28cd5ba715e33157500d6239333 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 20 Jul 2018 19:34:26 +0200 Subject: [PATCH 492/903] iio: light: isl29501: Add support for the ISL29501 ToF sensor. This patch adds support for the ISL29501 Time of Flight sensor. Signed-off-by: Mathieu Othacehe Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-isl29501 | 47 + .../bindings/iio/light/isl29501.txt | 13 + drivers/iio/proximity/Kconfig | 13 + drivers/iio/proximity/Makefile | 1 + drivers/iio/proximity/isl29501.c | 1027 +++++++++++++++++ 5 files changed, 1101 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-isl29501 create mode 100644 Documentation/devicetree/bindings/iio/light/isl29501.txt create mode 100644 drivers/iio/proximity/isl29501.c diff --git a/Documentation/ABI/testing/sysfs-bus-iio-isl29501 b/Documentation/ABI/testing/sysfs-bus-iio-isl29501 new file mode 100644 index 000000000000..d009cfbbd72b --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-isl29501 @@ -0,0 +1,47 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_agc_gain +What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_agc_gain_bias +KernelVersion: 4.18 +Contact: linux-iio@vger.kernel.org +Description: + This sensor has an automatic gain control (agc) loop + which sets the analog signal levels at an optimum + level by controlling programmable gain amplifiers. The + criteria for optimal gain is determined by the sensor. + + Return the actual gain value as an integer in [0; 65536] + range when read from. + + The agc gain read when measuring crosstalk shall be + written into in_proximity0_agc_gain_bias. + +What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_calib_phase_temp_a +What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_calib_phase_temp_b +What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_calib_phase_light_a +What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_calib_phase_light_b +KernelVersion: 4.18 +Contact: linux-iio@vger.kernel.org +Description: + The sensor is able to perform correction of distance + measurements due to changing temperature and ambient + light conditions. It can be programmed to correct for + a second order error polynomial. + + Phase data has to be collected when temperature and + ambient light are modulated independently. + + Then a least squares curve fit to a second order + polynomial has to be generated from the data. The + resultant curves have the form ax^2 + bx + c. + + From those two curves, a and b coefficients shall be + stored in in_proximity0_calib_phase_temp_a and + in_proximity0_calib_phase_temp_b for temperature and + in in_proximity0_calib_phase_light_a and + in_proximity0_calib_phase_light_b for ambient light. + + Those values must be integer in [0; 8355840] range. + + Finally, the c constant is set by the sensor + internally. + + The value stored in sensor is displayed when read from. diff --git a/Documentation/devicetree/bindings/iio/light/isl29501.txt b/Documentation/devicetree/bindings/iio/light/isl29501.txt new file mode 100644 index 000000000000..46957997fee3 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/isl29501.txt @@ -0,0 +1,13 @@ +* ISL29501 Time-of-flight sensor. + +Required properties: + + - compatible : should be "renesas,isl29501" + - reg : the I2C address of the sensor + +Example: + +isl29501@57 { + compatible = "renesas,isl29501"; + reg = <0x57>; +}; diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig index f726f9427602..388ef70c11d2 100644 --- a/drivers/iio/proximity/Kconfig +++ b/drivers/iio/proximity/Kconfig @@ -20,6 +20,19 @@ endmenu menu "Proximity and distance sensors" +config ISL29501 + tristate "Intersil ISL29501 Time Of Flight sensor" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select IIO_KFIFO_BUF + help + Say Y here if you want to build a driver for the Intersil ISL29501 + Time of Flight sensor. + + To compile this driver as a module, choose M here: the module will be + called isl29501. + config LIDAR_LITE_V2 tristate "PulsedLight LIDAR sensor" select IIO_BUFFER diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile index 4f4ed45e87ef..cac3d7d3325e 100644 --- a/drivers/iio/proximity/Makefile +++ b/drivers/iio/proximity/Makefile @@ -5,6 +5,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_AS3935) += as3935.o +obj-$(CONFIG_ISL29501) += isl29501.o obj-$(CONFIG_LIDAR_LITE_V2) += pulsedlight-lidar-lite-v2.o obj-$(CONFIG_RFD77402) += rfd77402.o obj-$(CONFIG_SRF04) += srf04.o diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c new file mode 100644 index 000000000000..e5e94540f404 --- /dev/null +++ b/drivers/iio/proximity/isl29501.c @@ -0,0 +1,1027 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * isl29501.c: ISL29501 Time of Flight sensor driver. + * + * Copyright (C) 2018 + * Author: Mathieu Othacehe + * + * 7-bit I2C slave address: 0x57 + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* Control, setting and status registers */ +#define ISL29501_DEVICE_ID 0x00 +#define ISL29501_ID 0x0A + +/* Sampling control registers */ +#define ISL29501_INTEGRATION_PERIOD 0x10 +#define ISL29501_SAMPLE_PERIOD 0x11 + +/* Closed loop calibration registers */ +#define ISL29501_CROSSTALK_I_MSB 0x24 +#define ISL29501_CROSSTALK_I_LSB 0x25 +#define ISL29501_CROSSTALK_I_EXPONENT 0x26 +#define ISL29501_CROSSTALK_Q_MSB 0x27 +#define ISL29501_CROSSTALK_Q_LSB 0x28 +#define ISL29501_CROSSTALK_Q_EXPONENT 0x29 +#define ISL29501_CROSSTALK_GAIN_MSB 0x2A +#define ISL29501_CROSSTALK_GAIN_LSB 0x2B +#define ISL29501_MAGNITUDE_REF_EXP 0x2C +#define ISL29501_MAGNITUDE_REF_MSB 0x2D +#define ISL29501_MAGNITUDE_REF_LSB 0x2E +#define ISL29501_PHASE_OFFSET_MSB 0x2F +#define ISL29501_PHASE_OFFSET_LSB 0x30 + +/* Analog control registers */ +#define ISL29501_DRIVER_RANGE 0x90 +#define ISL29501_EMITTER_DAC 0x91 + +#define ISL29501_COMMAND_REGISTER 0xB0 + +/* Commands */ +#define ISL29501_EMUL_SAMPLE_START_PIN 0x49 +#define ISL29501_RESET_ALL_REGISTERS 0xD7 +#define ISL29501_RESET_INT_SM 0xD1 + +/* Ambiant light and temperature corrections */ +#define ISL29501_TEMP_REFERENCE 0x31 +#define ISL29501_PHASE_EXPONENT 0x33 +#define ISL29501_TEMP_COEFF_A 0x34 +#define ISL29501_TEMP_COEFF_B 0x39 +#define ISL29501_AMBIANT_COEFF_A 0x36 +#define ISL29501_AMBIANT_COEFF_B 0x3B + +/* Data output registers */ +#define ISL29501_DISTANCE_MSB_DATA 0xD1 +#define ISL29501_DISTANCE_LSB_DATA 0xD2 +#define ISL29501_PRECISION_MSB 0xD3 +#define ISL29501_PRECISION_LSB 0xD4 +#define ISL29501_MAGNITUDE_EXPONENT 0xD5 +#define ISL29501_MAGNITUDE_MSB 0xD6 +#define ISL29501_MAGNITUDE_LSB 0xD7 +#define ISL29501_PHASE_MSB 0xD8 +#define ISL29501_PHASE_LSB 0xD9 +#define ISL29501_I_RAW_EXPONENT 0xDA +#define ISL29501_I_RAW_MSB 0xDB +#define ISL29501_I_RAW_LSB 0xDC +#define ISL29501_Q_RAW_EXPONENT 0xDD +#define ISL29501_Q_RAW_MSB 0xDE +#define ISL29501_Q_RAW_LSB 0xDF +#define ISL29501_DIE_TEMPERATURE 0xE2 +#define ISL29501_AMBIENT_LIGHT 0xE3 +#define ISL29501_GAIN_MSB 0xE6 +#define ISL29501_GAIN_LSB 0xE7 + +#define ISL29501_MAX_EXP_VAL 15 + +#define ISL29501_INT_TIME_AVAILABLE \ + "0.00007 0.00014 0.00028 0.00057 0.00114 " \ + "0.00228 0.00455 0.00910 0.01820 0.03640 " \ + "0.07281 0.14561" + +#define ISL29501_CURRENT_SCALE_AVAILABLE \ + "0.0039 0.0078 0.0118 0.0157 0.0196 " \ + "0.0235 0.0275 0.0314 0.0352 0.0392 " \ + "0.0431 0.0471 0.0510 0.0549 0.0588" + +enum isl29501_correction_coeff { + COEFF_TEMP_A, + COEFF_TEMP_B, + COEFF_LIGHT_A, + COEFF_LIGHT_B, + COEFF_MAX, +}; + +struct isl29501_private { + struct i2c_client *client; + struct mutex lock; + /* Exact representation of correction coefficients. */ + unsigned int shadow_coeffs[COEFF_MAX]; +}; + +enum isl29501_register_name { + REG_DISTANCE, + REG_PHASE, + REG_TEMPERATURE, + REG_AMBIENT_LIGHT, + REG_GAIN, + REG_GAIN_BIAS, + REG_PHASE_EXP, + REG_CALIB_PHASE_TEMP_A, + REG_CALIB_PHASE_TEMP_B, + REG_CALIB_PHASE_LIGHT_A, + REG_CALIB_PHASE_LIGHT_B, + REG_DISTANCE_BIAS, + REG_TEMPERATURE_BIAS, + REG_INT_TIME, + REG_SAMPLE_TIME, + REG_DRIVER_RANGE, + REG_EMITTER_DAC, +}; + +struct isl29501_register_desc { + u8 msb; + u8 lsb; +}; + +static const struct isl29501_register_desc isl29501_registers[] = { + [REG_DISTANCE] = { + .msb = ISL29501_DISTANCE_MSB_DATA, + .lsb = ISL29501_DISTANCE_LSB_DATA, + }, + [REG_PHASE] = { + .msb = ISL29501_PHASE_MSB, + .lsb = ISL29501_PHASE_LSB, + }, + [REG_TEMPERATURE] = { + .lsb = ISL29501_DIE_TEMPERATURE, + }, + [REG_AMBIENT_LIGHT] = { + .lsb = ISL29501_AMBIENT_LIGHT, + }, + [REG_GAIN] = { + .msb = ISL29501_GAIN_MSB, + .lsb = ISL29501_GAIN_LSB, + }, + [REG_GAIN_BIAS] = { + .msb = ISL29501_CROSSTALK_GAIN_MSB, + .lsb = ISL29501_CROSSTALK_GAIN_LSB, + }, + [REG_PHASE_EXP] = { + .lsb = ISL29501_PHASE_EXPONENT, + }, + [REG_CALIB_PHASE_TEMP_A] = { + .lsb = ISL29501_TEMP_COEFF_A, + }, + [REG_CALIB_PHASE_TEMP_B] = { + .lsb = ISL29501_TEMP_COEFF_B, + }, + [REG_CALIB_PHASE_LIGHT_A] = { + .lsb = ISL29501_AMBIANT_COEFF_A, + }, + [REG_CALIB_PHASE_LIGHT_B] = { + .lsb = ISL29501_AMBIANT_COEFF_B, + }, + [REG_DISTANCE_BIAS] = { + .msb = ISL29501_PHASE_OFFSET_MSB, + .lsb = ISL29501_PHASE_OFFSET_LSB, + }, + [REG_TEMPERATURE_BIAS] = { + .lsb = ISL29501_TEMP_REFERENCE, + }, + [REG_INT_TIME] = { + .lsb = ISL29501_INTEGRATION_PERIOD, + }, + [REG_SAMPLE_TIME] = { + .lsb = ISL29501_SAMPLE_PERIOD, + }, + [REG_DRIVER_RANGE] = { + .lsb = ISL29501_DRIVER_RANGE, + }, + [REG_EMITTER_DAC] = { + .lsb = ISL29501_EMITTER_DAC, + }, +}; + +static int isl29501_register_read(struct isl29501_private *isl29501, + enum isl29501_register_name name, + u32 *val) +{ + const struct isl29501_register_desc *reg = &isl29501_registers[name]; + u8 msb = 0, lsb = 0; + s32 ret; + + mutex_lock(&isl29501->lock); + if (reg->msb) { + ret = i2c_smbus_read_byte_data(isl29501->client, reg->msb); + if (ret < 0) + goto err; + msb = ret; + } + + if (reg->lsb) { + ret = i2c_smbus_read_byte_data(isl29501->client, reg->lsb); + if (ret < 0) + goto err; + lsb = ret; + } + mutex_unlock(&isl29501->lock); + + *val = (msb << 8) + lsb; + + return 0; +err: + mutex_unlock(&isl29501->lock); + + return ret; +} + +static u32 isl29501_register_write(struct isl29501_private *isl29501, + enum isl29501_register_name name, + u32 value) +{ + const struct isl29501_register_desc *reg = &isl29501_registers[name]; + u8 msb, lsb; + int ret; + + if (!reg->msb && value > U8_MAX) + return -ERANGE; + + if (value > U16_MAX) + return -ERANGE; + + if (!reg->msb) { + lsb = value & 0xFF; + } else { + msb = (value >> 8) & 0xFF; + lsb = value & 0xFF; + } + + mutex_lock(&isl29501->lock); + if (reg->msb) { + ret = i2c_smbus_write_byte_data(isl29501->client, + reg->msb, msb); + if (ret < 0) + goto err; + } + + ret = i2c_smbus_write_byte_data(isl29501->client, reg->lsb, lsb); + +err: + mutex_unlock(&isl29501->lock); + return ret; +} + +static ssize_t isl29501_read_ext(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, + char *buf) +{ + struct isl29501_private *isl29501 = iio_priv(indio_dev); + enum isl29501_register_name reg = private; + int ret; + u32 value, gain, coeff, exp; + + switch (reg) { + case REG_GAIN: + case REG_GAIN_BIAS: + ret = isl29501_register_read(isl29501, reg, &gain); + if (ret < 0) + return ret; + + value = gain; + break; + case REG_CALIB_PHASE_TEMP_A: + case REG_CALIB_PHASE_TEMP_B: + case REG_CALIB_PHASE_LIGHT_A: + case REG_CALIB_PHASE_LIGHT_B: + ret = isl29501_register_read(isl29501, REG_PHASE_EXP, &exp); + if (ret < 0) + return ret; + + ret = isl29501_register_read(isl29501, reg, &coeff); + if (ret < 0) + return ret; + + value = coeff << exp; + break; + default: + return -EINVAL; + } + + return sprintf(buf, "%u\n", value); +} + +static int isl29501_set_shadow_coeff(struct isl29501_private *isl29501, + enum isl29501_register_name reg, + unsigned int val) +{ + enum isl29501_correction_coeff coeff; + + switch (reg) { + case REG_CALIB_PHASE_TEMP_A: + coeff = COEFF_TEMP_A; + break; + case REG_CALIB_PHASE_TEMP_B: + coeff = COEFF_TEMP_B; + break; + case REG_CALIB_PHASE_LIGHT_A: + coeff = COEFF_LIGHT_A; + break; + case REG_CALIB_PHASE_LIGHT_B: + coeff = COEFF_LIGHT_B; + break; + default: + return -EINVAL; + } + isl29501->shadow_coeffs[coeff] = val; + + return 0; +} + +static int isl29501_write_coeff(struct isl29501_private *isl29501, + enum isl29501_correction_coeff coeff, + int val) +{ + enum isl29501_register_name reg; + + switch (coeff) { + case COEFF_TEMP_A: + reg = REG_CALIB_PHASE_TEMP_A; + break; + case COEFF_TEMP_B: + reg = REG_CALIB_PHASE_TEMP_B; + break; + case COEFF_LIGHT_A: + reg = REG_CALIB_PHASE_LIGHT_A; + break; + case COEFF_LIGHT_B: + reg = REG_CALIB_PHASE_LIGHT_B; + break; + default: + return -EINVAL; + } + + return isl29501_register_write(isl29501, reg, val); +} + +static unsigned int isl29501_find_corr_exp(unsigned int val, + unsigned int max_exp, + unsigned int max_mantissa) +{ + unsigned int exp = 1; + + /* + * Correction coefficients are represented under + * mantissa * 2^exponent form, where mantissa and exponent + * are stored in two separate registers of the sensor. + * + * Compute and return the lowest exponent such as: + * mantissa = value / 2^exponent + * + * where mantissa < max_mantissa. + */ + if (val <= max_mantissa) + return 0; + + while ((val >> exp) > max_mantissa) { + exp++; + + if (exp > max_exp) + return max_exp; + } + + return exp; +} + +static ssize_t isl29501_write_ext(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, + const char *buf, size_t len) +{ + struct isl29501_private *isl29501 = iio_priv(indio_dev); + enum isl29501_register_name reg = private; + unsigned int val; + int max_exp = 0; + int ret; + int i; + + ret = kstrtouint(buf, 10, &val); + if (ret) + return ret; + + switch (reg) { + case REG_GAIN_BIAS: + if (val > U16_MAX) + return -ERANGE; + + ret = isl29501_register_write(isl29501, reg, val); + if (ret < 0) + return ret; + + break; + case REG_CALIB_PHASE_TEMP_A: + case REG_CALIB_PHASE_TEMP_B: + case REG_CALIB_PHASE_LIGHT_A: + case REG_CALIB_PHASE_LIGHT_B: + + if (val > (U8_MAX << ISL29501_MAX_EXP_VAL)) + return -ERANGE; + + /* Store the correction coefficient under its exact form. */ + ret = isl29501_set_shadow_coeff(isl29501, reg, val); + if (ret < 0) + return ret; + + /* + * Find the highest exponent needed to represent + * correction coefficients. + */ + for (i = 0; i < COEFF_MAX; i++) { + int corr; + int corr_exp; + + corr = isl29501->shadow_coeffs[i]; + corr_exp = isl29501_find_corr_exp(corr, + ISL29501_MAX_EXP_VAL, + U8_MAX / 2); + dev_dbg(&isl29501->client->dev, + "found exp of corr(%d) = %d\n", corr, corr_exp); + + max_exp = max(max_exp, corr_exp); + } + + /* + * Represent every correction coefficient under + * mantissa * 2^max_exponent form and force the + * writing of those coefficients on the sensor. + */ + for (i = 0; i < COEFF_MAX; i++) { + int corr; + int mantissa; + + corr = isl29501->shadow_coeffs[i]; + if (!corr) + continue; + + mantissa = corr >> max_exp; + + ret = isl29501_write_coeff(isl29501, i, mantissa); + if (ret < 0) + return ret; + } + + ret = isl29501_register_write(isl29501, REG_PHASE_EXP, max_exp); + if (ret < 0) + return ret; + + break; + default: + return -EINVAL; + } + + return len; +} + +#define _ISL29501_EXT_INFO(_name, _ident) { \ + .name = _name, \ + .read = isl29501_read_ext, \ + .write = isl29501_write_ext, \ + .private = _ident, \ + .shared = IIO_SEPARATE, \ +} + +static const struct iio_chan_spec_ext_info isl29501_ext_info[] = { + _ISL29501_EXT_INFO("agc_gain", REG_GAIN), + _ISL29501_EXT_INFO("agc_gain_bias", REG_GAIN_BIAS), + _ISL29501_EXT_INFO("calib_phase_temp_a", REG_CALIB_PHASE_TEMP_A), + _ISL29501_EXT_INFO("calib_phase_temp_b", REG_CALIB_PHASE_TEMP_B), + _ISL29501_EXT_INFO("calib_phase_light_a", REG_CALIB_PHASE_LIGHT_A), + _ISL29501_EXT_INFO("calib_phase_light_b", REG_CALIB_PHASE_LIGHT_B), + { }, +}; + +#define ISL29501_DISTANCE_SCAN_INDEX 0 +#define ISL29501_TIMESTAMP_SCAN_INDEX 1 + +static const struct iio_chan_spec isl29501_channels[] = { + { + .type = IIO_PROXIMITY, + .scan_index = ISL29501_DISTANCE_SCAN_INDEX, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_CALIBBIAS), + .scan_type = { + .sign = 'u', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_CPU, + }, + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SAMP_FREQ), + .ext_info = isl29501_ext_info, + }, + { + .type = IIO_PHASE, + .scan_index = -1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + }, + { + .type = IIO_CURRENT, + .scan_index = -1, + .output = 1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + }, + { + .type = IIO_TEMP, + .scan_index = -1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_CALIBBIAS), + }, + { + .type = IIO_INTENSITY, + .scan_index = -1, + .modified = 1, + .channel2 = IIO_MOD_LIGHT_CLEAR, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + }, + IIO_CHAN_SOFT_TIMESTAMP(ISL29501_TIMESTAMP_SCAN_INDEX), +}; + +static int isl29501_reset_registers(struct isl29501_private *isl29501) +{ + int ret; + + ret = i2c_smbus_write_byte_data(isl29501->client, + ISL29501_COMMAND_REGISTER, + ISL29501_RESET_ALL_REGISTERS); + if (ret < 0) { + dev_err(&isl29501->client->dev, + "cannot reset registers %d\n", ret); + return ret; + } + + ret = i2c_smbus_write_byte_data(isl29501->client, + ISL29501_COMMAND_REGISTER, + ISL29501_RESET_INT_SM); + if (ret < 0) + dev_err(&isl29501->client->dev, + "cannot reset state machine %d\n", ret); + + return ret; +} + +static int isl29501_begin_acquisition(struct isl29501_private *isl29501) +{ + int ret; + + ret = i2c_smbus_write_byte_data(isl29501->client, + ISL29501_COMMAND_REGISTER, + ISL29501_EMUL_SAMPLE_START_PIN); + if (ret < 0) + dev_err(&isl29501->client->dev, + "cannot begin acquisition %d\n", ret); + + return ret; +} + +static IIO_CONST_ATTR_INT_TIME_AVAIL(ISL29501_INT_TIME_AVAILABLE); +static IIO_CONST_ATTR(out_current_scale_available, + ISL29501_CURRENT_SCALE_AVAILABLE); + +static struct attribute *isl29501_attributes[] = { + &iio_const_attr_integration_time_available.dev_attr.attr, + &iio_const_attr_out_current_scale_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group isl29501_attribute_group = { + .attrs = isl29501_attributes, +}; + +static const int isl29501_current_scale_table[][2] = { + {0, 3900}, {0, 7800}, {0, 11800}, {0, 15700}, + {0, 19600}, {0, 23500}, {0, 27500}, {0, 31400}, + {0, 35200}, {0, 39200}, {0, 43100}, {0, 47100}, + {0, 51000}, {0, 54900}, {0, 58800}, +}; + +static const int isl29501_int_time[][2] = { + {0, 70}, /* 0.07 ms */ + {0, 140}, /* 0.14 ms */ + {0, 280}, /* 0.28 ms */ + {0, 570}, /* 0.57 ms */ + {0, 1140}, /* 1.14 ms */ + {0, 2280}, /* 2.28 ms */ + {0, 4550}, /* 4.55 ms */ + {0, 9100}, /* 9.11 ms */ + {0, 18200}, /* 18.2 ms */ + {0, 36400}, /* 36.4 ms */ + {0, 72810}, /* 72.81 ms */ + {0, 145610} /* 145.28 ms */ +}; + +static int isl29501_get_raw(struct isl29501_private *isl29501, + const struct iio_chan_spec *chan, + int *raw) +{ + int ret; + + switch (chan->type) { + case IIO_PROXIMITY: + ret = isl29501_register_read(isl29501, REG_DISTANCE, raw); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + case IIO_INTENSITY: + ret = isl29501_register_read(isl29501, + REG_AMBIENT_LIGHT, + raw); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + case IIO_PHASE: + ret = isl29501_register_read(isl29501, REG_PHASE, raw); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + case IIO_CURRENT: + ret = isl29501_register_read(isl29501, REG_EMITTER_DAC, raw); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + case IIO_TEMP: + ret = isl29501_register_read(isl29501, REG_TEMPERATURE, raw); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int isl29501_get_scale(struct isl29501_private *isl29501, + const struct iio_chan_spec *chan, + int *val, int *val2) +{ + int ret; + u32 current_scale; + + switch (chan->type) { + case IIO_PROXIMITY: + /* distance = raw_distance * 33.31 / 65536 (m) */ + *val = 3331; + *val2 = 6553600; + + return IIO_VAL_FRACTIONAL; + case IIO_PHASE: + /* phase = raw_phase * 2pi / 65536 (rad) */ + *val = 0; + *val2 = 95874; + + return IIO_VAL_INT_PLUS_NANO; + case IIO_INTENSITY: + /* light = raw_light * 35 / 10000 (mA) */ + *val = 35; + *val2 = 10000; + + return IIO_VAL_FRACTIONAL; + case IIO_CURRENT: + ret = isl29501_register_read(isl29501, + REG_DRIVER_RANGE, + ¤t_scale); + if (ret < 0) + return ret; + + if (current_scale > ARRAY_SIZE(isl29501_current_scale_table)) + return -EINVAL; + + if (!current_scale) { + *val = 0; + *val2 = 0; + return IIO_VAL_INT; + } + + *val = isl29501_current_scale_table[current_scale - 1][0]; + *val2 = isl29501_current_scale_table[current_scale - 1][1]; + + return IIO_VAL_INT_PLUS_MICRO; + case IIO_TEMP: + /* temperature = raw_temperature * 125 / 100000 (milli °C) */ + *val = 125; + *val2 = 100000; + + return IIO_VAL_FRACTIONAL; + default: + return -EINVAL; + } +} + +static int isl29501_get_calibbias(struct isl29501_private *isl29501, + const struct iio_chan_spec *chan, + int *bias) +{ + switch (chan->type) { + case IIO_PROXIMITY: + return isl29501_register_read(isl29501, + REG_DISTANCE_BIAS, + bias); + case IIO_TEMP: + return isl29501_register_read(isl29501, + REG_TEMPERATURE_BIAS, + bias); + default: + return -EINVAL; + } +} + +static int isl29501_get_inttime(struct isl29501_private *isl29501, + int *val, int *val2) +{ + int ret; + u32 inttime; + + ret = isl29501_register_read(isl29501, REG_INT_TIME, &inttime); + if (ret < 0) + return ret; + + if (inttime >= ARRAY_SIZE(isl29501_int_time)) + return -EINVAL; + + *val = isl29501_int_time[inttime][0]; + *val2 = isl29501_int_time[inttime][1]; + + return IIO_VAL_INT_PLUS_MICRO; +} + +static int isl29501_get_freq(struct isl29501_private *isl29501, + int *val, int *val2) +{ + int ret; + int sample_time; + unsigned long long freq; + u32 temp; + + ret = isl29501_register_read(isl29501, REG_SAMPLE_TIME, &sample_time); + if (ret < 0) + return ret; + + /* freq = 1 / (0.000450 * (sample_time + 1) * 10^-6) */ + freq = 1000000ULL * 1000000ULL; + + do_div(freq, 450 * (sample_time + 1)); + + temp = do_div(freq, 1000000); + *val = freq; + *val2 = temp; + + return IIO_VAL_INT_PLUS_MICRO; +} + +static int isl29501_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct isl29501_private *isl29501 = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + return isl29501_get_raw(isl29501, chan, val); + case IIO_CHAN_INFO_SCALE: + return isl29501_get_scale(isl29501, chan, val, val2); + case IIO_CHAN_INFO_INT_TIME: + return isl29501_get_inttime(isl29501, val, val2); + case IIO_CHAN_INFO_SAMP_FREQ: + return isl29501_get_freq(isl29501, val, val2); + case IIO_CHAN_INFO_CALIBBIAS: + return isl29501_get_calibbias(isl29501, chan, val); + default: + return -EINVAL; + } +} + +static int isl29501_set_raw(struct isl29501_private *isl29501, + const struct iio_chan_spec *chan, + int raw) +{ + switch (chan->type) { + case IIO_CURRENT: + return isl29501_register_write(isl29501, REG_EMITTER_DAC, raw); + default: + return -EINVAL; + } +} + +static int isl29501_set_inttime(struct isl29501_private *isl29501, + int val, int val2) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(isl29501_int_time); i++) { + if (isl29501_int_time[i][0] == val && + isl29501_int_time[i][1] == val2) { + return isl29501_register_write(isl29501, + REG_INT_TIME, + i); + } + } + + return -EINVAL; +} + +static int isl29501_set_scale(struct isl29501_private *isl29501, + const struct iio_chan_spec *chan, + int val, int val2) +{ + int i; + + if (chan->type != IIO_CURRENT) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(isl29501_current_scale_table); i++) { + if (isl29501_current_scale_table[i][0] == val && + isl29501_current_scale_table[i][1] == val2) { + return isl29501_register_write(isl29501, + REG_DRIVER_RANGE, + i + 1); + } + } + + return -EINVAL; +} + +static int isl29501_set_calibbias(struct isl29501_private *isl29501, + const struct iio_chan_spec *chan, + int bias) +{ + switch (chan->type) { + case IIO_PROXIMITY: + return isl29501_register_write(isl29501, + REG_DISTANCE_BIAS, + bias); + case IIO_TEMP: + return isl29501_register_write(isl29501, + REG_TEMPERATURE_BIAS, + bias); + default: + return -EINVAL; + } +} + +static int isl29501_set_freq(struct isl29501_private *isl29501, + int val, int val2) +{ + int freq; + unsigned long long sample_time; + + /* sample_freq = 1 / (0.000450 * (sample_time + 1) * 10^-6) */ + freq = val * 1000000 + val2 % 1000000; + sample_time = 2222ULL * 1000000ULL; + do_div(sample_time, freq); + + sample_time -= 1; + + if (sample_time > 255) + return -ERANGE; + + return isl29501_register_write(isl29501, REG_SAMPLE_TIME, sample_time); +} + +static int isl29501_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct isl29501_private *isl29501 = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + return isl29501_set_raw(isl29501, chan, val); + case IIO_CHAN_INFO_INT_TIME: + return isl29501_set_inttime(isl29501, val, val2); + case IIO_CHAN_INFO_SAMP_FREQ: + return isl29501_set_freq(isl29501, val, val2); + case IIO_CHAN_INFO_SCALE: + return isl29501_set_scale(isl29501, chan, val, val2); + case IIO_CHAN_INFO_CALIBBIAS: + return isl29501_set_calibbias(isl29501, chan, val); + default: + return -EINVAL; + } +} + +static const struct iio_info isl29501_info = { + .read_raw = &isl29501_read_raw, + .write_raw = &isl29501_write_raw, + .attrs = &isl29501_attribute_group, +}; + +static int isl29501_init_chip(struct isl29501_private *isl29501) +{ + int ret; + + ret = i2c_smbus_read_byte_data(isl29501->client, ISL29501_DEVICE_ID); + if (ret < 0) { + dev_err(&isl29501->client->dev, "Error reading device id\n"); + return ret; + } + + if (ret != ISL29501_ID) { + dev_err(&isl29501->client->dev, + "Wrong chip id, got %x expected %x\n", + ret, ISL29501_DEVICE_ID); + return -ENODEV; + } + + ret = isl29501_reset_registers(isl29501); + if (ret < 0) + return ret; + + return isl29501_begin_acquisition(isl29501); +} + +static irqreturn_t isl29501_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct isl29501_private *isl29501 = iio_priv(indio_dev); + const unsigned long *active_mask = indio_dev->active_scan_mask; + u32 buffer[4] = {}; /* 1x16-bit + ts */ + + if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) + isl29501_register_read(isl29501, REG_DISTANCE, buffer); + + iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp); + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static int isl29501_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct iio_dev *indio_dev; + struct isl29501_private *isl29501; + int ret; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*isl29501)); + if (!indio_dev) + return -ENOMEM; + + isl29501 = iio_priv(indio_dev); + + i2c_set_clientdata(client, indio_dev); + isl29501->client = client; + + mutex_init(&isl29501->lock); + + ret = isl29501_init_chip(isl29501); + if (ret < 0) + return ret; + + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->dev.parent = &client->dev; + indio_dev->channels = isl29501_channels; + indio_dev->num_channels = ARRAY_SIZE(isl29501_channels); + indio_dev->name = client->name; + indio_dev->info = &isl29501_info; + + ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, + iio_pollfunc_store_time, + isl29501_trigger_handler, + NULL); + if (ret < 0) { + dev_err(&client->dev, "unable to setup iio triggered buffer\n"); + return ret; + } + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id isl29501_id[] = { + {"isl29501", 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, isl29501_id); + +#if defined(CONFIG_OF) +static const struct of_device_id isl29501_i2c_matches[] = { + { .compatible = "renesas,isl29501" }, + { } +}; +MODULE_DEVICE_TABLE(of, isl29501_i2c_matches); +#endif + +static struct i2c_driver isl29501_driver = { + .driver = { + .name = "isl29501", + }, + .id_table = isl29501_id, + .probe = isl29501_probe, +}; +module_i2c_driver(isl29501_driver); + +MODULE_AUTHOR("Mathieu Othacehe "); +MODULE_DESCRIPTION("ISL29501 Time of Flight sensor driver"); +MODULE_LICENSE("GPL v2"); From c0e4e0fd952b73bf6aae67e92b9a496a52837eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Roussin-B=C3=A9langer?= Date: Thu, 19 Jul 2018 16:26:24 -0400 Subject: [PATCH 493/903] iio: Add modifier for DUV light MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime Roussin-Bélanger Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++-- drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + tools/iio/iio_event_monitor.c | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index c9cfa833cf47..a5b4f223641d 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1307,13 +1307,16 @@ What: /sys/.../iio:deviceX/in_intensityY_raw What: /sys/.../iio:deviceX/in_intensityY_ir_raw What: /sys/.../iio:deviceX/in_intensityY_both_raw What: /sys/.../iio:deviceX/in_intensityY_uv_raw +What: /sys/.../iio:deviceX/in_intensityY_duv_raw KernelVersion: 3.4 Contact: linux-iio@vger.kernel.org Description: Unit-less light intensity. Modifiers both and ir indicate that measurements contain visible and infrared light - components or just infrared light, respectively. Modifier uv indicates - that measurements contain ultraviolet light components. + components or just infrared light, respectively. Modifier + uv indicates that measurements contain ultraviolet light + components. Modifier duv indicates that measurements + contain deep ultraviolet light components. What: /sys/.../iio:deviceX/in_uvindex_input KernelVersion: 4.6 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index a16ad5a4ab0c..a062cfddc5af 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -110,6 +110,7 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", [IIO_MOD_LIGHT_UV] = "uv", + [IIO_MOD_LIGHT_DUV] = "duv", [IIO_MOD_QUATERNION] = "quaternion", [IIO_MOD_TEMP_AMBIENT] = "ambient", [IIO_MOD_TEMP_OBJECT] = "object", diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index e4df3cc268db..92baabc103ac 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -86,6 +86,7 @@ enum iio_modifier { IIO_MOD_CO2, IIO_MOD_VOC, IIO_MOD_LIGHT_UV, + IIO_MOD_LIGHT_DUV, }; enum iio_event_type { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index f478f5558720..ac2de6b7e89f 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -98,6 +98,7 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", [IIO_MOD_LIGHT_UV] = "uv", + [IIO_MOD_LIGHT_DUV] = "duv", [IIO_MOD_QUATERNION] = "quaternion", [IIO_MOD_TEMP_AMBIENT] = "ambient", [IIO_MOD_TEMP_OBJECT] = "object", @@ -182,6 +183,7 @@ static bool event_is_known(struct iio_event_data *event) case IIO_MOD_LIGHT_GREEN: case IIO_MOD_LIGHT_BLUE: case IIO_MOD_LIGHT_UV: + case IIO_MOD_LIGHT_DUV: case IIO_MOD_QUATERNION: case IIO_MOD_TEMP_AMBIENT: case IIO_MOD_TEMP_OBJECT: From e01e7eaf37d865c72e2501a7b09e7a61317ce2d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Roussin-B=C3=A9langer?= Date: Thu, 19 Jul 2018 16:26:25 -0400 Subject: [PATCH 494/903] iio: light: introduce si1133 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e-mail received from Silicon Lab to confirm that the licensing isn't a problem. " Dear Maxime Roussin-Belanger, The LUX calculation code only works with Si1133. As long as the software is used with Silicon Lab's sensor product, I don't see any problem. Regards, Tony " Signed-off-by: Maxime Roussin-Bélanger Reviewed-by: Jean-Francois Dagenais Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-light-si1133 | 22 + drivers/iio/light/Kconfig | 12 + drivers/iio/light/Makefile | 1 + drivers/iio/light/si1133.c | 1068 +++++++++++++++++ 4 files changed, 1103 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-light-si1133 create mode 100644 drivers/iio/light/si1133.c diff --git a/Documentation/ABI/testing/sysfs-bus-iio-light-si1133 b/Documentation/ABI/testing/sysfs-bus-iio-light-si1133 new file mode 100644 index 000000000000..6f130cdb26a6 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-light-si1133 @@ -0,0 +1,22 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_ir_small_raw +KernelVersion: 4.18 +Contact: linux-iio@vger.kernel.org +Description: + Unit-less infrared intensity. The intensity is measured from 1 + dark photodiode. "small" indicate the surface area capturing + infrared. + +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_ir_large_raw +KernelVersion: 4.18 +Contact: linux-iio@vger.kernel.org +Description: + Unit-less infrared intensity. The intensity is measured from 4 + dark photodiodes. "large" indicate the surface area capturing + infrared. + +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_large_raw +KernelVersion: 4.18 +Contact: linux-iio@vger.kernel.org +Description: + Unit-less light intensity with more diodes. + diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index c7ef8d1862d6..f17f701a9b61 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -1,3 +1,4 @@ + # # Light sensors # @@ -319,6 +320,17 @@ config PA12203001 This driver can also be built as a module. If so, the module will be called pa12203001. +config SI1133 + tristate "SI1133 UV Index Sensor and Ambient Light Sensor" + depends on I2C + select REGMAP_I2C + help + Say Y here if you want to build a driver for the Silicon Labs SI1133 + UV Index Sensor and Ambient Light Sensor chip. + + To compile this driver as a module, choose M here: the module will be + called si1133. + config SI1145 tristate "SI1132 and SI1141/2/3/5/6/7 combined ALS, UV index and proximity sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 80943af5d627..86337b114bc4 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_OPT3001) += opt3001.o obj-$(CONFIG_PA12203001) += pa12203001.o obj-$(CONFIG_RPR0521) += rpr0521.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o +obj-$(CONFIG_SI1133) += si1133.o obj-$(CONFIG_SI1145) += si1145.o obj-$(CONFIG_STK3310) += stk3310.o obj-$(CONFIG_ST_UVIS25) += st_uvis25_core.o diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c new file mode 100644 index 000000000000..d3fbeb3bc463 --- /dev/null +++ b/drivers/iio/light/si1133.c @@ -0,0 +1,1068 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * si1133.c - Support for Silabs SI1133 combined ambient + * light and UV index sensors + * + * Copyright 2018 Maxime Roussin-Belanger + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define SI1133_REG_PART_ID 0x00 +#define SI1133_REG_REV_ID 0x01 +#define SI1133_REG_MFR_ID 0x02 +#define SI1133_REG_INFO0 0x03 +#define SI1133_REG_INFO1 0x04 + +#define SI1133_PART_ID 0x33 + +#define SI1133_REG_HOSTIN0 0x0A +#define SI1133_REG_COMMAND 0x0B +#define SI1133_REG_IRQ_ENABLE 0x0F +#define SI1133_REG_RESPONSE1 0x10 +#define SI1133_REG_RESPONSE0 0x11 +#define SI1133_REG_IRQ_STATUS 0x12 +#define SI1133_REG_MEAS_RATE 0x1A + +#define SI1133_IRQ_CHANNEL_ENABLE 0xF + +#define SI1133_CMD_RESET_CTR 0x00 +#define SI1133_CMD_RESET_SW 0x01 +#define SI1133_CMD_FORCE 0x11 +#define SI1133_CMD_START_AUTONOMOUS 0x13 +#define SI1133_CMD_PARAM_SET 0x80 +#define SI1133_CMD_PARAM_QUERY 0x40 +#define SI1133_CMD_PARAM_MASK 0x3F + +#define SI1133_CMD_ERR_MASK BIT(4) +#define SI1133_CMD_SEQ_MASK 0xF +#define SI1133_MAX_CMD_CTR 0xF + +#define SI1133_PARAM_REG_CHAN_LIST 0x01 +#define SI1133_PARAM_REG_ADCCONFIG(x) ((x) * 4) + 2 +#define SI1133_PARAM_REG_ADCSENS(x) ((x) * 4) + 3 +#define SI1133_PARAM_REG_ADCPOST(x) ((x) * 4) + 4 + +#define SI1133_ADCMUX_MASK 0x1F + +#define SI1133_ADCCONFIG_DECIM_RATE(x) (x) << 5 + +#define SI1133_ADCSENS_SCALE_MASK 0x70 +#define SI1133_ADCSENS_SCALE_SHIFT 4 +#define SI1133_ADCSENS_HSIG_MASK BIT(7) +#define SI1133_ADCSENS_HSIG_SHIFT 7 +#define SI1133_ADCSENS_HW_GAIN_MASK 0xF +#define SI1133_ADCSENS_NB_MEAS(x) fls(x) << SI1133_ADCSENS_SCALE_SHIFT + +#define SI1133_ADCPOST_24BIT_EN BIT(6) +#define SI1133_ADCPOST_POSTSHIFT_BITQTY(x) (x & GENMASK(2, 0)) << 3 + +#define SI1133_PARAM_ADCMUX_SMALL_IR 0x0 +#define SI1133_PARAM_ADCMUX_MED_IR 0x1 +#define SI1133_PARAM_ADCMUX_LARGE_IR 0x2 +#define SI1133_PARAM_ADCMUX_WHITE 0xB +#define SI1133_PARAM_ADCMUX_LARGE_WHITE 0xD +#define SI1133_PARAM_ADCMUX_UV 0x18 +#define SI1133_PARAM_ADCMUX_UV_DEEP 0x19 + +#define SI1133_ERR_INVALID_CMD 0x0 +#define SI1133_ERR_INVALID_LOCATION_CMD 0x1 +#define SI1133_ERR_SATURATION_ADC_OR_OVERFLOW_ACCUMULATION 0x2 +#define SI1133_ERR_OUTPUT_BUFFER_OVERFLOW 0x3 + +#define SI1133_COMPLETION_TIMEOUT_MS 500 + +#define SI1133_CMD_MINSLEEP_US_LOW 5000 +#define SI1133_CMD_MINSLEEP_US_HIGH 7500 +#define SI1133_CMD_TIMEOUT_MS 25 +#define SI1133_CMD_LUX_TIMEOUT_MS 5000 +#define SI1133_CMD_TIMEOUT_US SI1133_CMD_TIMEOUT_MS * 1000 + +#define SI1133_REG_HOSTOUT(x) (x) + 0x13 + +#define SI1133_MEASUREMENT_FREQUENCY 1250 + +#define SI1133_X_ORDER_MASK 0x0070 +#define SI1133_Y_ORDER_MASK 0x0007 +#define si1133_get_x_order(m) ((m) & SI1133_X_ORDER_MASK) >> 4 +#define si1133_get_y_order(m) ((m) & SI1133_Y_ORDER_MASK) + +#define SI1133_LUX_ADC_MASK 0xE +#define SI1133_ADC_THRESHOLD 16000 +#define SI1133_INPUT_FRACTION_HIGH 7 +#define SI1133_INPUT_FRACTION_LOW 15 +#define SI1133_LUX_OUTPUT_FRACTION 12 +#define SI1133_LUX_BUFFER_SIZE 9 + +static const int si1133_scale_available[] = { + 1, 2, 4, 8, 16, 32, 64, 128}; + +static IIO_CONST_ATTR(scale_available, "1 2 4 8 16 32 64 128"); + +static IIO_CONST_ATTR_INT_TIME_AVAIL("0.0244 0.0488 0.0975 0.195 0.390 0.780 " + "1.560 3.120 6.24 12.48 25.0 50.0"); + +/* A.K.A. HW_GAIN in datasheet */ +enum si1133_int_time { + _24_4_us = 0, + _48_8_us = 1, + _97_5_us = 2, + _195_0_us = 3, + _390_0_us = 4, + _780_0_us = 5, + _1_560_0_us = 6, + _3_120_0_us = 7, + _6_240_0_us = 8, + _12_480_0_us = 9, + _25_ms = 10, + _50_ms = 11, +}; + +/* Integration time in milliseconds, nanoseconds */ +static const int si1133_int_time_table[][2] = { + [_24_4_us] = {0, 24400}, + [_48_8_us] = {0, 48800}, + [_97_5_us] = {0, 97500}, + [_195_0_us] = {0, 195000}, + [_390_0_us] = {0, 390000}, + [_780_0_us] = {0, 780000}, + [_1_560_0_us] = {1, 560000}, + [_3_120_0_us] = {3, 120000}, + [_6_240_0_us] = {6, 240000}, + [_12_480_0_us] = {12, 480000}, + [_25_ms] = {25, 000000}, + [_50_ms] = {50, 000000}, +}; + +static const struct regmap_range si1133_reg_ranges[] = { + regmap_reg_range(0x00, 0x02), + regmap_reg_range(0x0A, 0x0B), + regmap_reg_range(0x0F, 0x0F), + regmap_reg_range(0x10, 0x12), + regmap_reg_range(0x13, 0x2C), +}; + +static const struct regmap_range si1133_reg_ro_ranges[] = { + regmap_reg_range(0x00, 0x02), + regmap_reg_range(0x10, 0x2C), +}; + +static const struct regmap_range si1133_precious_ranges[] = { + regmap_reg_range(0x12, 0x12), +}; + +static const struct regmap_access_table si1133_write_ranges_table = { + .yes_ranges = si1133_reg_ranges, + .n_yes_ranges = ARRAY_SIZE(si1133_reg_ranges), + .no_ranges = si1133_reg_ro_ranges, + .n_no_ranges = ARRAY_SIZE(si1133_reg_ro_ranges), +}; + +static const struct regmap_access_table si1133_read_ranges_table = { + .yes_ranges = si1133_reg_ranges, + .n_yes_ranges = ARRAY_SIZE(si1133_reg_ranges), +}; + +static const struct regmap_access_table si1133_precious_table = { + .yes_ranges = si1133_precious_ranges, + .n_yes_ranges = ARRAY_SIZE(si1133_precious_ranges), +}; + +static const struct regmap_config si1133_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = 0x2C, + + .wr_table = &si1133_write_ranges_table, + .rd_table = &si1133_read_ranges_table, + + .precious_table = &si1133_precious_table, +}; + +struct si1133_data { + struct regmap *regmap; + struct i2c_client *client; + + /* Lock protecting one command at a time can be processed */ + struct mutex mutex; + + int rsp_seq; + u8 scan_mask; + u8 adc_sens[6]; + u8 adc_config[6]; + + struct completion completion; +}; + +struct si1133_coeff { + s16 info; + u16 mag; +}; + +struct si1133_lux_coeff { + struct si1133_coeff coeff_high[4]; + struct si1133_coeff coeff_low[9]; +}; + +static const struct si1133_lux_coeff lux_coeff = { + { + { 0, 209}, + { 1665, 93}, + { 2064, 65}, + {-2671, 234} + }, + { + { 0, 0}, + { 1921, 29053}, + {-1022, 36363}, + { 2320, 20789}, + { -367, 57909}, + {-1774, 38240}, + { -608, 46775}, + {-1503, 51831}, + {-1886, 58928} + } +}; + +static int si1133_calculate_polynomial_inner(u32 input, u8 fraction, u16 mag, + s8 shift) +{ + return ((input << fraction) / mag) << shift; +} + +static int si1133_calculate_output(u32 x, u32 y, u8 x_order, u8 y_order, + u8 input_fraction, s8 sign, + const struct si1133_coeff *coeffs) +{ + s8 shift; + int x1 = 1; + int x2 = 1; + int y1 = 1; + int y2 = 1; + + shift = ((u16)coeffs->info & 0xFF00) >> 8; + shift ^= 0xFF; + shift += 1; + shift = -shift; + + if (x_order > 0) { + x1 = si1133_calculate_polynomial_inner(x, input_fraction, + coeffs->mag, shift); + if (x_order > 1) + x2 = x1; + } + + if (y_order > 0) { + y1 = si1133_calculate_polynomial_inner(y, input_fraction, + coeffs->mag, shift); + if (y_order > 1) + y2 = y1; + } + + return sign * x1 * x2 * y1 * y2; +} + +/* + * The algorithm is from: + * https://siliconlabs.github.io/Gecko_SDK_Doc/efm32zg/html/si1133_8c_source.html#l00716 + */ +static int si1133_calc_polynomial(u32 x, u32 y, u8 input_fraction, u8 num_coeff, + const struct si1133_coeff *coeffs) +{ + u8 x_order, y_order; + u8 counter; + s8 sign; + int output = 0; + + for (counter = 0; counter < num_coeff; counter++) { + if (coeffs->info < 0) + sign = -1; + else + sign = 1; + + x_order = si1133_get_x_order(coeffs->info); + y_order = si1133_get_y_order(coeffs->info); + + if ((x_order == 0) && (y_order == 0)) + output += + sign * coeffs->mag << SI1133_LUX_OUTPUT_FRACTION; + else + output += si1133_calculate_output(x, y, x_order, + y_order, + input_fraction, sign, + coeffs); + coeffs++; + } + + return abs(output); +} + +static int si1133_cmd_reset_sw(struct si1133_data *data) +{ + struct device *dev = &data->client->dev; + unsigned int resp; + unsigned long timeout; + int err; + + err = regmap_write(data->regmap, SI1133_REG_COMMAND, + SI1133_CMD_RESET_SW); + if (err) + return err; + + timeout = jiffies + msecs_to_jiffies(SI1133_CMD_TIMEOUT_MS); + while (true) { + err = regmap_read(data->regmap, SI1133_REG_RESPONSE0, &resp); + if (err == -ENXIO) { + usleep_range(SI1133_CMD_MINSLEEP_US_LOW, + SI1133_CMD_MINSLEEP_US_HIGH); + continue; + } + + if ((resp & SI1133_MAX_CMD_CTR) == SI1133_MAX_CMD_CTR) + break; + + if (time_after(jiffies, timeout)) { + dev_warn(dev, "Timeout on reset ctr resp: %d\n", resp); + return -ETIMEDOUT; + } + } + + if (!err) + data->rsp_seq = SI1133_MAX_CMD_CTR; + + return err; +} + +static int si1133_parse_response_err(struct device *dev, u32 resp, u8 cmd) +{ + resp &= 0xF; + + switch (resp) { + case SI1133_ERR_OUTPUT_BUFFER_OVERFLOW: + dev_warn(dev, "Output buffer overflow: %#02hhx\n", cmd); + return -EOVERFLOW; + case SI1133_ERR_SATURATION_ADC_OR_OVERFLOW_ACCUMULATION: + dev_warn(dev, "Saturation of the ADC or overflow of accumulation: %#02hhx\n", + cmd); + return -EOVERFLOW; + case SI1133_ERR_INVALID_LOCATION_CMD: + dev_warn(dev, + "Parameter access to an invalid location: %#02hhx\n", + cmd); + return -EINVAL; + case SI1133_ERR_INVALID_CMD: + dev_warn(dev, "Invalid command %#02hhx\n", cmd); + return -EINVAL; + default: + dev_warn(dev, "Unknown error %#02hhx\n", cmd); + return -EINVAL; + } +} + +static int si1133_cmd_reset_counter(struct si1133_data *data) +{ + int err = regmap_write(data->regmap, SI1133_REG_COMMAND, + SI1133_CMD_RESET_CTR); + if (err) + return err; + + data->rsp_seq = 0; + + return 0; +} + +static int si1133_command(struct si1133_data *data, u8 cmd) +{ + struct device *dev = &data->client->dev; + u32 resp; + int err; + int expected_seq; + + mutex_lock(&data->mutex); + + expected_seq = (data->rsp_seq + 1) & SI1133_MAX_CMD_CTR; + + if (cmd == SI1133_CMD_FORCE) + reinit_completion(&data->completion); + + err = regmap_write(data->regmap, SI1133_REG_COMMAND, cmd); + if (err) { + dev_warn(dev, "Failed to write command %#02hhx, ret=%d\n", cmd, + err); + goto out; + } + + if (cmd == SI1133_CMD_FORCE) { + /* wait for irq */ + if (!wait_for_completion_timeout(&data->completion, + msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS))) { + err = -ETIMEDOUT; + goto out; + } + } else { + err = regmap_read_poll_timeout(data->regmap, + SI1133_REG_RESPONSE0, resp, + (resp & SI1133_CMD_SEQ_MASK) == + expected_seq || + (resp & SI1133_CMD_ERR_MASK), + SI1133_CMD_MINSLEEP_US_LOW, + SI1133_CMD_TIMEOUT_MS * 1000); + if (err) { + dev_warn(dev, + "Failed to read command %#02hhx, ret=%d\n", + cmd, err); + goto out; + } + } + + if (resp & SI1133_CMD_ERR_MASK) { + err = si1133_parse_response_err(dev, resp, cmd); + si1133_cmd_reset_counter(data); + } else { + data->rsp_seq = expected_seq; + } + +out: + mutex_unlock(&data->mutex); + + return err; +} + +static int si1133_param_set(struct si1133_data *data, u8 param, u32 value) +{ + int err = regmap_write(data->regmap, SI1133_REG_HOSTIN0, value); + + if (err) + return err; + + return si1133_command(data, SI1133_CMD_PARAM_SET | + (param & SI1133_CMD_PARAM_MASK)); +} + +static int si1133_param_query(struct si1133_data *data, u8 param, u32 *result) +{ + int err = si1133_command(data, SI1133_CMD_PARAM_QUERY | + (param & SI1133_CMD_PARAM_MASK)); + if (err) + return err; + + return regmap_read(data->regmap, SI1133_REG_RESPONSE1, result); +} + +#define SI1133_CHANNEL(_ch, _type) \ + .type = _type, \ + .channel = _ch, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_HARDWAREGAIN), \ + +static const struct iio_chan_spec si1133_channels[] = { + { + .type = IIO_LIGHT, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .channel = 0, + }, + { + SI1133_CHANNEL(SI1133_PARAM_ADCMUX_WHITE, IIO_INTENSITY) + .channel2 = IIO_MOD_LIGHT_BOTH, + }, + { + SI1133_CHANNEL(SI1133_PARAM_ADCMUX_LARGE_WHITE, IIO_INTENSITY) + .channel2 = IIO_MOD_LIGHT_BOTH, + .extend_name = "large", + }, + { + SI1133_CHANNEL(SI1133_PARAM_ADCMUX_SMALL_IR, IIO_INTENSITY) + .extend_name = "small", + .modified = 1, + .channel2 = IIO_MOD_LIGHT_IR, + }, + { + SI1133_CHANNEL(SI1133_PARAM_ADCMUX_MED_IR, IIO_INTENSITY) + .modified = 1, + .channel2 = IIO_MOD_LIGHT_IR, + }, + { + SI1133_CHANNEL(SI1133_PARAM_ADCMUX_LARGE_IR, IIO_INTENSITY) + .extend_name = "large", + .modified = 1, + .channel2 = IIO_MOD_LIGHT_IR, + }, + { + SI1133_CHANNEL(SI1133_PARAM_ADCMUX_UV, IIO_UVINDEX) + }, + { + SI1133_CHANNEL(SI1133_PARAM_ADCMUX_UV_DEEP, IIO_UVINDEX) + .modified = 1, + .channel2 = IIO_MOD_LIGHT_DUV, + } +}; + +static int si1133_get_int_time_index(int milliseconds, int nanoseconds) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(si1133_int_time_table); i++) { + if (milliseconds == si1133_int_time_table[i][0] && + nanoseconds == si1133_int_time_table[i][1]) + return i; + } + return -EINVAL; +} + +static int si1133_set_integration_time(struct si1133_data *data, u8 adc, + int milliseconds, int nanoseconds) +{ + int index; + + index = si1133_get_int_time_index(milliseconds, nanoseconds); + if (index < 0) + return index; + + data->adc_sens[adc] &= 0xF0; + data->adc_sens[adc] |= index; + + return si1133_param_set(data, SI1133_PARAM_REG_ADCSENS(0), + data->adc_sens[adc]); +} + +static int si1133_set_chlist(struct si1133_data *data, u8 scan_mask) +{ + /* channel list already set, no need to reprogram */ + if (data->scan_mask == scan_mask) + return 0; + + data->scan_mask = scan_mask; + + return si1133_param_set(data, SI1133_PARAM_REG_CHAN_LIST, scan_mask); +} + +static int si1133_chan_set_adcconfig(struct si1133_data *data, u8 adc, + u8 adc_config) +{ + int err; + + err = si1133_param_set(data, SI1133_PARAM_REG_ADCCONFIG(adc), + adc_config); + if (err) + return err; + + data->adc_config[adc] = adc_config; + + return 0; +} + +static int si1133_update_adcconfig(struct si1133_data *data, uint8_t adc, + u8 mask, u8 shift, u8 value) +{ + u32 adc_config; + int err; + + err = si1133_param_query(data, SI1133_PARAM_REG_ADCCONFIG(adc), + &adc_config); + if (err) + return err; + + adc_config &= ~mask; + adc_config |= (value << shift); + + return si1133_chan_set_adcconfig(data, adc, adc_config); +} + +static int si1133_set_adcmux(struct si1133_data *data, u8 adc, u8 mux) +{ + if ((mux & data->adc_config[adc]) == mux) + return 0; /* mux already set to correct value */ + + return si1133_update_adcconfig(data, adc, SI1133_ADCMUX_MASK, 0, mux); +} + +static int si1133_force_measurement(struct si1133_data *data) +{ + return si1133_command(data, SI1133_CMD_FORCE); +} + +static int si1133_bulk_read(struct si1133_data *data, u8 start_reg, u8 length, + u8 *buffer) +{ + int err; + + err = si1133_force_measurement(data); + if (err) + return err; + + return regmap_bulk_read(data->regmap, start_reg, buffer, length); +} + +static int si1133_measure(struct si1133_data *data, + struct iio_chan_spec const *chan, + int *val) +{ + int err; + + __be16 resp; + + err = si1133_set_adcmux(data, 0, chan->channel); + if (err) + return err; + + /* Deactivate lux measurements if they were active */ + err = si1133_set_chlist(data, BIT(0)); + if (err) + return err; + + err = si1133_bulk_read(data, SI1133_REG_HOSTOUT(0), sizeof(resp), + (u8 *)&resp); + if (err) + return err; + + *val = be16_to_cpu(resp); + + return err; +} + +static irqreturn_t si1133_threaded_irq_handler(int irq, void *private) +{ + struct iio_dev *iio_dev = private; + struct si1133_data *data = iio_priv(iio_dev); + u32 irq_status; + int err; + + err = regmap_read(data->regmap, SI1133_REG_IRQ_STATUS, &irq_status); + if (err) { + dev_err_ratelimited(&iio_dev->dev, "Error reading IRQ\n"); + goto out; + } + + if (irq_status != data->scan_mask) + return IRQ_NONE; + +out: + complete(&data->completion); + + return IRQ_HANDLED; +} + +static int si1133_scale_to_swgain(int scale_integer, int scale_fractional) +{ + scale_integer = find_closest(scale_integer, si1133_scale_available, + ARRAY_SIZE(si1133_scale_available)); + if (scale_integer < 0 || + scale_integer > ARRAY_SIZE(si1133_scale_available) || + scale_fractional != 0) + return -EINVAL; + + return scale_integer; +} + +static int si1133_chan_set_adcsens(struct si1133_data *data, u8 adc, + u8 adc_sens) +{ + int err; + + err = si1133_param_set(data, SI1133_PARAM_REG_ADCSENS(adc), adc_sens); + if (err) + return err; + + data->adc_sens[adc] = adc_sens; + + return 0; +} + +static int si1133_update_adcsens(struct si1133_data *data, u8 mask, + u8 shift, u8 value) +{ + int err; + u32 adc_sens; + + err = si1133_param_query(data, SI1133_PARAM_REG_ADCSENS(0), + &adc_sens); + if (err) + return err; + + adc_sens &= ~mask; + adc_sens |= (value << shift); + + return si1133_chan_set_adcsens(data, 0, adc_sens); +} + +static int si1133_get_lux(struct si1133_data *data, int *val) +{ + int err; + int lux; + u32 high_vis; + u32 low_vis; + u32 ir; + u8 buffer[SI1133_LUX_BUFFER_SIZE]; + + /* Activate lux channels */ + err = si1133_set_chlist(data, SI1133_LUX_ADC_MASK); + if (err) + return err; + + err = si1133_bulk_read(data, SI1133_REG_HOSTOUT(0), + SI1133_LUX_BUFFER_SIZE, buffer); + if (err) + return err; + + high_vis = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2]; + low_vis = (buffer[3] << 16) | (buffer[4] << 8) | buffer[5]; + ir = (buffer[6] << 16) | (buffer[7] << 8) | buffer[8]; + + if (high_vis > SI1133_ADC_THRESHOLD || ir > SI1133_ADC_THRESHOLD) + lux = si1133_calc_polynomial(high_vis, ir, + SI1133_INPUT_FRACTION_HIGH, + ARRAY_SIZE(lux_coeff.coeff_high), + &lux_coeff.coeff_high[0]); + else + lux = si1133_calc_polynomial(low_vis, ir, + SI1133_INPUT_FRACTION_LOW, + ARRAY_SIZE(lux_coeff.coeff_low), + &lux_coeff.coeff_low[0]); + + *val = lux >> SI1133_LUX_OUTPUT_FRACTION; + + return err; +} + +static int si1133_read_raw(struct iio_dev *iio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct si1133_data *data = iio_priv(iio_dev); + u8 adc_sens = data->adc_sens[0]; + int err; + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + switch (chan->type) { + case IIO_LIGHT: + err = si1133_get_lux(data, val); + if (err) + return err; + + return IIO_VAL_INT; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_RAW: + switch (chan->type) { + case IIO_INTENSITY: + case IIO_UVINDEX: + err = si1133_measure(data, chan, val); + if (err) + return err; + + return IIO_VAL_INT; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_INT_TIME: + switch (chan->type) { + case IIO_INTENSITY: + case IIO_UVINDEX: + adc_sens &= SI1133_ADCSENS_HW_GAIN_MASK; + + *val = si1133_int_time_table[adc_sens][0]; + *val2 = si1133_int_time_table[adc_sens][1]; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_INTENSITY: + case IIO_UVINDEX: + adc_sens &= SI1133_ADCSENS_SCALE_MASK; + adc_sens >>= SI1133_ADCSENS_SCALE_SHIFT; + + *val = BIT(adc_sens); + + return IIO_VAL_INT; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_HARDWAREGAIN: + switch (chan->type) { + case IIO_INTENSITY: + case IIO_UVINDEX: + adc_sens >>= SI1133_ADCSENS_HSIG_SHIFT; + + *val = adc_sens; + + return IIO_VAL_INT; + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static int si1133_write_raw(struct iio_dev *iio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct si1133_data *data = iio_priv(iio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_INTENSITY: + case IIO_UVINDEX: + val = si1133_scale_to_swgain(val, val2); + if (val < 0) + return val; + + return si1133_update_adcsens(data, + SI1133_ADCSENS_SCALE_MASK, + SI1133_ADCSENS_SCALE_SHIFT, + val); + default: + return -EINVAL; + } + case IIO_CHAN_INFO_INT_TIME: + return si1133_set_integration_time(data, 0, val, val2); + case IIO_CHAN_INFO_HARDWAREGAIN: + switch (chan->type) { + case IIO_INTENSITY: + case IIO_UVINDEX: + if (val != 0 || val != 1) + return -EINVAL; + + return si1133_update_adcsens(data, + SI1133_ADCSENS_HSIG_MASK, + SI1133_ADCSENS_HSIG_SHIFT, + val); + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static struct attribute *si1133_attributes[] = { + &iio_const_attr_integration_time_available.dev_attr.attr, + &iio_const_attr_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group si1133_attribute_group = { + .attrs = si1133_attributes, +}; + +static const struct iio_info si1133_info = { + .read_raw = si1133_read_raw, + .write_raw = si1133_write_raw, + .attrs = &si1133_attribute_group, +}; + +/* + * si1133_init_lux_channels - Configure 3 different channels(adc) (1,2 and 3) + * The channel configuration for the lux measurement was taken from : + * https://siliconlabs.github.io/Gecko_SDK_Doc/efm32zg/html/si1133_8c_source.html#l00578 + * + * Reserved the channel 0 for the other raw measurements + */ +static int si1133_init_lux_channels(struct si1133_data *data) +{ + int err; + + err = si1133_chan_set_adcconfig(data, 1, + SI1133_ADCCONFIG_DECIM_RATE(1) | + SI1133_PARAM_ADCMUX_LARGE_WHITE); + if (err) + return err; + + err = si1133_param_set(data, SI1133_PARAM_REG_ADCPOST(1), + SI1133_ADCPOST_24BIT_EN | + SI1133_ADCPOST_POSTSHIFT_BITQTY(0)); + if (err) + return err; + err = si1133_chan_set_adcsens(data, 1, SI1133_ADCSENS_HSIG_MASK | + SI1133_ADCSENS_NB_MEAS(64) | _48_8_us); + if (err) + return err; + + err = si1133_chan_set_adcconfig(data, 2, + SI1133_ADCCONFIG_DECIM_RATE(1) | + SI1133_PARAM_ADCMUX_LARGE_WHITE); + if (err) + return err; + + err = si1133_param_set(data, SI1133_PARAM_REG_ADCPOST(2), + SI1133_ADCPOST_24BIT_EN | + SI1133_ADCPOST_POSTSHIFT_BITQTY(2)); + if (err) + return err; + + err = si1133_chan_set_adcsens(data, 2, SI1133_ADCSENS_HSIG_MASK | + SI1133_ADCSENS_NB_MEAS(1) | _3_120_0_us); + if (err) + return err; + + err = si1133_chan_set_adcconfig(data, 3, + SI1133_ADCCONFIG_DECIM_RATE(1) | + SI1133_PARAM_ADCMUX_MED_IR); + if (err) + return err; + + err = si1133_param_set(data, SI1133_PARAM_REG_ADCPOST(3), + SI1133_ADCPOST_24BIT_EN | + SI1133_ADCPOST_POSTSHIFT_BITQTY(2)); + if (err) + return err; + + return si1133_chan_set_adcsens(data, 3, SI1133_ADCSENS_HSIG_MASK | + SI1133_ADCSENS_NB_MEAS(64) | _48_8_us); +} + +static int si1133_initialize(struct si1133_data *data) +{ + int err; + + err = si1133_cmd_reset_sw(data); + if (err) + return err; + + /* Turn off autonomous mode */ + err = si1133_param_set(data, SI1133_REG_MEAS_RATE, 0); + if (err) + return err; + + err = si1133_init_lux_channels(data); + if (err) + return err; + + return regmap_write(data->regmap, SI1133_REG_IRQ_ENABLE, + SI1133_IRQ_CHANNEL_ENABLE); +} + +static int si1133_validate_ids(struct iio_dev *iio_dev) +{ + struct si1133_data *data = iio_priv(iio_dev); + + unsigned int part_id, rev_id, mfr_id; + int err; + + err = regmap_read(data->regmap, SI1133_REG_PART_ID, &part_id); + if (err) + return err; + + err = regmap_read(data->regmap, SI1133_REG_REV_ID, &rev_id); + if (err) + return err; + + err = regmap_read(data->regmap, SI1133_REG_MFR_ID, &mfr_id); + if (err) + return err; + + dev_info(&iio_dev->dev, + "Device ID part %#02hhx rev %#02hhx mfr %#02hhx\n", + part_id, rev_id, mfr_id); + if (part_id != SI1133_PART_ID) { + dev_err(&iio_dev->dev, + "Part ID mismatch got %#02hhx, expected %#02x\n", + part_id, SI1133_PART_ID); + return -ENODEV; + } + + return 0; +} + +static int si1133_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct si1133_data *data; + struct iio_dev *iio_dev; + int err; + + iio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!iio_dev) + return -ENOMEM; + + data = iio_priv(iio_dev); + + init_completion(&data->completion); + + data->regmap = devm_regmap_init_i2c(client, &si1133_regmap_config); + if (IS_ERR(data->regmap)) { + err = PTR_ERR(data->regmap); + dev_err(&client->dev, "Failed to initialise regmap: %d\n", err); + return err; + } + + i2c_set_clientdata(client, iio_dev); + data->client = client; + + iio_dev->dev.parent = &client->dev; + iio_dev->name = id->name; + iio_dev->channels = si1133_channels; + iio_dev->num_channels = ARRAY_SIZE(si1133_channels); + iio_dev->info = &si1133_info; + iio_dev->modes = INDIO_DIRECT_MODE; + + mutex_init(&data->mutex); + + err = si1133_validate_ids(iio_dev); + if (err) + return err; + + err = si1133_initialize(data); + if (err) { + dev_err(&client->dev, + "Error when initializing chip: %d\n", err); + return err; + } + + if (!client->irq) { + dev_err(&client->dev, + "Required interrupt not provided, cannot proceed\n"); + return -EINVAL; + } + + err = devm_request_threaded_irq(&client->dev, client->irq, + NULL, + si1133_threaded_irq_handler, + IRQF_ONESHOT | IRQF_SHARED, + client->name, iio_dev); + if (err) { + dev_warn(&client->dev, "Request irq %d failed: %i\n", + client->irq, err); + return err; + } + + return devm_iio_device_register(&client->dev, iio_dev); +} + +static const struct i2c_device_id si1133_ids[] = { + { "si1133", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, si1133_ids); + +static struct i2c_driver si1133_driver = { + .driver = { + .name = "si1133", + }, + .probe = si1133_probe, + .id_table = si1133_ids, +}; + +module_i2c_driver(si1133_driver); + +MODULE_AUTHOR("Maxime Roussin-Belanger "); +MODULE_DESCRIPTION("Silabs SI1133, UV index sensor and ambient light sensor driver"); +MODULE_LICENSE("GPL"); From 39e27533cdb4affdec79a89308ab9133a6e0e5c7 Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Thu, 19 Jul 2018 16:51:50 +0200 Subject: [PATCH 495/903] dt-bindings: iio: sigma-delta-modulator: fix unit-address in example Device tree compiler gives a warning if a device node has "@" but no reg property. Fix the example in iio: adc: sigma-delta-modulator. Signed-off-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/sigma-delta-modulator.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt b/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt index ba24ca7ba95e..59b92cd32552 100644 --- a/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt +++ b/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt @@ -7,7 +7,7 @@ Required properties: Example node: - ads1202: adc@0 { + ads1202: adc { compatible = "sd-modulator"; #io-channel-cells = <0>; }; From c344a327baefc372b7f4b7d0c17ac8b417ceaf94 Mon Sep 17 00:00:00 2001 From: Manish Narani Date: Wed, 18 Jul 2018 16:42:09 +0530 Subject: [PATCH 496/903] iio: adc: xilinx: Remove dead code from xadc_zynq_setup This patch removes dead code from xadc_zynq_setup. The condition "if (tck_rate > XADC_ZYNQ_TCK_RATE_MAX)" cannot be true at any point of time. There is also an incompatible parameter used in the code. This patch fixes the same reported by coverity. Signed-off-by: Manish Narani Signed-off-by: Jonathan Cameron --- drivers/iio/adc/xilinx-xadc-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index d4f21d1be6c8..0127e8513166 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -341,8 +341,6 @@ static int xadc_zynq_setup(struct platform_device *pdev, pcap_rate = clk_get_rate(xadc->clk); - if (tck_rate > XADC_ZYNQ_TCK_RATE_MAX) - tck_rate = XADC_ZYNQ_TCK_RATE_MAX; if (tck_rate > pcap_rate / 2) { div = 2; } else { @@ -1045,7 +1043,7 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np, unsigned int num_channels; const char *external_mux; u32 ext_mux_chan; - int reg; + u32 reg; int ret; *conf = 0; From 69f894c3f3185d3826ea6573afb282386b797acf Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 5 Jul 2018 15:34:22 +0300 Subject: [PATCH 497/903] iio: ad9523: replace core mlock with local lock This is also part of a long term effort to make the use of mlock opaque and single purpose. This lock is required for accessing device registers. The device may be accessed by multiple processes at the same time, and this can result in inconsistent data, where one device reads data before the other one has finished writing. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/ad9523.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index ddb6a334ae68..48ea46a1bc38 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -274,6 +274,15 @@ struct ad9523_state { unsigned long vco_out_freq[AD9523_NUM_CLK_SRC]; unsigned char vco_out_map[AD9523_NUM_CHAN_ALT_CLK_SRC]; + /* + * Lock for accessing device registers. Some operations require + * multiple consecutive R/W operations, during which the device + * shouldn't be interrupted. The buffers are also shared across + * all operations so need to be protected on stand alone reads and + * writes. + */ + struct mutex lock; + /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. @@ -500,6 +509,7 @@ static ssize_t ad9523_store(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + struct ad9523_state *st = iio_priv(indio_dev); bool state; int ret; @@ -510,7 +520,7 @@ static ssize_t ad9523_store(struct device *dev, if (!state) return 0; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); switch ((u32)this_attr->address) { case AD9523_SYNC: ret = ad9523_sync(indio_dev); @@ -521,7 +531,7 @@ static ssize_t ad9523_store(struct device *dev, default: ret = -ENODEV; } - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret ? ret : len; } @@ -532,15 +542,16 @@ static ssize_t ad9523_show(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + struct ad9523_state *st = iio_priv(indio_dev); int ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); ret = ad9523_read(indio_dev, AD9523_READBACK_0); if (ret >= 0) { ret = sprintf(buf, "%d\n", !!(ret & (1 << (u32)this_attr->address))); } - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -623,9 +634,9 @@ static int ad9523_read_raw(struct iio_dev *indio_dev, unsigned int code; int ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); ret = ad9523_read(indio_dev, AD9523_CHANNEL_CLOCK_DIST(chan->channel)); - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); if (ret < 0) return ret; @@ -659,7 +670,7 @@ static int ad9523_write_raw(struct iio_dev *indio_dev, unsigned int reg; int ret, tmp, code; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); ret = ad9523_read(indio_dev, AD9523_CHANNEL_CLOCK_DIST(chan->channel)); if (ret < 0) goto out; @@ -705,7 +716,7 @@ static int ad9523_write_raw(struct iio_dev *indio_dev, ad9523_io_update(indio_dev); out: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -713,9 +724,10 @@ static int ad9523_reg_access(struct iio_dev *indio_dev, unsigned int reg, unsigned int writeval, unsigned int *readval) { + struct ad9523_state *st = iio_priv(indio_dev); int ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); if (readval == NULL) { ret = ad9523_write(indio_dev, reg | AD9523_R1B, writeval); ad9523_io_update(indio_dev); @@ -728,7 +740,7 @@ static int ad9523_reg_access(struct iio_dev *indio_dev, } out_unlock: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -967,6 +979,8 @@ static int ad9523_probe(struct spi_device *spi) st = iio_priv(indio_dev); + mutex_init(&st->lock); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); From a176ba37e6282207be3f012fb58b77c6f51d55d9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 9 Jul 2018 14:06:59 +0300 Subject: [PATCH 498/903] iio: adc: at91-sama5d2_adc: fix up casting in at91_adc_read_info_raw() This code is problematic because we're supposed to be writing an int but we instead write to only the high 16 bits. This doesn't work on big endian systems, and there is a potential that the bottom 16 bits are used without being initialized. Fixes: 23ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position and pressure channels") Signed-off-by: Dan Carpenter Tested-by: Eugen Hristev Acked-by: Ludovic Desroches Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index e02f7d1c86bc..d5ea84cf6460 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1296,6 +1296,7 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, { struct at91_adc_state *st = iio_priv(indio_dev); u32 cor = 0; + u16 tmp_val; int ret; /* @@ -1309,7 +1310,8 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, mutex_lock(&st->lock); ret = at91_adc_read_position(st, chan->channel, - (u16 *)val); + &tmp_val); + *val = tmp_val; mutex_unlock(&st->lock); iio_device_release_direct_mode(indio_dev); @@ -1322,7 +1324,8 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, mutex_lock(&st->lock); ret = at91_adc_read_pressure(st, chan->channel, - (u16 *)val); + &tmp_val); + *val = tmp_val; mutex_unlock(&st->lock); iio_device_release_direct_mode(indio_dev); From 7d7209f0c467ba8b86229dbd4e1aa2f3d9b0c5bb Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sat, 21 Jul 2018 14:37:33 -0500 Subject: [PATCH 499/903] iio: adc: ti-ads7950: use SPDX-License-Identifier This updates the ti-ads7950.c file to use SPDX-License-Identifier instead of more verbose license text. Signed-off-by: David Lechner Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads7950.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index 0225c1b333ab..f08c4de2bd10 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Texas Instruments ADS7950 SPI ADC driver * @@ -10,15 +11,6 @@ * And also on hwmon/ads79xx.c * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ * Nishanth Menon - * - * 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. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include From 8134b613b05dd27fc718fbe3785ccc9c5da10e02 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sat, 21 Jul 2018 14:37:34 -0500 Subject: [PATCH 500/903] iio: adc: ti-ads7950: allow simultaneous use of buffer and direct mode This modifies the TI ADS7950 A/DC driver to allow the simultaneous use of both the triggered buffer and reading channels directly (via in- kernel API or sysfs). The use case for this is on LEGO MINDSTORMS EV3. Two of the voltage channels are used in-kernel by a power supply driver, which reads the values using iio_read_channel_processed(). These channels are only read at a slow rate (<= 1Hz). However, we want to be able to read 12 other channels at the same time using the triggered buffer at a high rate (>= 100Hz). Signed-off-by: David Lechner Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads7950.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index f08c4de2bd10..a5bd5944bc66 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -68,6 +68,9 @@ struct ti_ads7950_state { __be16 rx_buf[TI_ADS7950_MAX_CHAN + TI_ADS7950_TIMESTAMP_SIZE] ____cacheline_aligned; __be16 tx_buf[TI_ADS7950_MAX_CHAN]; + __be16 single_tx; + __be16 single_rx; + }; struct ti_ads7950_chip_info { @@ -287,18 +290,26 @@ out: return IRQ_HANDLED; } -static int ti_ads7950_scan_direct(struct ti_ads7950_state *st, unsigned int ch) +static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch) { + struct ti_ads7950_state *st = iio_priv(indio_dev); int ret, cmd; + mutex_lock(&indio_dev->mlock); + cmd = TI_ADS7950_CR_WRITE | TI_ADS7950_CR_CHAN(ch) | st->settings; - st->tx_buf[0] = cpu_to_be16(cmd); + st->single_tx = cpu_to_be16(cmd); ret = spi_sync(st->spi, &st->scan_single_msg); if (ret) - return ret; + goto out; - return be16_to_cpu(st->rx_buf[0]); + ret = be16_to_cpu(st->single_rx); + +out: + mutex_unlock(&indio_dev->mlock); + + return ret; } static int ti_ads7950_get_range(struct ti_ads7950_state *st) @@ -330,13 +341,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: - - ret = iio_device_claim_direct_mode(indio_dev); - if (ret < 0) - return ret; - - ret = ti_ads7950_scan_direct(st, chan->address); - iio_device_release_direct_mode(indio_dev); + ret = ti_ads7950_scan_direct(indio_dev, chan->address); if (ret < 0) return ret; @@ -402,13 +407,13 @@ static int ti_ads7950_probe(struct spi_device *spi) * was read at the end of the first transfer. */ - st->scan_single_xfer[0].tx_buf = &st->tx_buf[0]; + st->scan_single_xfer[0].tx_buf = &st->single_tx; st->scan_single_xfer[0].len = 2; st->scan_single_xfer[0].cs_change = 1; - st->scan_single_xfer[1].tx_buf = &st->tx_buf[0]; + st->scan_single_xfer[1].tx_buf = &st->single_tx; st->scan_single_xfer[1].len = 2; st->scan_single_xfer[1].cs_change = 1; - st->scan_single_xfer[2].rx_buf = &st->rx_buf[0]; + st->scan_single_xfer[2].rx_buf = &st->single_rx; st->scan_single_xfer[2].len = 2; spi_message_init_with_transfers(&st->scan_single_msg, From 439ba65b8b4f3788d55a90356fe25dc214721106 Mon Sep 17 00:00:00 2001 From: Martin Blumenstingl Date: Sat, 21 Jul 2018 21:40:48 +0200 Subject: [PATCH 501/903] dt-bindings: iio: adc: add Meson8m2 support The Amlogic Meson SAR ADC implementation on the Meson8m2 SoC is identical to the Meson8b variant. Add a compatible string to indicate that we support the SAR ADC on the Meson8m2 SoC. Signed-off-by: Martin Blumenstingl Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/amlogic,meson-saradc.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt index d1acd5ea2737..54b823f3a453 100644 --- a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt +++ b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt @@ -4,6 +4,7 @@ Required properties: - compatible: depending on the SoC this should be one of: - "amlogic,meson8-saradc" for Meson8 - "amlogic,meson8b-saradc" for Meson8b + - "amlogic,meson8m2-saradc" for Meson8m2 - "amlogic,meson-gxbb-saradc" for GXBB - "amlogic,meson-gxl-saradc" for GXL - "amlogic,meson-gxm-saradc" for GXM From ffc0d638c838ff670fee2eb43d3884d05cb86faa Mon Sep 17 00:00:00 2001 From: Martin Blumenstingl Date: Sat, 21 Jul 2018 21:40:49 +0200 Subject: [PATCH 502/903] iio: adc: meson-saradc: add support for the Meson8m2 SoCs The SAR ADC on Meson8m2 behaves identical to the one found in the Meson8b SoCs. Add a separate compatible string because the temperature sensor logic (not supported yet) differs between Meson8 and Meson8m2 (however, it's the same for Meson8b and Meson8m2). Signed-off-by: Martin Blumenstingl Signed-off-by: Jonathan Cameron --- drivers/iio/adc/meson_saradc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 2948909f3ee3..da2d16dfa63e 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -922,6 +922,11 @@ static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = { .name = "meson-meson8b-saradc", }; +static const struct meson_sar_adc_data meson_sar_adc_meson8m2_data = { + .param = &meson_sar_adc_meson8_param, + .name = "meson-meson8m2-saradc", +}; + static const struct meson_sar_adc_data meson_sar_adc_gxbb_data = { .param = &meson_sar_adc_gxbb_param, .name = "meson-gxbb-saradc", @@ -951,6 +956,10 @@ static const struct of_device_id meson_sar_adc_of_match[] = { .compatible = "amlogic,meson8b-saradc", .data = &meson_sar_adc_meson8b_data, }, + { + .compatible = "amlogic,meson8m2-saradc", + .data = &meson_sar_adc_meson8m2_data, + }, { .compatible = "amlogic,meson-gxbb-saradc", .data = &meson_sar_adc_gxbb_data, From 847794a1a7380ca9301f3e09d4dc41f59a170bd7 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 20 Jul 2018 17:31:35 +0530 Subject: [PATCH 503/903] staging: wilc1000: remove gpio parameter from wilc_netdev_init() Instead of passing the gpio as parameter to wilc_netdev_init() now setting its value after finishing wilc_netdev_init() call. Avoided passing of extra parameter to wilc_netdev_init(). Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 3 +-- drivers/staging/wilc1000/wilc_sdio.c | 4 ++-- drivers/staging/wilc1000/wilc_spi.c | 3 ++- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 2f4bf8e1f33e..8f43a1f6b30f 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1053,7 +1053,7 @@ static const struct net_device_ops wilc_netdev_ops = { }; int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, - int gpio, const struct wilc_hif_func *ops) + const struct wilc_hif_func *ops) { int i, ret; struct wilc_vif *vif; @@ -1066,7 +1066,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, *wilc = wl; wl->io_type = io_type; - wl->gpio = gpio; wl->hif_func = ops; INIT_LIST_HEAD(&wl->txq_head.list); INIT_LIST_HEAD(&wl->rxq_head.list); diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 4ab43f97646a..7a2fc79d6fca 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -118,14 +118,14 @@ static int linux_sdio_probe(struct sdio_func *func, } dev_dbg(&func->dev, "Initializing netdev\n"); - ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, gpio, - &wilc_hif_sdio); + ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, &wilc_hif_sdio); if (ret) { dev_err(&func->dev, "Couldn't initialize netdev\n"); return ret; } sdio_set_drvdata(func, wilc); wilc->dev = &func->dev; + wilc->gpio = gpio; dev_info(&func->dev, "Driver Initializing success\n"); return 0; diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 647526387784..69b2c3cc75dc 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -113,12 +113,13 @@ static int wilc_bus_probe(struct spi_device *spi) if (gpio < 0) gpio = GPIO_NUM; - ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, GPIO_NUM, &wilc_hif_spi); + ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, &wilc_hif_spi); if (ret) return ret; spi_set_drvdata(spi, wilc); wilc->dev = &spi->dev; + wilc->gpio = gpio; return 0; } diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 765681a78105..add76c707532 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -174,7 +174,7 @@ void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); void wilc_mac_indicate(struct wilc *wilc); void wilc_netdev_cleanup(struct wilc *wilc); int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, - int gpio, const struct wilc_hif_func *ops); + const struct wilc_hif_func *ops); void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode); From 4b6cfa87b1373a597be8fea19d6de90d92516096 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 20 Jul 2018 17:31:36 +0530 Subject: [PATCH 504/903] staging: wilc1000: rename variable from 'gpio' to 'gpio_irq' Rename from 'gpio' to 'gpio_irq', so its inlcude the information about the purpose of GPIO. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 17 +++++++++-------- drivers/staging/wilc1000/wilc_sdio.c | 2 +- drivers/staging/wilc1000/wilc_spi.c | 2 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 8f43a1f6b30f..74e71806e9e6 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -127,9 +127,9 @@ static int init_irq(struct net_device *dev) struct wilc_vif *vif = netdev_priv(dev); struct wilc *wl = vif->wilc; - if ((gpio_request(wl->gpio, "WILC_INTR") == 0) && - (gpio_direction_input(wl->gpio) == 0)) { - wl->dev_irq_num = gpio_to_irq(wl->gpio); + if ((gpio_request(wl->gpio_irq, "WILC_INTR") == 0) && + (gpio_direction_input(wl->gpio_irq) == 0)) { + wl->dev_irq_num = gpio_to_irq(wl->gpio_irq); } else { ret = -1; netdev_err(dev, "could not obtain gpio for WILC_INTR\n"); @@ -140,13 +140,14 @@ static int init_irq(struct net_device *dev) isr_bh_routine, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "WILC_IRQ", dev) < 0) { - netdev_err(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio); - gpio_free(wl->gpio); + netdev_err(dev, "Failed to request IRQ GPIO: %d\n", + wl->gpio_irq); + gpio_free(wl->gpio_irq); ret = -1; } else { netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", - wl->dev_irq_num, wl->gpio); + wl->dev_irq_num, wl->gpio_irq); } return ret; @@ -160,7 +161,7 @@ static void deinit_irq(struct net_device *dev) /* Deinitialize IRQ */ if (wilc->dev_irq_num) { free_irq(wilc->dev_irq_num, wilc); - gpio_free(wilc->gpio); + gpio_free(wilc->gpio_irq); } } @@ -651,7 +652,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) goto fail_locks; } - if (wl->gpio >= 0 && init_irq(dev)) { + if (wl->gpio_irq >= 0 && init_irq(dev)) { ret = -EIO; goto fail_locks; } diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 7a2fc79d6fca..07cb8a6fae9c 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -125,7 +125,7 @@ static int linux_sdio_probe(struct sdio_func *func, } sdio_set_drvdata(func, wilc); wilc->dev = &func->dev; - wilc->gpio = gpio; + wilc->gpio_irq = gpio; dev_info(&func->dev, "Driver Initializing success\n"); return 0; diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 69b2c3cc75dc..8cb286b317ec 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -119,7 +119,7 @@ static int wilc_bus_probe(struct spi_device *spi) spi_set_drvdata(spi, wilc); wilc->dev = &spi->dev; - wilc->gpio = gpio; + wilc->gpio_irq = gpio; return 0; } diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index add76c707532..74c2a17ecdca 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -121,7 +121,7 @@ struct wilc { const struct wilc_hif_func *hif_func; int io_type; int mac_status; - int gpio; + int gpio_irq; bool initialized; int dev_irq_num; int close; From 8dfaf8594e9754a3681af10118f5b9a8b6c40f52 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 20 Jul 2018 17:31:37 +0530 Subject: [PATCH 505/903] staging: wilc1000: change compatible string from atmel to microchip Use 'microchip' in compatible string instead of 'atmel', also replace '_' with '-' before the module. Remove 'wilc1000' prefix from device table name. Signed-off-by: Ajay Singh Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_sdio.c | 11 +++++++++-- drivers/staging/wilc1000/wilc_spi.c | 14 +++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 07cb8a6fae9c..afb91e5a5aa1 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -199,21 +199,28 @@ static int wilc_sdio_resume(struct device *dev) return 0; } +static const struct of_device_id wilc_of_match[] = { + { .compatible = "microchip,wilc1000-sdio", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, wilc_of_match); + static const struct dev_pm_ops wilc_sdio_pm_ops = { .suspend = wilc_sdio_suspend, .resume = wilc_sdio_resume, }; -static struct sdio_driver wilc1000_sdio_driver = { +static struct sdio_driver wilc_sdio_driver = { .name = SDIO_MODALIAS, .id_table = wilc_sdio_ids, .probe = linux_sdio_probe, .remove = linux_sdio_remove, .drv = { .pm = &wilc_sdio_pm_ops, + .of_match_table = wilc_of_match, } }; -module_driver(wilc1000_sdio_driver, +module_driver(wilc_sdio_driver, sdio_register_driver, sdio_unregister_driver); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 8cb286b317ec..7d4c7c5b586b 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -130,21 +130,21 @@ static int wilc_bus_remove(struct spi_device *spi) return 0; } -static const struct of_device_id wilc1000_of_match[] = { - { .compatible = "atmel,wilc_spi", }, - {} +static const struct of_device_id wilc_of_match[] = { + { .compatible = "microchip,wilc1000-spi", }, + { /* sentinel */ } }; -MODULE_DEVICE_TABLE(of, wilc1000_of_match); +MODULE_DEVICE_TABLE(of, wilc_of_match); -static struct spi_driver wilc1000_spi_driver = { +static struct spi_driver wilc_spi_driver = { .driver = { .name = MODALIAS, - .of_match_table = wilc1000_of_match, + .of_match_table = wilc_of_match, }, .probe = wilc_bus_probe, .remove = wilc_bus_remove, }; -module_spi_driver(wilc1000_spi_driver); +module_spi_driver(wilc_spi_driver); MODULE_LICENSE("GPL"); static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len) From 367b955907b1123f8374025f02f579306886697e Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 20 Jul 2018 17:31:38 +0530 Subject: [PATCH 506/903] staging: wilc1000: use descriptor-based interface for GPIO Now making use of descriptor-based interface instead of integer-based interface for IRQ GPIO. Added device tree binding reference for WILC SDIO and SPI interface module. Also moved the code to free gpio descriptor in module remove as the reference was fetched in probe function. Updated the TODO file Signed-off-by: Ajay Singh Reviewed-by: Linus Walleij Reviewed-by: Claudiu Beznea Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/TODO | 4 -- drivers/staging/wilc1000/linux_wlan.c | 40 ++++++++----------- .../wilc1000/microchip,wilc1000,sdio.txt | 32 +++++++++++++++ .../wilc1000/microchip,wilc1000,spi.txt | 26 ++++++++++++ drivers/staging/wilc1000/wilc_sdio.c | 23 +++++++---- drivers/staging/wilc1000/wilc_spi.c | 21 +++++++--- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +- 7 files changed, 107 insertions(+), 42 deletions(-) create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.txt create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.txt diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO index 725bedee08c0..3d82bb0a8131 100644 --- a/drivers/staging/wilc1000/TODO +++ b/drivers/staging/wilc1000/TODO @@ -3,7 +3,3 @@ TODO: - make spi and sdio components coexist in one build - support soft-ap and p2p mode - support resume/suspend function -- convert all uses of the old GPIO API from to the - GPIO descriptor API in and look up GPIO - lines from device tree, ACPI or board files, board files should - use diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 74e71806e9e6..64c5d692d0e3 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include #include #include #include @@ -127,28 +126,23 @@ static int init_irq(struct net_device *dev) struct wilc_vif *vif = netdev_priv(dev); struct wilc *wl = vif->wilc; - if ((gpio_request(wl->gpio_irq, "WILC_INTR") == 0) && - (gpio_direction_input(wl->gpio_irq) == 0)) { - wl->dev_irq_num = gpio_to_irq(wl->gpio_irq); - } else { - ret = -1; + ret = gpiod_direction_input(wl->gpio_irq); + if (ret) { netdev_err(dev, "could not obtain gpio for WILC_INTR\n"); + return ret; } - if (ret != -1 && request_threaded_irq(wl->dev_irq_num, - isr_uh_routine, - isr_bh_routine, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "WILC_IRQ", dev) < 0) { - netdev_err(dev, "Failed to request IRQ GPIO: %d\n", - wl->gpio_irq); - gpio_free(wl->gpio_irq); - ret = -1; - } else { - netdev_dbg(dev, - "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", - wl->dev_irq_num, wl->gpio_irq); - } + wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq); + + ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine, + isr_bh_routine, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "WILC_IRQ", dev); + if (ret < 0) + netdev_err(dev, "Failed to request IRQ\n"); + else + netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", + wl->dev_irq_num); return ret; } @@ -159,10 +153,8 @@ static void deinit_irq(struct net_device *dev) struct wilc *wilc = vif->wilc; /* Deinitialize IRQ */ - if (wilc->dev_irq_num) { + if (wilc->dev_irq_num) free_irq(wilc->dev_irq_num, wilc); - gpio_free(wilc->gpio_irq); - } } void wilc_mac_indicate(struct wilc *wilc) @@ -652,7 +644,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) goto fail_locks; } - if (wl->gpio_irq >= 0 && init_irq(dev)) { + if (wl->gpio_irq && init_irq(dev)) { ret = -EIO; goto fail_locks; } diff --git a/drivers/staging/wilc1000/microchip,wilc1000,sdio.txt b/drivers/staging/wilc1000/microchip,wilc1000,sdio.txt new file mode 100644 index 000000000000..4f7d1c2be4d0 --- /dev/null +++ b/drivers/staging/wilc1000/microchip,wilc1000,sdio.txt @@ -0,0 +1,32 @@ +* Microchip WILC wireless SDIO device + +The wilc1000 chips can be connected via SDIO. The node is used to specifiy +child node to the SDIO controller that connects the device to the system. + +Required properties: +- compatible : Should be "microchip,wilc1000-spi" +- irq-gpios : Connect to a host IRQ +- reg : Slot ID used in the controller + +Optional: +- bus-width : Number of data lines wired up the slot. Default 1 bit. + + +Examples: +mmc1: mmc@fc000000 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_mmc1_clk_cmd_dat0 &pinctrl_mmc1_dat1_3>; + non-removable; + vmmc-supply = <&vcc_mmc1_reg>; + vqmmc-supply = <&vcc_3v3_reg>; + status = "okay"; + + wilc_sdio@0 { + compatible = "microchip,wilc1000-sdio"; + irq-gpios = <&pioC 27 0>; + status = "okay"; + reg = <0>; + bus-width = <4>; + } + }; +} diff --git a/drivers/staging/wilc1000/microchip,wilc1000,spi.txt b/drivers/staging/wilc1000/microchip,wilc1000,spi.txt new file mode 100644 index 000000000000..87db87b2d901 --- /dev/null +++ b/drivers/staging/wilc1000/microchip,wilc1000,spi.txt @@ -0,0 +1,26 @@ +* Microchip WILC wireless SPI device + +The wilc1000 chips can be connected via SPI. This document describes +the binding for the SPI connected module. + +Required properties: +- compatible : Should be "microchip,wilc1000-spi" +- spi-max-frequency : Maximum SPI clocking speed of device in Hz +- reg : Chip select address of device +- irq-gpios : Connect to a host IRQ + + +Examples: + +spi1: spi@fc018000 { + cs-gpios = <&pioB 21 0>; + status = "okay"; + + wilc_spi@0 { + compatible = "microchip,wilc1000-spi"; + spi-max-frequency = <48000000>; + reg = <0>; + irq-gpios = <&pioC 27 0>; + status = "okay"; + }; +}; diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index afb91e5a5aa1..8a471474a807 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include "wilc_wfi_netdevice.h" @@ -108,13 +108,17 @@ static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { struct wilc *wilc; - int gpio, ret; + int ret; + struct gpio_desc *gpio = NULL; - gpio = -1; if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) { - gpio = of_get_gpio(func->dev.of_node, 0); - if (gpio < 0) - gpio = GPIO_NUM; + gpio = gpiod_get(&func->dev, "irq", GPIOD_IN); + if (IS_ERR(gpio)) { + /* get the GPIO descriptor from hardcode GPIO number */ + gpio = gpio_to_desc(GPIO_NUM); + if (!gpio) + dev_err(&func->dev, "failed to get irq gpio\n"); + } } dev_dbg(&func->dev, "Initializing netdev\n"); @@ -133,7 +137,12 @@ static int linux_sdio_probe(struct sdio_func *func, static void linux_sdio_remove(struct sdio_func *func) { - wilc_netdev_cleanup(sdio_get_drvdata(func)); + struct wilc *wilc = sdio_get_drvdata(func); + + /* free the GPIO in module remove */ + if (wilc->gpio_irq) + gpiod_put(wilc->gpio_irq); + wilc_netdev_cleanup(wilc); } static int sdio_reset(struct wilc *wilc) diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 7d4c7c5b586b..fa9371ba53a9 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -6,7 +6,6 @@ */ #include -#include #include "wilc_wfi_netdevice.h" @@ -106,12 +105,17 @@ static u8 crc7(u8 crc, const u8 *buffer, u32 len) static int wilc_bus_probe(struct spi_device *spi) { - int ret, gpio; + int ret; struct wilc *wilc; + struct gpio_desc *gpio; - gpio = of_get_gpio(spi->dev.of_node, 0); - if (gpio < 0) - gpio = GPIO_NUM; + gpio = gpiod_get(&spi->dev, "irq", GPIOD_IN); + if (IS_ERR(gpio)) { + /* get the GPIO descriptor from hardcode GPIO number */ + gpio = gpio_to_desc(GPIO_NUM); + if (!gpio) + dev_err(&spi->dev, "failed to get the irq gpio\n"); + } ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, &wilc_hif_spi); if (ret) @@ -126,7 +130,12 @@ static int wilc_bus_probe(struct spi_device *spi) static int wilc_bus_remove(struct spi_device *spi) { - wilc_netdev_cleanup(spi_get_drvdata(spi)); + struct wilc *wilc = spi_get_drvdata(spi); + + /* free the GPIO in module remove */ + if (wilc->gpio_irq) + gpiod_put(wilc->gpio_irq); + wilc_netdev_cleanup(wilc); return 0; } diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 74c2a17ecdca..331a9711e31d 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "host_interface.h" #include "wilc_wlan.h" @@ -121,7 +122,7 @@ struct wilc { const struct wilc_hif_func *hif_func; int io_type; int mac_status; - int gpio_irq; + struct gpio_desc *gpio_irq; bool initialized; int dev_irq_num; int close; From 51a2ee0a4e62961131879f8f315052c48265829d Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 24 Jul 2018 13:13:28 +0200 Subject: [PATCH 507/903] staging: rtl8188eu/rtl8723bs: fix character encoding drivers/staging/rtl8188eu/include/odm.h uses an incorrect encoding for the '...' character in two comments, which makes it one of the few non-UTF-8 source files. This removes the odd characters and uses the same ASCII representation that we have in the regular rtlwifi driver. The second instance of drivers/staging/rtl8723bs/hal/odm.h is garbled in a different way, so I change it to be the same as well even though it is already plain ASCII. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm.h | 2 +- drivers/staging/rtl8723bs/hal/odm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 79affc617f35..947481de9cb1 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -708,7 +708,7 @@ struct odm_dm_struct { /* HOOK BEFORE REG INIT----------- */ /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ u8 SupportPlatform; - /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/ ¡K¡K = 1/2/3/¡K */ + /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/... = 1/2/3/... */ u32 SupportAbility; /* ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */ u8 SupportInterface; diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h index a4153a660d32..23ab160ac2c8 100644 --- a/drivers/staging/rtl8723bs/hal/odm.h +++ b/drivers/staging/rtl8723bs/hal/odm.h @@ -913,7 +913,7 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure { /* HOOK BEFORE REG INIT----------- */ /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ u8 SupportPlatform; - /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/ ?K?K = 1/2/3/?K */ + /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/... = 1/2/3/... */ u32 SupportAbility; /* ODM PCIE/USB/SDIO = 1/2/3 */ u8 SupportInterface; From 59ab5af731565762189d2f923887933fc1e84bcf Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:34:54 -0700 Subject: [PATCH 508/903] staging: gasket: fix check_and_invoke_callback log param The message should be passed the callback function pointer, not the pointer to the gasket device. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 40e46ca5228c..2cd232230845 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -205,7 +205,7 @@ static inline int check_and_invoke_callback( { int ret = 0; - gasket_nodev_error("check_and_invoke_callback %p", gasket_dev); + gasket_nodev_error("check_and_invoke_callback %p", cb_function); if (cb_function) { mutex_lock(&gasket_dev->mutex); ret = cb_function(gasket_dev); From 996e650030857e791416af81d7d9171d9652bd9d Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:34:55 -0700 Subject: [PATCH 509/903] staging: gasket: remove duplicate call to retrieve device callback gasket_handle_ioctl() calls gasket_get_ioctl_permissions_cb() twice; simplify the code and avoid duplicated work by fetching the callback pointer only once. Reported-by: Dmitry Torokhov Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 2e2c9b997093..dbe9fdef0c26 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -55,14 +55,15 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) { struct gasket_dev *gasket_dev; unsigned long arg = (unsigned long)argp; + gasket_ioctl_permissions_cb_t ioctl_permissions_cb; int retval; gasket_dev = (struct gasket_dev *)filp->private_data; trace_gasket_ioctl_entry(gasket_dev->dev_info.name, cmd); - if (gasket_get_ioctl_permissions_cb(gasket_dev)) { - retval = gasket_get_ioctl_permissions_cb(gasket_dev)( - filp, cmd, argp); + ioctl_permissions_cb = gasket_get_ioctl_permissions_cb(gasket_dev); + if (ioctl_permissions_cb) { + retval = ioctl_permissions_cb(filp, cmd, argp); if (retval < 0) { trace_gasket_ioctl_exit(-EPERM); return retval; From 8fc1cb4cef287fd61391adcc48f4a6bdc369bf49 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:34:56 -0700 Subject: [PATCH 510/903] staging: gasket: gasket_handle_ioctl fix ioctl exit trace param Pass the return value from the device ioctl permissions callback to the tracepoint when the callback returns an error. Reported-by: Dmitry Torokhov Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index dbe9fdef0c26..1b164ac7a049 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -65,7 +65,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) if (ioctl_permissions_cb) { retval = ioctl_permissions_cb(filp, cmd, argp); if (retval < 0) { - trace_gasket_ioctl_exit(-EPERM); + trace_gasket_ioctl_exit(retval); return retval; } else if (retval == 0) { trace_gasket_ioctl_exit(-EPERM); From 5c4a5d3ddd724d1c4f27c3b52ad0980c4c750999 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:34:57 -0700 Subject: [PATCH 511/903] staging: gasket: avoid copy to user on error in coherent alloc config gasket_config_coherent_allocator() on error return the error to caller without copying a possibly-update DMA address back to userspace. Reported-by: Dmitry Torokhov Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 1b164ac7a049..8cf094b90cdb 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -441,8 +441,10 @@ static int gasket_config_coherent_allocator( gasket_dev, ibuf.size, &ibuf.dma_address, ibuf.page_table_index); } + if (ret) + return ret; if (copy_to_user(argp, &ibuf, sizeof(ibuf))) return -EFAULT; - return ret; + return 0; } From a1978fa2d632c9001d1d68dac3926177af96c64e Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:34:58 -0700 Subject: [PATCH 512/903] staging: gasket: print mmap starting address as unsigned long Page alignment error log should print the offending value as an unsigned long, not as a kernel pointer. Reported-by: Guenter Roeck Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 2cd232230845..11ab04985449 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1596,8 +1596,8 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) if (vma->vm_start & ~PAGE_MASK) { gasket_log_error( - gasket_dev, "Base address not page-aligned: 0x%p\n", - (void *)vma->vm_start); + gasket_dev, "Base address not page-aligned: 0x%lx\n", + vma->vm_start); trace_gasket_mmap_exit(-EINVAL); return -EINVAL; } From 99ccddf5af6f32f501e719024e5e699565c6552e Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:34:59 -0700 Subject: [PATCH 513/903] staging: gasket: remove unnecessary NULL checks on calls from VFS Remove unneeded checks for NULL pointers in struct file pointers passed from the VFS layer or the private_data that must have been properly set at file open time. Reported-by: Guenter Roeck Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 11ab04985449..e82f8ce39c9f 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1587,11 +1587,6 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) int num_map_regions = 0; enum do_map_region_status map_status; - if (!gasket_dev) { - gasket_nodev_error("Unable to retrieve device data"); - trace_gasket_mmap_exit(-EINVAL); - return -EINVAL; - } driver_desc = gasket_dev->internal_desc->driver_desc; if (vma->vm_start & ~PAGE_MASK) { @@ -1785,17 +1780,7 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) void __user *argp = (void __user *)arg; char path[256]; - if (!filp) - return -ENODEV; - gasket_dev = (struct gasket_dev *)filp->private_data; - if (!gasket_dev) { - gasket_nodev_error( - "Unable to find Gasket structure for file %s", - d_path(&filp->f_path, path, 256)); - return -ENODEV; - } - driver_desc = gasket_dev->internal_desc->driver_desc; if (!driver_desc) { gasket_log_error( From e2f00f0b9876387e38849e7b1338ac684a7a6562 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:00 -0700 Subject: [PATCH 514/903] staging: gasket: gasket_get_device drop check for NULL pci_dev The pci_dev field of a struct gasket_dev can never be NULL, there's no need to check for this in gasket_get_device(). Reported-by: Guenter Roeck Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index e82f8ce39c9f..8265d543623d 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -2026,9 +2026,7 @@ const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev) */ struct device *gasket_get_device(struct gasket_dev *dev) { - if (dev->pci_dev) - return &dev->pci_dev->dev; - return NULL; + return &dev->pci_dev->dev; } /** From b0e66fb7ba060243f71f6871c988846d74bac0ac Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:01 -0700 Subject: [PATCH 515/903] staging: gasket: apex return error on sysfs show of missing attribute Apex sysfs show function return -ENODEV if the attribute is not present, rather than silently failing from the standpoint of the userspace accessor. Reported-by: Guenter Roeck Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 3e76c4db5db2..1c6f73b5a2a9 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -710,14 +710,14 @@ static ssize_t sysfs_show( gasket_dev = gasket_sysfs_get_device_data(device); if (!gasket_dev) { gasket_nodev_error("No Apex device sysfs mapping found"); - return 0; + return -ENODEV; } gasket_attr = gasket_sysfs_get_attr(device, attr); if (!gasket_attr) { gasket_nodev_error("No Apex device sysfs attr data found"); gasket_sysfs_put_device_data(device, gasket_dev); - return 0; + return -ENODEV; } type = (enum sysfs_attribute_type)gasket_sysfs_get_attr(device, attr); From 6b18580bad320fe96e32216bd91ba9f036119d25 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:02 -0700 Subject: [PATCH 516/903] staging: gasket: core: convert various logs to debug level Debugging information is improperly logged at non-debug log level in a number of places, and some logs regarding error conditions may be generated too frequently, such that these could cause performance problems and/or obscure other logs. Convert these to debug log level. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 38 +++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 8265d543623d..1d04fd0990e4 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -205,7 +205,8 @@ static inline int check_and_invoke_callback( { int ret = 0; - gasket_nodev_error("check_and_invoke_callback %p", cb_function); + gasket_log_debug(gasket_dev, "check_and_invoke_callback %p", + cb_function); if (cb_function) { mutex_lock(&gasket_dev->mutex); ret = cb_function(gasket_dev); @@ -227,7 +228,7 @@ static inline int gasket_check_and_invoke_callback_nolock( int ret = 0; if (cb_function) { - gasket_log_info( + gasket_log_debug( gasket_dev, "Invoking device-specific callback."); ret = cb_function(gasket_dev); } @@ -1177,7 +1178,7 @@ static int gasket_release(struct inode *inode, struct file *file) if (file->f_mode & FMODE_WRITE) { ownership->write_open_count--; if (ownership->write_open_count == 0) { - gasket_log_info(gasket_dev, "Device is now free"); + gasket_log_debug(gasket_dev, "Device is now free"); ownership->is_owned = 0; ownership->owner = 0; @@ -1198,7 +1199,7 @@ static int gasket_release(struct inode *inode, struct file *file) } } - gasket_log_info( + gasket_log_debug( gasket_dev, "New open count (owning tgid %u): %d", ownership->owner, ownership->write_open_count); mutex_unlock(&gasket_dev->mutex); @@ -1225,7 +1226,7 @@ static bool gasket_mmap_has_permissions( /* Never allow non-sysadmins to access to a dead device. */ if (gasket_dev->status != GASKET_STATUS_ALIVE) { - gasket_log_info(gasket_dev, "Device is dead."); + gasket_log_debug(gasket_dev, "Device is dead."); return false; } @@ -1233,7 +1234,7 @@ static bool gasket_mmap_has_permissions( requested_permissions = (vma->vm_flags & (VM_WRITE | VM_READ | VM_EXEC)); if (requested_permissions & ~(bar_permissions)) { - gasket_log_info( + gasket_log_debug( gasket_dev, "Attempting to map a region with requested permissions " "0x%x, but region has permissions 0x%x.", @@ -1244,7 +1245,7 @@ static bool gasket_mmap_has_permissions( /* Do not allow a non-owner to write. */ if ((vma->vm_flags & VM_WRITE) && !gasket_owned_by_current_tgid(&gasket_dev->dev_info)) { - gasket_log_info( + gasket_log_debug( gasket_dev, "Attempting to mmap a region for write without owning " "device."); @@ -1736,15 +1737,16 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) status = gasket_check_and_invoke_callback_nolock( gasket_dev, driver_desc->device_status_cb); if (status != GASKET_STATUS_ALIVE) { - gasket_log_info(gasket_dev, "Hardware reported status %d.", - status); + gasket_log_debug(gasket_dev, "Hardware reported status %d.", + status); return status; } status = gasket_interrupt_system_status(gasket_dev); if (status != GASKET_STATUS_ALIVE) { - gasket_log_info(gasket_dev, - "Interrupt system reported status %d.", status); + gasket_log_debug(gasket_dev, + "Interrupt system reported status %d.", + status); return status; } @@ -1752,7 +1754,7 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) status = gasket_page_table_system_status( gasket_dev->page_table[i]); if (status != GASKET_STATUS_ALIVE) { - gasket_log_info( + gasket_log_debug( gasket_dev, "Page table %d reported status %d.", i, status); return status; @@ -1783,7 +1785,7 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) gasket_dev = (struct gasket_dev *)filp->private_data; driver_desc = gasket_dev->internal_desc->driver_desc; if (!driver_desc) { - gasket_log_error( + gasket_log_debug( gasket_dev, "Unable to find device descriptor for file %s", d_path(&filp->f_path, path, 256)); @@ -1831,7 +1833,7 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) /* Perform a device reset of the requested type. */ ret = driver_desc->device_reset_cb(gasket_dev, reset_type); if (ret) { - gasket_log_error( + gasket_log_debug( gasket_dev, "Device reset cb returned %d.", ret); return ret; } @@ -1842,7 +1844,7 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) ret = gasket_interrupt_reinit(gasket_dev); if (ret) { - gasket_log_error( + gasket_log_debug( gasket_dev, "Unable to reinit interrupts: %d.", ret); return ret; } @@ -1850,7 +1852,7 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) /* Get current device health. */ gasket_dev->status = gasket_get_hw_status(gasket_dev); if (gasket_dev->status == GASKET_STATUS_DEAD) { - gasket_log_error(gasket_dev, "Device reported as dead."); + gasket_log_debug(gasket_dev, "Device reported as dead."); return -EINVAL; } @@ -2002,7 +2004,7 @@ static ssize_t gasket_sysfs_data_show( } break; default: - gasket_log_error( + gasket_log_debug( gasket_dev, "Unknown attribute: %s", attr->attr.name); ret = 0; break; @@ -2056,7 +2058,7 @@ int gasket_wait_with_reschedule( msleep(delay_ms); retries++; } - gasket_log_error(gasket_dev, "%s timeout: reg %llx timeout (%llu ms)", + gasket_log_debug(gasket_dev, "%s timeout: reg %llx timeout (%llu ms)", __func__, offset, max_retries * delay_ms); return -ETIMEDOUT; } From 040c626008e9e2f332caf16f25f2ca708cfcc480 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:03 -0700 Subject: [PATCH 517/903] staging: gasket: interrupts: convert various logs to debug level Debugging information is improperly logged at non-debug log level in a number of places, and some logs regarding error conditions may be generated too frequently, such that these could cause performance problems and/or obscure other logs. Convert these to debug log level. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index d096ce73cc8b..2b8c26d06533 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -287,7 +287,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) int ret; if (!gasket_dev->interrupt_data) { - gasket_log_error( + gasket_log_debug( gasket_dev, "Attempted to reinit uninitialized interrupt data."); return -EINVAL; @@ -305,7 +305,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) case PCI_MSI: case PLATFORM_WIRE: default: - gasket_nodev_error( + gasket_nodev_debug( "Cannot handle unsupported interrupt type %d.", gasket_dev->interrupt_data->type); ret = -EINVAL; @@ -351,7 +351,7 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) gasket_dev->interrupt_data; if (!interrupt_data) { - gasket_log_error( + gasket_log_debug( gasket_dev, "Interrupt data is not initialized."); return; } @@ -365,7 +365,7 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) } if (interrupt_data->type != PCI_MSIX) { - gasket_nodev_error( + gasket_nodev_debug( "Cannot handle unsupported interrupt type %d.", interrupt_data->type); return; @@ -403,7 +403,7 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) pack_shift = 3 * interrupt_data->pack_width; break; default: - gasket_nodev_error( + gasket_nodev_debug( "Found interrupt description with " "unknown enum %d.", interrupt_data->interrupts[i].packing); @@ -445,7 +445,7 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) case PCI_MSI: case PLATFORM_WIRE: default: - gasket_nodev_error( + gasket_nodev_debug( "Cannot handle unsupported interrupt type %d.", interrupt_data->type); }; @@ -460,18 +460,18 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) int gasket_interrupt_system_status(struct gasket_dev *gasket_dev) { if (!gasket_dev->interrupt_data) { - gasket_nodev_info("Interrupt data is null."); + gasket_nodev_debug("Interrupt data is null."); return GASKET_STATUS_DEAD; } if (!gasket_dev->interrupt_data->msix_configured) { - gasket_nodev_info("Interrupt not initialized."); + gasket_nodev_debug("Interrupt not initialized."); return GASKET_STATUS_LAMED; } if (gasket_dev->interrupt_data->num_configured != gasket_dev->interrupt_data->num_interrupts) { - gasket_nodev_info("Not all interrupts were configured."); + gasket_nodev_debug("Not all interrupts were configured."); return GASKET_STATUS_LAMED; } @@ -516,14 +516,14 @@ static ssize_t interrupt_sysfs_show( gasket_dev = gasket_sysfs_get_device_data(device); if (!gasket_dev) { - gasket_nodev_error( + gasket_nodev_debug( "No sysfs mapping found for device 0x%p", device); return 0; } gasket_attr = gasket_sysfs_get_attr(device, attr); if (!gasket_attr) { - gasket_nodev_error( + gasket_nodev_debug( "No sysfs attr data found for device 0x%p", device); gasket_sysfs_put_device_data(device, gasket_dev); return 0; @@ -545,7 +545,7 @@ static ssize_t interrupt_sysfs_show( ret = total_written; break; default: - gasket_log_error( + gasket_log_debug( gasket_dev, "Unknown attribute: %s", attr->attr.name); ret = 0; break; From 1d079f20d5aaab58ac6ccc3afd849f7ccebf28a1 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:04 -0700 Subject: [PATCH 518/903] staging: gasket: ioctl common: convert various logs to debug level Debugging information is improperly logged at non-debug log level in a number of places, and some logs regarding error conditions may be generated too frequently, such that these could cause performance problems and/or obscure other logs. Convert these to debug log level. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 2 +- drivers/staging/gasket/gasket_ioctl.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 1d04fd0990e4..732218773c3c 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1801,7 +1801,7 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) if (driver_desc->ioctl_handler_cb) return driver_desc->ioctl_handler_cb(filp, cmd, argp); - gasket_log_error( + gasket_log_debug( gasket_dev, "Received unknown ioctl 0x%x", cmd); return -EINVAL; } diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 8cf094b90cdb..63e139ab7ff8 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -73,7 +73,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) } } else if (!gasket_ioctl_check_permissions(filp, cmd)) { trace_gasket_ioctl_exit(-EPERM); - gasket_log_error(gasket_dev, "ioctl cmd=%x noperm.", cmd); + gasket_log_debug(gasket_dev, "ioctl cmd=%x noperm.", cmd); return -EPERM; } @@ -132,7 +132,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) * the arg. */ trace_gasket_ioctl_integer_data(arg); - gasket_log_warn( + gasket_log_debug( gasket_dev, "Unknown ioctl cmd=0x%x not caught by " "gasket_is_supported_ioctl", @@ -329,7 +329,7 @@ static int gasket_partition_page_table( gasket_dev->page_table[ibuf.page_table_index]); if (ibuf.size > max_page_table_size) { - gasket_log_error( + gasket_log_debug( gasket_dev, "Partition request 0x%llx too large, max is 0x%x.", ibuf.size, max_page_table_size); From 37d7b0efabc56338370ca37a77ce69387b0a4373 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:05 -0700 Subject: [PATCH 519/903] staging: gasket: page table: convert various logs to debug level Debugging information is improperly logged at non-debug log level in a number of places, and some logs regarding error conditions may be generated too frequently, such that these could cause performance problems and/or obscure other logs. Convert these to debug log level. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 9f8116112e0a..f0c4884cb4bc 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -306,7 +306,7 @@ int gasket_page_table_init( * hardware register that contains the page table size. */ if (total_entries == ULONG_MAX) { - gasket_nodev_error( + gasket_nodev_debug( "Error reading page table size. " "Initializing page table with size 0."); total_entries = 0; @@ -323,7 +323,7 @@ int gasket_page_table_init( *ppg_tbl = kzalloc(sizeof(**ppg_tbl), GFP_KERNEL); if (!*ppg_tbl) { - gasket_nodev_error("No memory for page table."); + gasket_nodev_debug("No memory for page table."); return -ENOMEM; } @@ -332,7 +332,7 @@ int gasket_page_table_init( if (bytes != 0) { pg_tbl->entries = vmalloc(bytes); if (!pg_tbl->entries) { - gasket_nodev_error( + gasket_nodev_debug( "No memory for address translation metadata."); kfree(pg_tbl); *ppg_tbl = NULL; @@ -658,7 +658,7 @@ int gasket_page_table_system_status(struct gasket_page_table *page_table) } if (gasket_page_table_num_entries(page_table) == 0) { - gasket_nodev_error("Page table size is 0."); + gasket_nodev_debug("Page table size is 0."); return GASKET_STATUS_LAMED; } @@ -903,7 +903,7 @@ static int gasket_perform_mapping( (unsigned long long)ptes[i].dma_addr); if (ptes[i].dma_addr == -1) { - gasket_nodev_error( + gasket_nodev_debug( "%s i %d" " -> fail to map page %llx " "[pfn %p ohys %p]\n", @@ -1612,7 +1612,7 @@ int gasket_set_user_virt( */ pg_tbl = gasket_dev->page_table[0]; if (!pg_tbl) { - gasket_nodev_error( + gasket_nodev_debug( "%s: invalid page table index", __func__); return 0; } From 0322bad3b507a74e9fed302c875bc3371df0dca8 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:06 -0700 Subject: [PATCH 520/903] staging: gasket: page table: remove unnecessary logs Some error logs in page table handling code could only be hit in cases of programming errors not expected in the current code base, and aren't likely to be useful on their own. Remove these. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 23 +++++----------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index f0c4884cb4bc..4f2ff7700658 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -605,10 +605,8 @@ EXPORT_SYMBOL(gasket_page_table_is_dev_addr_bad); /* See gasket_page_table.h for description. */ uint gasket_page_table_max_size(struct gasket_page_table *page_table) { - if (!page_table) { - gasket_nodev_error("Passed a null page table."); + if (!page_table) return 0; - } return page_table->config.total_entries; } EXPORT_SYMBOL(gasket_page_table_max_size); @@ -616,11 +614,8 @@ EXPORT_SYMBOL(gasket_page_table_max_size); /* See gasket_page_table.h for description. */ uint gasket_page_table_num_entries(struct gasket_page_table *pg_tbl) { - if (!pg_tbl) { - gasket_nodev_error("Passed a null page table."); + if (!pg_tbl) return 0; - } - return pg_tbl->num_simple_entries + pg_tbl->num_extended_entries; } EXPORT_SYMBOL(gasket_page_table_num_entries); @@ -628,11 +623,8 @@ EXPORT_SYMBOL(gasket_page_table_num_entries); /* See gasket_page_table.h for description. */ uint gasket_page_table_num_simple_entries(struct gasket_page_table *pg_tbl) { - if (!pg_tbl) { - gasket_nodev_error("Passed a null page table."); + if (!pg_tbl) return 0; - } - return pg_tbl->num_simple_entries; } EXPORT_SYMBOL(gasket_page_table_num_simple_entries); @@ -640,11 +632,8 @@ EXPORT_SYMBOL(gasket_page_table_num_simple_entries); /* See gasket_page_table.h for description. */ uint gasket_page_table_num_active_pages(struct gasket_page_table *pg_tbl) { - if (!pg_tbl) { - gasket_nodev_error("Passed a null page table."); + if (!pg_tbl) return 0; - } - return pg_tbl->num_active_pages; } EXPORT_SYMBOL(gasket_page_table_num_active_pages); @@ -652,10 +641,8 @@ EXPORT_SYMBOL(gasket_page_table_num_active_pages); /* See gasket_page_table.h */ int gasket_page_table_system_status(struct gasket_page_table *page_table) { - if (!page_table) { - gasket_nodev_error("Passed a null page table."); + if (!page_table) return GASKET_STATUS_LAMED; - } if (gasket_page_table_num_entries(page_table) == 0) { gasket_nodev_debug("Page table size is 0."); From afa9e31818a00b5a519429df343b1406488cd5a6 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 21 Jul 2018 06:35:07 -0700 Subject: [PATCH 521/903] staging: gasket: apex: convert various logs to debug level Debugging information is improperly logged at non-debug log level in a number of places, and some logs regarding error conditions may be generated too frequently, such that these could cause performance problems and/or obscure other logs. Convert these to debug log level. Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 1c6f73b5a2a9..6396b18b246a 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -420,7 +420,7 @@ static int apex_device_cleanup(struct gasket_dev *gasket_dev) gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS); - gasket_log_info( + gasket_log_debug( gasket_dev, "%s 0x%p hib_error 0x%llx scalar_error " "0x%llx.", @@ -589,7 +589,7 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); val1 = gasket_dev_read_32( gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); - gasket_log_error( + gasket_log_debug( gasket_dev, "Disallow HW clock gating 0x%x -> 0x%x", val0, val1); } else { @@ -602,7 +602,7 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); val1 = gasket_dev_read_32( gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); - gasket_log_error( + gasket_log_debug( gasket_dev, "Allow HW clock gating 0x%x -> 0x%x", val0, val1); } @@ -668,7 +668,7 @@ static long apex_clock_gating(struct gasket_dev *gasket_dev, if (copy_from_user(&ibuf, argp, sizeof(ibuf))) return -EFAULT; - gasket_log_error(gasket_dev, "%s %llu", __func__, ibuf.enable); + gasket_log_debug(gasket_dev, "%s %llu", __func__, ibuf.enable); if (ibuf.enable) { /* Quiesce AXI, gate GCB clock. */ @@ -738,7 +738,7 @@ static ssize_t sysfs_show( gasket_dev->page_table[0])); break; default: - gasket_log_error( + gasket_log_debug( gasket_dev, "Unknown attribute: %s", attr->attr.name); ret = 0; break; From 24b9bdff8d0848029dba1c80b196b43e80b39463 Mon Sep 17 00:00:00 2001 From: Ivan Bornyakov Date: Mon, 23 Jul 2018 21:30:25 +0300 Subject: [PATCH 522/903] staging: gasket: use vzalloc instead of vmalloc/memset Use vzalloc instead of vmalloc followed by memset with 0. Signed-off-by: Ivan Bornyakov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 4f2ff7700658..55ab59303247 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -330,7 +330,7 @@ int gasket_page_table_init( pg_tbl = *ppg_tbl; bytes = total_entries * sizeof(struct gasket_page_table_entry); if (bytes != 0) { - pg_tbl->entries = vmalloc(bytes); + pg_tbl->entries = vzalloc(bytes); if (!pg_tbl->entries) { gasket_nodev_debug( "No memory for address translation metadata."); @@ -338,7 +338,6 @@ int gasket_page_table_init( *ppg_tbl = NULL; return -ENOMEM; } - memset(pg_tbl->entries, 0, bytes); } mutex_init(&pg_tbl->mutex); @@ -1054,13 +1053,12 @@ static int gasket_alloc_extended_subtable( subtable_bytes = sizeof(struct gasket_page_table_entry) * GASKET_PAGES_PER_SUBTABLE; - pte->sublevel = vmalloc(subtable_bytes); + pte->sublevel = vzalloc(subtable_bytes); if (!pte->sublevel) { free_page(page_addr); memset(pte, 0, sizeof(struct gasket_page_table_entry)); return -ENOMEM; } - memset(pte->sublevel, 0, subtable_bytes); /* Map the page into DMA space. */ if (pg_tbl->dma_ops) { From 5b70084f6cbcd53f615433f9d216e01bd71de0bb Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Sat, 21 Jul 2018 13:31:24 +0200 Subject: [PATCH 523/903] staging: bcm2835-camera: handle wait_for_completion_timeout return properly wait_for_completion_timeout returns unsigned long not int so a variable of proper type is introduced. Further the check for <= 0 is ambiguous and should be == 0 here indicating timeout. Signed-off-by: Nicholas Mc Guire Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index ce26741ae9d9..3f61d04c47ab 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -580,6 +580,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) static void stop_streaming(struct vb2_queue *vq) { int ret; + unsigned long timeout; struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq); v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n", @@ -605,10 +606,10 @@ static void stop_streaming(struct vb2_queue *vq) sizeof(dev->capture.frame_count)); /* wait for last frame to complete */ - ret = wait_for_completion_timeout(&dev->capture.frame_cmplt, HZ); - if (ret <= 0) + timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt, HZ); + if (timeout == 0) v4l2_err(&dev->v4l2_dev, - "error %d waiting for frame completion\n", ret); + "timed out waiting for frame completion\n"); v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "disabling connection\n"); From 1ef5c96081d849a00dc973733cde3b595fc38442 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Mon, 23 Jul 2018 00:18:01 +0530 Subject: [PATCH 524/903] staging: dgnc: dgnc_tty.c: Avoid '(' at the end of line Bring the first argument to the previous line, remove a superfluous () in the second argument by using !, and align the lines to match open parenthesis. Issue found by checkpatch. Signed-off-by: Nishad Kamdar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 9f9b9a5b4b27..f91eaa1c3b67 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -883,10 +883,9 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) * touched safely, the close routine will signal the * ch_flags_wait to wake us back up. */ - rc = wait_event_interruptible( - ch->ch_flags_wait, - (((ch->ch_tun.un_flags | - ch->ch_pun.un_flags) & UN_CLOSING) == 0)); + rc = wait_event_interruptible(ch->ch_flags_wait, + !((ch->ch_tun.un_flags | + ch->ch_pun.un_flags) & UN_CLOSING)); /* If ret is non-zero, user ctrl-c'ed us */ if (rc) return -EINTR; From b7afce51d95726a619743aaad8870db66dfa1479 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Sat, 21 Jul 2018 15:20:28 +0200 Subject: [PATCH 525/903] staging: bcm2835-camera: fix timeout handling in wait_for_completion_timeout wait_for_completion_timeout returns unsigned long not int so a variable of proper type is introduced. Further the check for <= 0 is ambiguous and should be == 0 here indicating timeout which is the only error case so no additional check needed here. Signed-off-by: Nicholas Mc Guire Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index f5b5ead6347c..51e5b04ff0f5 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -630,6 +630,7 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, { struct mmal_msg_context *msg_context; int ret; + unsigned long timeout; /* payload size must not cause message to exceed max size */ if (payload_len > @@ -668,11 +669,11 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, return ret; } - ret = wait_for_completion_timeout(&msg_context->u.sync.cmplt, 3 * HZ); - if (ret <= 0) { - pr_err("error %d waiting for sync completion\n", ret); - if (ret == 0) - ret = -ETIME; + timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt, + 3 * HZ); + if (timeout == 0) { + pr_err("timed out waiting for sync completion\n"); + ret = -ETIME; /* todo: what happens if the message arrives after aborting */ release_msg_context(msg_context); return ret; From e360c0ea438fc4fff86f0a709f411f4385aa8af6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:35 +0200 Subject: [PATCH 526/903] staging: rtl8188eu: remove blank lines Remove unrequired blank lines reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 1 - drivers/staging/rtl8188eu/hal/phy.c | 3 --- drivers/staging/rtl8188eu/hal/rf.c | 1 - drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 5 ----- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2 -- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/hal/usb_halinit.c | 1 - drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 17 ----------------- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 3 --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 ---- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 - .../staging/rtl8188eu/os_dep/usb_ops_linux.c | 14 -------------- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 4 ---- 13 files changed, 57 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 8d087b05df6e..1f21728f5084 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -156,7 +156,6 @@ u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = { {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */ }; - #define RxDefaultAnt1 0x65a9 #define RxDefaultAnt2 0x569a diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 2ede7cf2371b..0fe2d53310f0 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -352,7 +352,6 @@ void rtl88eu_dm_txpower_track_adjust(struct odm_dm_struct *dm_odm, u8 type, pwr_value = dm_odm->BbSwingIdxCck - dm_odm->BbSwingIdxCckBase; } - } if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *direction == 1) @@ -879,7 +878,6 @@ static void mac_setting_calibration(struct adapter *adapt, u32 *mac_reg, u32 *ba static void path_a_standby(struct adapter *adapt) { - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x0); phy_set_bb_reg(adapt, 0x840, bMaskDWord, 0x00010000); phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); @@ -1003,7 +1001,6 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], retry_count = 2; if (t == 0) { - /* Save ADDA parameters, turn Path A ADDA on */ save_adda_registers(adapt, adda_reg, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); diff --git a/drivers/staging/rtl8188eu/hal/rf.c b/drivers/staging/rtl8188eu/hal/rf.c index 39bc3afdf991..81e30a1a6bfd 100644 --- a/drivers/staging/rtl8188eu/hal/rf.c +++ b/drivers/staging/rtl8188eu/hal/rf.c @@ -44,7 +44,6 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) u8 *ptr; u8 direction; - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { tx_agc[RF_PATH_A] = 0x3f3f3f3f; tx_agc[RF_PATH_B] = 0x3f3f3f3f; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index db5d4375277e..b832bbf202a5 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -57,7 +57,6 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p u32 h2c_cmd_ex = 0; s32 ret = _FAIL; - if (!adapt->bFWReady) { DBG_88E("%s(): return H2C cmd because fw is not ready\n", __func__); @@ -110,8 +109,6 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p ret = _SUCCESS; exit: - - return ret; } @@ -196,7 +193,6 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) H2CSetPwrMode.PwrState = 0x0C;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode); - } void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) @@ -554,7 +550,6 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) u8 DLBcnCount = 0; u32 poll = 0; - DBG_88E("%s mstatus(%x)\n", __func__, mstatus); if (mstatus == 1) { diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 0f92cc9d3bbe..8e7190b98692 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -70,7 +70,6 @@ static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) return rst; } - s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) { s32 result = _SUCCESS; @@ -399,7 +398,6 @@ static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) else if (chnl == 14) /* Channel 14 */ *pGroup = 5; } else { - /* probably, this branch is suitable only for 5 GHz */ bIn24G = false; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 8979e27b092f..c0d51ba70a75 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -87,7 +87,6 @@ void rtw_hal_free_recv_priv(struct adapter *padapter) DBG_88E(KERN_WARNING "rx_skb_queue not empty\n"); skb_queue_purge(&precvpriv->rx_skb_queue); - if (skb_queue_len(&precvpriv->free_recv_skb_queue)) DBG_88E(KERN_WARNING "free_recv_skb_queue not empty, %d\n", skb_queue_len(&precvpriv->free_recv_skb_queue)); diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index d551d0cca90b..56fda8005d38 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -994,7 +994,6 @@ exit: RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); - return status; } diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 0f82a8c330f8..8da43022bb40 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1283,7 +1283,6 @@ static int rtw_wx_set_essid(struct net_device *dev, uint ret = 0, len; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); if (_FAIL == rtw_pwr_wakeup(padapter)) { @@ -1365,10 +1364,8 @@ static int rtw_wx_set_essid(struct net_device *dev, } exit: - DBG_88E("<=%s, ret %d\n", __func__, ret); - return ret; } @@ -1383,7 +1380,6 @@ static int rtw_wx_get_essid(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); - if ((check_fwstate(pmlmepriv, _FW_LINKED)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { len = pcur_bss->Ssid.SsidLength; @@ -1409,7 +1405,6 @@ static int rtw_wx_set_rate(struct net_device *dev, u32 ratevalue = 0; u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); @@ -1501,7 +1496,6 @@ static int rtw_wx_set_rts(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - if (wrqu->rts.disabled) { padapter->registrypriv.rts_thresh = 2347; } else { @@ -1514,7 +1508,6 @@ static int rtw_wx_set_rts(struct net_device *dev, DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); - return 0; } @@ -1524,14 +1517,12 @@ static int rtw_wx_get_rts(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); wrqu->rts.value = padapter->registrypriv.rts_thresh; wrqu->rts.fixed = 0; /* no auto select */ /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ - return 0; } @@ -1541,7 +1532,6 @@ static int rtw_wx_set_frag(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - if (wrqu->frag.disabled) { padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; } else { @@ -1554,7 +1544,6 @@ static int rtw_wx_set_frag(struct net_device *dev, DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); - return 0; } @@ -1564,13 +1553,11 @@ static int rtw_wx_get_frag(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); wrqu->frag.value = padapter->xmitpriv.frag_len; wrqu->frag.fixed = 0; /* no auto select */ - return 0; } @@ -1604,7 +1591,6 @@ static int rtw_wx_set_enc(struct net_device *dev, key = erq->flags & IW_ENCODE_INDEX; - if (erq->flags & IW_ENCODE_DISABLED) { DBG_88E("EncryptionDisabled\n"); padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; @@ -1697,8 +1683,6 @@ static int rtw_wx_set_enc(struct net_device *dev, } exit: - - return ret; } @@ -1711,7 +1695,6 @@ static int rtw_wx_get_enc(struct net_device *dev, struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { erq->length = 0; diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c index aa08793699ca..238c1d9cdc7b 100644 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -5,7 +5,6 @@ * ******************************************************************************/ - #define _MLME_OSDEP_C_ #include @@ -142,7 +141,6 @@ void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *pst if (pstapriv->sta_aid[psta->aid - 1] != psta) return; - wrqu.addr.sa_family = ARPHRD_ETHER; memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); @@ -166,7 +164,6 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info * if (pstapriv->sta_aid[psta->aid - 1] != psta) return; - wrqu.addr.sa_family = ARPHRD_ETHER; memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 8dd17986d969..9b810c76d6de 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -355,7 +355,6 @@ void rtw_stop_drv_threads(struct adapter *padapter) complete(&padapter->cmdpriv.cmd_queue_comp); if (padapter->cmdThread) wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp); - } static u8 rtw_init_default_value(struct adapter *padapter) @@ -433,7 +432,6 @@ u8 rtw_init_drv_sw(struct adapter *padapter) { u8 ret8 = _SUCCESS; - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n")); if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) { @@ -490,7 +488,6 @@ u8 rtw_init_drv_sw(struct adapter *padapter) exit: RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n")); - return ret8; } @@ -653,7 +650,6 @@ netdev_open_error: return _FAIL; } - int rtw_ips_pwr_up(struct adapter *padapter) { int result; diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 0d0517d226a6..025cd0f59718 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -133,7 +133,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) } usb_put_dev(interface_to_usbdev(usb_intf)); - } void usb_intf_stop(struct adapter *padapter) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 20727ad83e01..7c3e744cc4a9 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -267,7 +267,6 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i } } } - } /* firmware download is checksumed, don't retry */ @@ -291,7 +290,6 @@ u8 usb_read8(struct adapter *adapter, u32 addr) u16 len; u8 data = 0; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -301,9 +299,7 @@ u8 usb_read8(struct adapter *adapter, u32 addr) usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); - return data; - } u16 usb_read16(struct adapter *adapter, u32 addr) @@ -334,7 +330,6 @@ u32 usb_read32(struct adapter *adapter, u32 addr) u16 len; __le32 data; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -344,7 +339,6 @@ u32 usb_read32(struct adapter *adapter, u32 addr) usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); - return le32_to_cpu(data); } @@ -429,7 +423,6 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf) unsigned int pipe; u32 ret = _SUCCESS; - if (adapter->bDriverStopped || adapter->bSurpriseRemoved || adapter->pwrctrlpriv.pnp_bstop_trx) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, @@ -532,7 +525,6 @@ int usb_write16(struct adapter *adapter, u32 addr, u16 val) u16 len; __le32 data; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -544,8 +536,6 @@ int usb_write16(struct adapter *adapter, u32 addr, u16 val) return usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); - - } int usb_write32(struct adapter *adapter, u32 addr, u32 val) @@ -557,7 +547,6 @@ int usb_write32(struct adapter *adapter, u32 addr, u32 val) u16 len; __le32 data; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -568,8 +557,6 @@ int usb_write32(struct adapter *adapter, u32 addr, u32 val) return usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); - - } static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) @@ -663,7 +650,6 @@ u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf struct xmit_frame *pxmitframe = (struct xmit_frame *)xmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n")); if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) || diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index a4210aaf300c..85cde696d369 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -156,7 +156,6 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) return true; } - int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); @@ -164,7 +163,6 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; s32 res = 0; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); if (rtw_if_up(padapter) == false) { @@ -198,7 +196,5 @@ drop_packet: RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, ("rtw_xmit_entry: drop, tx_drop=%d\n", (u32)pxmitpriv->tx_drop)); exit: - - return 0; } From 0f3e250f2efc9232e381de97fa7764adafce8975 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:36 +0200 Subject: [PATCH 527/903] staging: rtl8188eu: refactor rtw_is_cckrates_included() Refactor rtw_is_cckrates_included() to improve readability and slightly reduce object file size. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index b7188fa5364a..b695f47be073 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -74,14 +74,14 @@ int rtw_get_bit_value_from_ieee_value(u8 val) uint rtw_is_cckrates_included(u8 *rate) { - u32 i = 0; + while (*rate) { + u8 r = *rate & 0x7f; - while (rate[i] != 0) { - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + if (r == 2 || r == 4 || r == 11 || r == 22) return true; - i++; + rate++; } + return false; } From 2c93b22aaafb7e2fb9c0bee69f5068d720d09d33 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:37 +0200 Subject: [PATCH 528/903] staging: rtl8188eu: refactor rtw_is_cckratesonly_included() Refactor rtw_is_cckratesonly_included() to improve readability and slightly reduce object file size. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index b695f47be073..77eca07c92aa 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -87,13 +87,12 @@ uint rtw_is_cckrates_included(u8 *rate) uint rtw_is_cckratesonly_included(u8 *rate) { - u32 i = 0; + while (*rate) { + u8 r = *rate & 0x7f; - while (rate[i] != 0) { - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + if (r != 2 && r != 4 && r != 11 && r != 22) return false; - i++; + rate++; } return true; From a0cec709e17ae6d357c742bac0cbd6f7f84af998 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:38 +0200 Subject: [PATCH 529/903] staging: rtl8188eu: change return type to bool Both rtw_is_cckrates_included() and rtw_is_cckratesonly_included() return true or false. Change the return type from uint to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8188eu/include/ieee80211.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 77eca07c92aa..d48840869307 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -72,7 +72,7 @@ int rtw_get_bit_value_from_ieee_value(u8 val) return 0; } -uint rtw_is_cckrates_included(u8 *rate) +bool rtw_is_cckrates_included(u8 *rate) { while (*rate) { u8 r = *rate & 0x7f; @@ -85,7 +85,7 @@ uint rtw_is_cckrates_included(u8 *rate) return false; } -uint rtw_is_cckratesonly_included(u8 *rate) +bool rtw_is_cckratesonly_included(u8 *rate) { while (*rate) { u8 r = *rate & 0x7f; diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index 3fbd92a95b17..c60b833ca110 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -767,9 +767,9 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv); int rtw_get_bit_value_from_ieee_value(u8 val); -uint rtw_is_cckrates_included(u8 *rate); +bool rtw_is_cckrates_included(u8 *rate); -uint rtw_is_cckratesonly_included(u8 *rate); +bool rtw_is_cckratesonly_included(u8 *rate); int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); From 8c438b738e476f875ab362bea550ae2db8d9c31a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:39 +0200 Subject: [PATCH 530/903] staging: rtl8188eu: fix comparsions to true Use if(x) instead of if(x == true). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 6 +++--- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index d48840869307..9db19724f168 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -101,14 +101,14 @@ bool rtw_is_cckratesonly_included(u8 *rate) int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) { if (channel > 14) { - if ((rtw_is_cckrates_included(rate)) == true) + if (rtw_is_cckrates_included(rate)) return WIRELESS_INVALID; else return WIRELESS_11A; } else { /* could be pure B, pure G, or B/G */ - if ((rtw_is_cckratesonly_included(rate)) == true) + if (rtw_is_cckratesonly_included(rate)) return WIRELESS_11B; - else if ((rtw_is_cckrates_included(rate)) == true) + else if (rtw_is_cckrates_included(rate)) return WIRELESS_11BG; else return WIRELESS_11G; diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 8da43022bb40..221fae22bab6 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -642,12 +642,12 @@ static int rtw_wx_get_name(struct net_device *dev, prates = &pcur_bss->SupportedRates; - if (rtw_is_cckratesonly_included((u8 *)prates) == true) { + if (rtw_is_cckratesonly_included((u8 *)prates)) { if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); - } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) { + } else if (rtw_is_cckrates_included((u8 *)prates)) { if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); else From 4964e934a66dae049c643b56cab1f9659d0f7e89 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:40 +0200 Subject: [PATCH 531/903] staging: rtl8188eu: remove unnecessary parentheses Remove unnecessary parentheses. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_ieee80211.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 9db19724f168..1259cfd8098d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -40,18 +40,18 @@ u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 }; /* */ static u8 WIFI_CCKRATES[] = { - (IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK), - (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK), - (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK), - (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK) + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; static u8 WIFI_OFDMRATES[] = { - (IEEE80211_OFDM_RATE_6MB), - (IEEE80211_OFDM_RATE_9MB), - (IEEE80211_OFDM_RATE_12MB), - (IEEE80211_OFDM_RATE_18MB), - (IEEE80211_OFDM_RATE_24MB), + IEEE80211_OFDM_RATE_6MB, + IEEE80211_OFDM_RATE_9MB, + IEEE80211_OFDM_RATE_12MB, + IEEE80211_OFDM_RATE_18MB, + IEEE80211_OFDM_RATE_24MB, IEEE80211_OFDM_RATE_36MB, IEEE80211_OFDM_RATE_48MB, IEEE80211_OFDM_RATE_54MB @@ -919,7 +919,7 @@ void rtw_macaddr_cfg(u8 *mac_addr) DBG_88E("MAC Address from efuse error, assign random one !!!\n"); } - DBG_88E("%s MAC Address = %pM\n", __func__, (mac_addr)); + DBG_88E("%s MAC Address = %pM\n", __func__, mac_addr); } static int rtw_get_cipher_info(struct wlan_network *pnetwork) From 9f95c49e56c421d9287346aefb986845135fc466 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:41 +0200 Subject: [PATCH 532/903] staging: rtl8188eu: replace tabs with spaces Replace tabs with spaces or just remove tabs where appropriate. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 1259cfd8098d..7d5cbaf50f1c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -39,14 +39,14 @@ u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 }; /* for adhoc-master to generate ie and provide supported-rate to fw */ /* */ -static u8 WIFI_CCKRATES[] = { +static u8 WIFI_CCKRATES[] = { IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK - }; +}; -static u8 WIFI_OFDMRATES[] = { +static u8 WIFI_OFDMRATES[] = { IEEE80211_OFDM_RATE_6MB, IEEE80211_OFDM_RATE_9MB, IEEE80211_OFDM_RATE_12MB, @@ -55,7 +55,7 @@ static u8 WIFI_OFDMRATES[] = { IEEE80211_OFDM_RATE_36MB, IEEE80211_OFDM_RATE_48MB, IEEE80211_OFDM_RATE_54MB - }; +}; int rtw_get_bit_value_from_ieee_value(u8 val) { @@ -492,7 +492,7 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, { u8 authmode, sec_idx, i; u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; - uint cnt; + uint cnt; /* Search required WPA or WPA2 IE and copy to sec_ie[] */ @@ -970,7 +970,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) u16 wpa_len = 0, rsn_len = 0; struct HT_info_element *pht_info = NULL; uint len; - unsigned char *p; + unsigned char *p; memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.ies), 2); cap = le16_to_cpu(le_tmp); From 9a3620800edeb35d00e33fafdc3eec215fc8c1f5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Jul 2018 20:57:42 +0200 Subject: [PATCH 533/903] staging: rtl8188eu: fix lines over 80 characters Fix two lines over 80 characters by removing unnecessary parentheses. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 7c3e744cc4a9..c69edb7d174c 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -20,8 +20,8 @@ static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbu } /* HISR */ - memcpy(&(haldata->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); - memcpy(&(haldata->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); + memcpy(&haldata->IntArray[0], &pbuf[USB_INTR_CONTENT_HISR_OFFSET], 4); + memcpy(&haldata->IntArray[1], &pbuf[USB_INTR_CONTENT_HISRE_OFFSET], 4); /* C2H Event */ if (pbuf[0] != 0) From cb72b2f6dfa954d5c18df69cf789190310a0c545 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:43 +0100 Subject: [PATCH 534/903] staging:rtl8192u: Rename TClasProc > t_clas_proc - Style Rename the struct TS_COMMON_INFO member variable TClasProc to t_clas_proc. This change clears the checkpatch issue with CamelCase variable names. There should be no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 3bf48a04a68e..a183198afb31 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -22,7 +22,7 @@ struct ts_common_info { u8 addr[6]; TSPEC_BODY t_spec; QOS_TCLAS t_class[TCLAS_NUM]; - u8 TClasProc; + u8 t_clas_proc; u8 TClasNum; }; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index b5fede650b81..8b2bb0a69b01 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -106,7 +106,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) eth_zero_addr(pTsCommonInfo->addr); memset(&pTsCommonInfo->t_spec, 0, sizeof(TSPEC_BODY)); memset(&pTsCommonInfo->t_class, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); - pTsCommonInfo->TClasProc = 0; + pTsCommonInfo->t_clas_proc = 0; pTsCommonInfo->TClasNum = 0; } @@ -281,7 +281,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, for(count = 0; count < TCLAS_Num; count++) memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS)); - pTsCommonInfo->TClasProc = TCLAS_Proc; + pTsCommonInfo->t_clas_proc = TCLAS_Proc; pTsCommonInfo->TClasNum = TCLAS_Num; } From 32cb4d731a9fb2385cc2638f69416e31435261a4 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:44 +0100 Subject: [PATCH 535/903] staging:rtl8192u: Rename TClasNum > t_clas_num - Style Rename the struct TS_COMMON_INFO member variable TClasNum to t_clas_num. This change clears the checkpatch issue with CamelCase naming. There should be no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index a183198afb31..3da1ef6ef105 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -23,7 +23,7 @@ struct ts_common_info { TSPEC_BODY t_spec; QOS_TCLAS t_class[TCLAS_NUM]; u8 t_clas_proc; - u8 TClasNum; + u8 t_clas_num; }; typedef struct _TX_TS_RECORD { diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 8b2bb0a69b01..4b2da7f31166 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -107,7 +107,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) memset(&pTsCommonInfo->t_spec, 0, sizeof(TSPEC_BODY)); memset(&pTsCommonInfo->t_class, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); pTsCommonInfo->t_clas_proc = 0; - pTsCommonInfo->TClasNum = 0; + pTsCommonInfo->t_clas_num = 0; } static void ResetTxTsEntry(PTX_TS_RECORD pTS) @@ -282,7 +282,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS)); pTsCommonInfo->t_clas_proc = TCLAS_Proc; - pTsCommonInfo->TClasNum = TCLAS_Num; + pTsCommonInfo->t_clas_num = TCLAS_Num; } From 3c22fbaf3bc685ac5691852fb25e0ff6d3510f24 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:45 +0100 Subject: [PATCH 536/903] staging:rtl8192u: Remove typedef and rename struct RT_DOT11D_INFO - Style Removed the typedef from structure RT_DOT11D_INFO. This change clears the checkpatch issue with declaring new types. Rename the structure from RT_DOT11D_INFO to rt_dot11d_info. Coding style changes which should not impact runtime execution of code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 14 +++++++------- drivers/staging/rtl8192u/ieee80211/dot11d.h | 11 ++++++----- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index 44b5e506b140..cd63e158c7c8 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -5,7 +5,7 @@ void Dot11d_Init(struct ieee80211_device *ieee) { - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee); + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee); pDot11dInfo->bEnabled = false; @@ -23,7 +23,7 @@ EXPORT_SYMBOL(Dot11d_Init); void Dot11d_Reset(struct ieee80211_device *ieee) { u32 i; - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee); + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee); /* Clear old channel map */ memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); @@ -52,7 +52,7 @@ EXPORT_SYMBOL(Dot11d_Reset); void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, u16 CoutryIeLen, u8 *pCoutryIe) { - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); u8 i, j, NumTriples, MaxChnlNum; struct chnl_txpower_triple *pTriple; @@ -101,7 +101,7 @@ EXPORT_SYMBOL(Dot11d_UpdateCountryIe); u8 DOT11D_GetMaxTxPwrInDbm(struct ieee80211_device *dev, u8 Channel) { - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); u8 MaxTxPwrInDbm = 255; if (Channel > MAX_CHANNEL_NUMBER) { @@ -117,7 +117,7 @@ EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm); void DOT11D_ScanComplete(struct ieee80211_device *dev) { - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); switch (pDot11dInfo->State) { case DOT11D_STATE_LEARNED: @@ -138,7 +138,7 @@ EXPORT_SYMBOL(DOT11D_ScanComplete); int IsLegalChannel(struct ieee80211_device *dev, u8 channel) { - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); if (channel > MAX_CHANNEL_NUMBER) { netdev_err(dev->dev, "IsLegalChannel(): Invalid Channel\n"); @@ -152,7 +152,7 @@ EXPORT_SYMBOL(IsLegalChannel); int ToLegalChannel(struct ieee80211_device *dev, u8 channel) { - PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); + struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); u8 default_chn = 0; u32 i = 0; diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 9402c05cb24f..8f7426333da5 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -16,8 +16,8 @@ enum dot11d_state { DOT11D_STATE_DONE, }; -typedef struct _RT_DOT11D_INFO { - /* DECLARE_RT_OBJECT(RT_DOT11D_INFO); */ +struct rt_dot11d_info { + /* DECLARE_RT_OBJECT(rt_dot11d_info); */ bool bEnabled; /* dot11MultiDomainCapabilityEnabled */ @@ -30,15 +30,16 @@ typedef struct _RT_DOT11D_INFO { u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; enum dot11d_state State; -} RT_DOT11D_INFO, *PRT_DOT11D_INFO; -#define eqMacAddr(a, b) (((a)[0] == (b)[0] && \ +}; + +#define eqMacAddr(a, b) (((a)[0] == (b)[0] && \ (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && \ (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0) #define cpMacAddr(des, src) ((des)[0] = (src)[0], \ (des)[1] = (src)[1], (des)[2] = (src)[2], \ (des)[3] = (src)[3], (des)[4] = (src)[4], \ (des)[5] = (src)[5]) -#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo)) +#define GET_DOT11D_INFO(__pIeeeDev) ((struct rt_dot11d_info *)((__pIeeeDev)->pDot11dInfo)) #define IS_DOT11D_ENABLE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->bEnabled) #define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index fe61451f6c14..ca3a35b8ac07 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2542,7 +2542,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) for (i = 0; i < 5; i++) ieee->seq_ctrl[i] = 0; - ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_KERNEL); + ieee->pDot11dInfo = kzalloc(sizeof(struct rt_dot11d_info), GFP_KERNEL); if (!ieee->pDot11dInfo) IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n"); //added for AP roaming From b34db7f48ab6bd7308112da330c49ef06b56c164 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:46 +0100 Subject: [PATCH 537/903] staging:rtl8192u: Rename bEnabled > enabled - Style Rename the member variable bEnabled to enabled. This change clears the checkpatch issue with CamelCase. Purely a coding style change which should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 2 +- drivers/staging/rtl8192u/ieee80211/dot11d.h | 4 ++-- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index cd63e158c7c8..3d2eb19a7f48 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -7,7 +7,7 @@ void Dot11d_Init(struct ieee80211_device *ieee) { struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee); - pDot11dInfo->bEnabled = false; + pDot11dInfo->enabled = false; pDot11dInfo->State = DOT11D_STATE_NONE; pDot11dInfo->CountryIeLen = 0; diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 8f7426333da5..cfe342d0b4bb 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -19,7 +19,7 @@ enum dot11d_state { struct rt_dot11d_info { /* DECLARE_RT_OBJECT(rt_dot11d_info); */ - bool bEnabled; /* dot11MultiDomainCapabilityEnabled */ + bool enabled; /* dot11MultiDomainCapabilityEnabled */ u16 CountryIeLen; /* > 0 if CountryIeBuf[] contains valid country information element. */ u8 CountryIeBuf[MAX_IE_LEN]; @@ -41,7 +41,7 @@ struct rt_dot11d_info { (des)[5] = (src)[5]) #define GET_DOT11D_INFO(__pIeeeDev) ((struct rt_dot11d_info *)((__pIeeeDev)->pDot11dInfo)) -#define IS_DOT11D_ENABLE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->bEnabled) +#define IS_DOT11D_ENABLE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->enabled) #define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index cf39c0bc2a26..c99923d467a7 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -211,7 +211,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv) /* this flag enabled to follow 11d country IE setting, * otherwise, it shall follow global domain settings. */ - GET_DOT11D_INFO(ieee)->bEnabled = 0; + GET_DOT11D_INFO(ieee)->enabled = 0; Dot11d_Reset(ieee); ieee->bGlobalDomain = true; break; From 9e1c8eb6ed602fdc0359454849910d1c799dbf16 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:47 +0100 Subject: [PATCH 538/903] staging:rtl8192u: Rename CountryIeLen > country_ie_len - Style Rename CountryIeLen to country_ie_len, coding style change to clear checkpatch issue with CamelCase naming. The change should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/dot11d.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index 3d2eb19a7f48..87af2ddae349 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -10,7 +10,7 @@ void Dot11d_Init(struct ieee80211_device *ieee) pDot11dInfo->enabled = false; pDot11dInfo->State = DOT11D_STATE_NONE; - pDot11dInfo->CountryIeLen = 0; + pDot11dInfo->country_ie_len = 0; memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1); memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); RESET_CIE_WATCHDOG(ieee); @@ -35,7 +35,7 @@ void Dot11d_Reset(struct ieee80211_device *ieee) (pDot11dInfo->channel_map)[i] = 2; pDot11dInfo->State = DOT11D_STATE_NONE; - pDot11dInfo->CountryIeLen = 0; + pDot11dInfo->country_ie_len = 0; RESET_CIE_WATCHDOG(ieee); } EXPORT_SYMBOL(Dot11d_Reset); @@ -93,7 +93,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, UPDATE_CIE_SRC(dev, pTaddr); - pDot11dInfo->CountryIeLen = CoutryIeLen; + pDot11dInfo->country_ie_len = CoutryIeLen; memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen); pDot11dInfo->State = DOT11D_STATE_LEARNED; } diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index cfe342d0b4bb..a15b21456101 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -21,7 +21,7 @@ struct rt_dot11d_info { bool enabled; /* dot11MultiDomainCapabilityEnabled */ - u16 CountryIeLen; /* > 0 if CountryIeBuf[] contains valid country information element. */ + u16 country_ie_len; /* > 0 if CountryIeBuf[] contains valid country information element. */ u8 CountryIeBuf[MAX_IE_LEN]; u8 CountryIeSrcAddr[6]; /* Source AP of the country IE. */ u8 CountryIeWatchdog; @@ -42,13 +42,13 @@ struct rt_dot11d_info { #define GET_DOT11D_INFO(__pIeeeDev) ((struct rt_dot11d_info *)((__pIeeeDev)->pDot11dInfo)) #define IS_DOT11D_ENABLE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->enabled) -#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) +#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->country_ie_len > 0) #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) #define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) #define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \ - (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \ + (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->country_ie_len) ? \ FALSE : \ (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length))) From 18ee7be97e1895a0b52843bd5bb733c2383af465 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:48 +0100 Subject: [PATCH 539/903] staging:rtl8192u: Rename CountryIeBuf to country_ie_buf - Style Rename the member variable CountryIeBuf to country_ie_buf. This change clears the checkpatch issue with CamelCase. The change is purely coding style and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 2 +- drivers/staging/rtl8192u/ieee80211/dot11d.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index 87af2ddae349..b1205345a7e0 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -94,7 +94,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, UPDATE_CIE_SRC(dev, pTaddr); pDot11dInfo->country_ie_len = CoutryIeLen; - memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen); + memcpy(pDot11dInfo->country_ie_buf, pCoutryIe, CoutryIeLen); pDot11dInfo->State = DOT11D_STATE_LEARNED; } EXPORT_SYMBOL(Dot11d_UpdateCountryIe); diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index a15b21456101..109b82e69b5e 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -21,8 +21,8 @@ struct rt_dot11d_info { bool enabled; /* dot11MultiDomainCapabilityEnabled */ - u16 country_ie_len; /* > 0 if CountryIeBuf[] contains valid country information element. */ - u8 CountryIeBuf[MAX_IE_LEN]; + u16 country_ie_len; /* > 0 if country_ie_buf[] contains valid country information element. */ + u8 country_ie_buf[MAX_IE_LEN]; u8 CountryIeSrcAddr[6]; /* Source AP of the country IE. */ u8 CountryIeWatchdog; @@ -50,7 +50,7 @@ struct rt_dot11d_info { #define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \ (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->country_ie_len) ? \ FALSE : \ - (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length))) + (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->country_ie_buf, (__Ie).Octet, (__Ie).Length))) #define CIE_WATCHDOG_TH 1 #define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog) From 4655d4f041d1a251cccf6465b2753c1b928d326b Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:49 +0100 Subject: [PATCH 540/903] staging:rtl8192u: Rename variable CountryIeSrcAddr - Style Rename the member variable CountryIeSrcAddr to country_ie_src_addr, this clears the checkpatch issue with CamelCase naming. The change is purely a coding style change and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 109b82e69b5e..e5087291d64a 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -23,7 +23,7 @@ struct rt_dot11d_info { u16 country_ie_len; /* > 0 if country_ie_buf[] contains valid country information element. */ u8 country_ie_buf[MAX_IE_LEN]; - u8 CountryIeSrcAddr[6]; /* Source AP of the country IE. */ + u8 country_ie_src_addr[6]; /* Source AP of the country IE. */ u8 CountryIeWatchdog; u8 channel_map[MAX_CHANNEL_NUMBER+1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ @@ -44,8 +44,8 @@ struct rt_dot11d_info { #define IS_DOT11D_ENABLE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->enabled) #define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->country_ie_len > 0) -#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) -#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) +#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->country_ie_src_addr, __pTa) +#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->country_ie_src_addr, __pTa) #define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \ (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->country_ie_len) ? \ From 6963fe9935ef01e70b24b2bfc02689b3cb04eedd Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:50 +0100 Subject: [PATCH 541/903] staging:rtl8192u: Rename CountryIeWatchdog > country_ie_watchdog - Style Rename the member variable CountryIeWatchdog to country_ie_watchdog, this change clears the checkpatch issue with CamelCase naming of variables. The change is a simple coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index e5087291d64a..a7fa1a7f01bd 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -24,7 +24,7 @@ struct rt_dot11d_info { u16 country_ie_len; /* > 0 if country_ie_buf[] contains valid country information element. */ u8 country_ie_buf[MAX_IE_LEN]; u8 country_ie_src_addr[6]; /* Source AP of the country IE. */ - u8 CountryIeWatchdog; + u8 country_ie_watchdog; u8 channel_map[MAX_CHANNEL_NUMBER+1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; @@ -53,7 +53,7 @@ struct rt_dot11d_info { (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->country_ie_buf, (__Ie).Octet, (__Ie).Length))) #define CIE_WATCHDOG_TH 1 -#define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog) +#define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->country_ie_watchdog) #define RESET_CIE_WATCHDOG(__pIeeeDev) (GET_CIE_WATCHDOG(__pIeeeDev) = 0) #define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev)) From 6da23bfd735cfff039aa3083706596c1f4d6670e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:51 +0100 Subject: [PATCH 542/903] staging:rtl8192u: Rename MaxTxPwrDbmList > max_tx_pwr_dbm_list - Style Rename the member variable MaxTxPwrDbmList to max_tx_pwr_dbm_list. This change clears the checkpatch issue with CamelCase naming. The change is a simple coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index b1205345a7e0..21912b2d728d 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -12,7 +12,7 @@ void Dot11d_Init(struct ieee80211_device *ieee) pDot11dInfo->State = DOT11D_STATE_NONE; pDot11dInfo->country_ie_len = 0; memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1); - memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); + memset(pDot11dInfo->max_tx_pwr_dbm_list, 0xFF, MAX_CHANNEL_NUMBER+1); RESET_CIE_WATCHDOG(ieee); netdev_info(ieee->dev, "Dot11d_Init()\n"); @@ -26,7 +26,7 @@ void Dot11d_Reset(struct ieee80211_device *ieee) struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee); /* Clear old channel map */ memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); - memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); + memset(pDot11dInfo->max_tx_pwr_dbm_list, 0xFF, MAX_CHANNEL_NUMBER+1); /* Set new channel map */ for (i = 1; i <= 11; i++) (pDot11dInfo->channel_map)[i] = 1; @@ -57,7 +57,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, struct chnl_txpower_triple *pTriple; memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); - memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); + memset(pDot11dInfo->max_tx_pwr_dbm_list, 0xFF, MAX_CHANNEL_NUMBER+1); MaxChnlNum = 0; NumTriples = (CoutryIeLen - 3) / 3; /* skip 3-byte country string. */ pTriple = (struct chnl_txpower_triple *)(pCoutryIe + 3); @@ -79,7 +79,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, for (j = 0; j < pTriple->num_channels; j++) { pDot11dInfo->channel_map[pTriple->first_channel + j] = 1; - pDot11dInfo->MaxTxPwrDbmList[pTriple->first_channel + j] = pTriple->max_tx_pwr_dbm; + pDot11dInfo->max_tx_pwr_dbm_list[pTriple->first_channel + j] = pTriple->max_tx_pwr_dbm; MaxChnlNum = pTriple->first_channel + j; } @@ -109,7 +109,7 @@ u8 DOT11D_GetMaxTxPwrInDbm(struct ieee80211_device *dev, u8 Channel) return MaxTxPwrInDbm; } if (pDot11dInfo->channel_map[Channel]) - MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel]; + MaxTxPwrInDbm = pDot11dInfo->max_tx_pwr_dbm_list[Channel]; return MaxTxPwrInDbm; } diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index a7fa1a7f01bd..0c7652a2ebb3 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -27,7 +27,7 @@ struct rt_dot11d_info { u8 country_ie_watchdog; u8 channel_map[MAX_CHANNEL_NUMBER+1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ - u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; + u8 max_tx_pwr_dbm_list[MAX_CHANNEL_NUMBER+1]; enum dot11d_state State; }; From 2aa608bc48bcff19a42f652fcbd5917d69a009ee Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 21 Jul 2018 20:25:52 +0100 Subject: [PATCH 543/903] staging:rtl8192u: Rename variable State > state - Style Rename the variable State to state, this clears the checkpatch issue with CamelCase naming. The change is purely coding style and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index 21912b2d728d..2fb575a2b6ab 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -9,7 +9,7 @@ void Dot11d_Init(struct ieee80211_device *ieee) pDot11dInfo->enabled = false; - pDot11dInfo->State = DOT11D_STATE_NONE; + pDot11dInfo->state = DOT11D_STATE_NONE; pDot11dInfo->country_ie_len = 0; memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1); memset(pDot11dInfo->max_tx_pwr_dbm_list, 0xFF, MAX_CHANNEL_NUMBER+1); @@ -34,7 +34,7 @@ void Dot11d_Reset(struct ieee80211_device *ieee) for (i = 12; i <= 14; i++) (pDot11dInfo->channel_map)[i] = 2; - pDot11dInfo->State = DOT11D_STATE_NONE; + pDot11dInfo->state = DOT11D_STATE_NONE; pDot11dInfo->country_ie_len = 0; RESET_CIE_WATCHDOG(ieee); } @@ -95,7 +95,7 @@ void Dot11d_UpdateCountryIe(struct ieee80211_device *dev, u8 *pTaddr, pDot11dInfo->country_ie_len = CoutryIeLen; memcpy(pDot11dInfo->country_ie_buf, pCoutryIe, CoutryIeLen); - pDot11dInfo->State = DOT11D_STATE_LEARNED; + pDot11dInfo->state = DOT11D_STATE_LEARNED; } EXPORT_SYMBOL(Dot11d_UpdateCountryIe); @@ -119,9 +119,9 @@ void DOT11D_ScanComplete(struct ieee80211_device *dev) { struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev); - switch (pDot11dInfo->State) { + switch (pDot11dInfo->state) { case DOT11D_STATE_LEARNED: - pDot11dInfo->State = DOT11D_STATE_DONE; + pDot11dInfo->state = DOT11D_STATE_DONE; break; case DOT11D_STATE_DONE: diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 0c7652a2ebb3..5639bb498865 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -29,7 +29,7 @@ struct rt_dot11d_info { u8 channel_map[MAX_CHANNEL_NUMBER+1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ u8 max_tx_pwr_dbm_list[MAX_CHANNEL_NUMBER+1]; - enum dot11d_state State; + enum dot11d_state state; }; #define eqMacAddr(a, b) (((a)[0] == (b)[0] && \ From 6464a50993a4ba922a6f350050d1923a4267233b Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:16 +0100 Subject: [PATCH 544/903] staging:rtl8192u: Remove unused page 1 definitions - Style Remove all the "page 1" definitions as they are not used in code. A lot of these definitions, if not all, fail checkpatch because of CamelCase issues. Rather then change the names of unused constants simply remove. This is a coding style change which should have no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 31 ------------------------ 1 file changed, 31 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index c058a9537526..437f3bfcc399 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -5,37 +5,6 @@ #define RF_DATA 0x1d4 /* FW will write RF data in the register.*/ -/* Register duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF - * page 1 - */ -#define rPMAC_Reset 0x100 -#define rPMAC_TxStart 0x104 -#define rPMAC_TxLegacySIG 0x108 -#define rPMAC_TxHTSIG1 0x10c -#define rPMAC_TxHTSIG2 0x110 -#define rPMAC_PHYDebug 0x114 -#define rPMAC_TxPacketNum 0x118 -#define rPMAC_TxIdle 0x11c -#define rPMAC_TxMACHeader0 0x120 -#define rPMAC_TxMACHeader1 0x124 -#define rPMAC_TxMACHeader2 0x128 -#define rPMAC_TxMACHeader3 0x12c -#define rPMAC_TxMACHeader4 0x130 -#define rPMAC_TxMACHeader5 0x134 -#define rPMAC_TxDataType 0x138 -#define rPMAC_TxRandomSeed 0x13c -#define rPMAC_CCKPLCPPreamble 0x140 -#define rPMAC_CCKPLCPHeader 0x144 -#define rPMAC_CCKCRC16 0x148 -#define rPMAC_OFDMRxCRC32OK 0x170 -#define rPMAC_OFDMRxCRC32Er 0x174 -#define rPMAC_OFDMRxParityEr 0x178 -#define rPMAC_OFDMRxCRC8Er 0x17c -#define rPMAC_CCKCRxRC16Er 0x180 -#define rPMAC_CCKCRxRC32Er 0x184 -#define rPMAC_CCKCRxRC32OK 0x188 -#define rPMAC_TxStatus 0x18c - /* page8 */ #define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC */ #define rFPGA0_TxInfo 0x804 From 590bb44e864d228de18d8587515f1867b6a45f0a Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:17 +0100 Subject: [PATCH 545/903] staging:rtl8192u: Remove unused page 8 definitions - Style Remove page 8 definitions which are never used in code. Many of these definitions, if not all, fail the checkpatch CamelCase checks. To avoid the effort of renaming unused definitions they have been removed. This is a style change which should have no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 437f3bfcc399..b8e5fc003a5a 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -7,14 +7,7 @@ /* page8 */ #define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC */ -#define rFPGA0_TxInfo 0x804 -#define rFPGA0_PSDFunction 0x808 #define rFPGA0_TxGainStage 0x80c -#define rFPGA0_RFTiming1 0x810 -#define rFPGA0_RFTiming2 0x814 -/* #define rFPGA0_XC_RFTiming 0x818 - * #define rFPGA0_XD_RFTiming 0x81c - */ #define rFPGA0_XA_HSSIParameter1 0x820 #define rFPGA0_XA_HSSIParameter2 0x824 #define rFPGA0_XB_HSSIParameter1 0x828 @@ -27,8 +20,6 @@ #define rFPGA0_XB_LSSIParameter 0x844 #define rFPGA0_XC_LSSIParameter 0x848 #define rFPGA0_XD_LSSIParameter 0x84c -#define rFPGA0_RFWakeUpParameter 0x850 -#define rFPGA0_RFSleepUpParameter 0x854 #define rFPGA0_XAB_SwitchControl 0x858 #define rFPGA0_XCD_SwitchControl 0x85c #define rFPGA0_XA_RFInterfaceOE 0x860 @@ -40,14 +31,11 @@ #define rFPGA0_XAB_RFParameter 0x878 #define rFPGA0_XCD_RFParameter 0x87c #define rFPGA0_AnalogParameter1 0x880 -#define rFPGA0_AnalogParameter2 0x884 -#define rFPGA0_AnalogParameter3 0x888 #define rFPGA0_AnalogParameter4 0x88c #define rFPGA0_XA_LSSIReadBack 0x8a0 #define rFPGA0_XB_LSSIReadBack 0x8a4 #define rFPGA0_XC_LSSIReadBack 0x8a8 #define rFPGA0_XD_LSSIReadBack 0x8ac -#define rFPGA0_PSDReport 0x8b4 #define rFPGA0_XAB_RFInterfaceRB 0x8e0 #define rFPGA0_XCD_RFInterfaceRB 0x8e4 From bf94a343846faf71c1c5f30cf1a0ed7087668203 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:18 +0100 Subject: [PATCH 546/903] staging:rtl8192u: Remove unused page 9 definitions - Style Remove the unused definitions from page 9 section. These definitions will fail the checkpatch CamelCase test, to save renaming these unused definitions they have simply been removed. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index b8e5fc003a5a..e0c99a953afd 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -41,9 +41,6 @@ /* page 9 */ #define rFPGA1_RFMOD 0x900 /* RF mode & OFDM TxSC */ -#define rFPGA1_TxBlock 0x904 -#define rFPGA1_DebugSelect 0x908 -#define rFPGA1_TxInfo 0x90c /* page a */ #define rCCK0_System 0xa00 From 3527392f5aca429841e9d8389b197f1b066baff5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:19 +0100 Subject: [PATCH 547/903] staging:rtl8192u: Remove unused page a definitions - Style Remove unused 'page a' definitions. These definitions fail the checkpatch CamelCase naming test, rather then renaming these unused definitions they have simply been removed. This is a coding style change only, and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index e0c99a953afd..6be63aef33f7 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -46,19 +46,9 @@ #define rCCK0_System 0xa00 #define rCCK0_AFESetting 0xa04 #define rCCK0_CCA 0xa08 -#define rCCK0_RxAGC1 0xa0c /* AGC default value, saturation level */ -#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ -#define rCCK0_RxHP 0xa14 -#define rCCK0_DSPParameter1 0xa18 /* Timing recovery & Channel estimation threshold */ -#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */ #define rCCK0_TxFilter1 0xa20 #define rCCK0_TxFilter2 0xa24 #define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */ -#define rCCK0_FalseAlarmReport 0xa2c /* 0xa2d */ -#define rCCK0_TRSSIReport 0xa50 -#define rCCK0_RxReport 0xa54 /* 0xa57 */ -#define rCCK0_FACounterLower 0xa5c /* 0xa5b */ -#define rCCK0_FACounterUpper 0xa58 /* 0xa5c */ /* page c */ #define rOFDM0_LSTF 0xc00 From 5c9b63a4aeb87ae9b27fae7ee51eeaaba88fb06c Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:20 +0100 Subject: [PATCH 548/903] staging:rtl8192u: Remove unused page c definitions - Style Remove unused 'page c' definitions. These definitions fail the checkpatch CamelCase test, to save renaming, these unused definitions have simply been removed. This is a coding style change which should not have an impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 6be63aef33f7..26d18a494fb4 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -51,10 +51,7 @@ #define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */ /* page c */ -#define rOFDM0_LSTF 0xc00 #define rOFDM0_TRxPathEnable 0xc04 -#define rOFDM0_TRMuxPar 0xc08 -#define rOFDM0_TRSWIsolation 0xc0c #define rOFDM0_XARxAFE 0xc10 /* RxIQ DC offset, Rx digital filter, DC notch filter */ #define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */ #define rOFDM0_XBRxAFE 0xc18 @@ -66,10 +63,6 @@ #define rOFDM0_RxDetector1 0xc30 /* PD,BW & SBD */ #define rOFDM0_RxDetector2 0xc34 /* SBD & Fame Sync.*/ #define rOFDM0_RxDetector3 0xc38 /* Frame Sync.*/ -#define rOFDM0_RxDetector4 0xc3c /* PD, SBD, Frame Sync & Short-GI */ -#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ -#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */ -#define rOFDM0_CCADropThreshold 0xc48 /* CCA Drop threshold */ #define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */ #define rOFDM0_XAAGCCore1 0xc50 #define rOFDM0_XAAGCCore2 0xc54 @@ -79,10 +72,6 @@ #define rOFDM0_XCAGCCore2 0xc64 #define rOFDM0_XDAGCCore1 0xc68 #define rOFDM0_XDAGCCore2 0xc6c -#define rOFDM0_AGCParameter1 0xc70 -#define rOFDM0_AGCParameter2 0xc74 -#define rOFDM0_AGCRSSITable 0xc78 -#define rOFDM0_HTSTFAGC 0xc7c #define rOFDM0_XATxIQImbalance 0xc80 #define rOFDM0_XATxAFE 0xc84 #define rOFDM0_XBTxIQImbalance 0xc88 @@ -91,16 +80,6 @@ #define rOFDM0_XCTxAFE 0xc94 #define rOFDM0_XDTxIQImbalance 0xc98 #define rOFDM0_XDTxAFE 0xc9c -#define rOFDM0_RxHPParameter 0xce0 -#define rOFDM0_TxPseudoNoiseWgt 0xce4 -#define rOFDM0_FrameSync 0xcf0 -#define rOFDM0_DFSReport 0xcf4 -#define rOFDM0_TxCoeff1 0xca4 -#define rOFDM0_TxCoeff2 0xca8 -#define rOFDM0_TxCoeff3 0xcac -#define rOFDM0_TxCoeff4 0xcb0 -#define rOFDM0_TxCoeff5 0xcb4 -#define rOFDM0_TxCoeff6 0xcb8 /* page d */ From 7225444a94f5a314e0f9405defec9aa001a49cc0 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:21 +0100 Subject: [PATCH 549/903] staging:rtl8192u: Remove unused page d definitions - Style Remove the unused 'page d' definitions. These definitions fail the checkpatch CamelCase naming test. Rather then renaming unused definitions they have simply been removed. This change is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 27 ------------------------ 1 file changed, 27 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 26d18a494fb4..661df18867dd 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -85,33 +85,6 @@ /* page d */ #define rOFDM1_LSTF 0xd00 #define rOFDM1_TRxPathEnable 0xd04 -#define rOFDM1_CFO 0xd08 -#define rOFDM1_CSI1 0xd10 -#define rOFDM1_SBD 0xd14 -#define rOFDM1_CSI2 0xd18 -#define rOFDM1_CFOTracking 0xd2c -#define rOFDM1_TRxMesaure1 0xd34 -#define rOFDM1_IntfDet 0xd3c -#define rOFDM1_PseudoNoiseStateAB 0xd50 -#define rOFDM1_PseudoNoiseStateCD 0xd54 -#define rOFDM1_RxPseudoNoiseWgt 0xd58 -#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */ -#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */ - -#define rOFDM_PHYCounter3 0xda8 /* MCS not support */ -#define rOFDM_ShortCFOAB 0xdac -#define rOFDM_ShortCFOCD 0xdb0 -#define rOFDM_LongCFOAB 0xdb4 -#define rOFDM_LongCFOCD 0xdb8 -#define rOFDM_TailCFOAB 0xdbc -#define rOFDM_TailCFOCD 0xdc0 -#define rOFDM_PWMeasure1 0xdc4 -#define rOFDM_PWMeasure2 0xdc8 -#define rOFDM_BWReport 0xdcc -#define rOFDM_AGCReport 0xdd0 -#define rOFDM_RxSNR 0xdd4 -#define rOFDM_RxEVMCSI 0xdd8 -#define rOFDM_SIGReport 0xddc /* page e */ #define rTxAGC_Rate18_06 0xe00 From 18eacf127ddb01662fdef1c10b864ea11f46294e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:22 +0100 Subject: [PATCH 550/903] staging:rtl8192u: Remove unused Zebra1 definitions - Style Remove unused 'Zebra1' definitions. These definitions fail the checkpatch CamelCase test, rather then rename, these unused definitions have simply been removed. This is a coding style change which should have not impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 661df18867dd..73944a9f9622 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -99,16 +99,7 @@ /* RF * Zebra1 */ -#define rZebra1_HSSIEnable 0x0 -#define rZebra1_TRxEnable1 0x1 -#define rZebra1_TRxEnable2 0x2 -#define rZebra1_AGC 0x4 -#define rZebra1_ChargePump 0x5 #define rZebra1_Channel 0x7 -#define rZebra1_TxGain 0x8 -#define rZebra1_TxLPF 0x9 -#define rZebra1_RxLPF 0xb -#define rZebra1_RxHPFCorner 0xc /* Zebra4 */ #define rGlobalCtrl 0 From 6820978513fed595e5ab9b643ade7c45950de62d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:23 +0100 Subject: [PATCH 551/903] staging:rtl8192u: Remove unused Zebra4 definitions - Style Remove the unused 'Zebra4' definitions. These definitions fail the checkpatch CamelCase naming test, rather then rename as they are unused definitions they have simply been removed. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 73944a9f9622..ea0c3bdc2a77 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -103,8 +103,6 @@ /* Zebra4 */ #define rGlobalCtrl 0 -#define rRTL8256_TxLPF 19 -#define rRTL8256_RxLPF 11 /* RTL8258 */ #define rRTL8258_TxLPF 0x11 From 93860840b67c77a2f6a59e0bbb9710d4d00e4bf1 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:24 +0100 Subject: [PATCH 552/903] staging:rtl8192u: Remove unused RTL8258 definitions - Style Remove the unused RTL8258 definitions. These definitions fail the checkpatch CamelCase naming test, rather then renaming, as the definitions are unused they have simply been removed. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index ea0c3bdc2a77..5352ae64ab97 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -104,11 +104,6 @@ /* Zebra4 */ #define rGlobalCtrl 0 -/* RTL8258 */ -#define rRTL8258_TxLPF 0x11 -#define rRTL8258_RxLPF 0x13 -#define rRTL8258_RSSILPF 0xa - /* Bit Mask * page-1 */ From 531db6558984f9147aeb286de1dd22117063f2bd Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:25 +0100 Subject: [PATCH 553/903] staging:rtl8192u: Remove unused page-1 Bit Masks - Style Remove the unused 'page-1' Bit Masks. These definitions fail the checkpatch CamelCase naming test. To avoid renaming the definitions have simply been removed. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 48 +----------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 5352ae64ab97..fb0b388f6759 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -105,54 +105,8 @@ #define rGlobalCtrl 0 /* Bit Mask - * page-1 + * page-8 */ -#define bBBResetB 0x100 -#define bGlobalResetB 0x200 -#define bOFDMTxStart 0x4 -#define bCCKTxStart 0x8 -#define bCRC32Debug 0x100 -#define bPMACLoopback 0x10 -#define bTxLSIG 0xffffff -#define bOFDMTxRate 0xf -#define bOFDMTxReserved 0x10 -#define bOFDMTxLength 0x1ffe0 -#define bOFDMTxParity 0x20000 -#define bTxHTSIG1 0xffffff -#define bTxHTMCSRate 0x7f -#define bTxHTBW 0x80 -#define bTxHTLength 0xffff00 -#define bTxHTSIG2 0xffffff -#define bTxHTSmoothing 0x1 -#define bTxHTSounding 0x2 -#define bTxHTReserved 0x4 -#define bTxHTAggreation 0x8 -#define bTxHTSTBC 0x30 -#define bTxHTAdvanceCoding 0x40 -#define bTxHTShortGI 0x80 -#define bTxHTNumberHT_LTF 0x300 -#define bTxHTCRC8 0x3fc00 -#define bCounterReset 0x10000 -#define bNumOfOFDMTx 0xffff -#define bNumOfCCKTx 0xffff0000 -#define bTxIdleInterval 0xffff -#define bOFDMService 0xffff0000 -#define bTxMACHeader 0xffffffff -#define bTxDataInit 0xff -#define bTxHTMode 0x100 -#define bTxDataType 0x30000 -#define bTxRandomSeed 0xffffffff -#define bCCKTxPreamble 0x1 -#define bCCKTxSFD 0xffff0000 -#define bCCKTxSIG 0xff -#define bCCKTxService 0xff00 -#define bCCKLengthExt 0x8000 -#define bCCKTxLength 0xffff0000 -#define bCCKTxCRC16 0xffff -#define bCCKTxStatus 0x1 -#define bOFDMTxStatus 0x2 - -/* page-8 */ #define bRFMOD 0x1 #define bJapanMode 0x2 #define bCCKTxSC 0x30 From bd632154fa068d1183df1f684dfe65e01920ab93 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:26 +0100 Subject: [PATCH 554/903] staging:rtl8192u: Remove unused page-8 Bit Mask definitions - Style Remove unused 'page-8' Bit Mask definitions. These definitions fail the checkpatch CamelCase naming test, since they are unused in code they have simply been removed from code, rather then renamed. This is a coding style change which should not impact runtime code execution. * page-8 */ Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 114 ----------------------- 1 file changed, 114 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index fb0b388f6759..211f34359e43 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -108,131 +108,17 @@ * page-8 */ #define bRFMOD 0x1 -#define bJapanMode 0x2 -#define bCCKTxSC 0x30 #define bCCKEn 0x1000000 #define bOFDMEn 0x2000000 -#define bOFDMRxADCPhase 0x10000 -#define bOFDMTxDACPhase 0x40000 -#define bXATxAGC 0x3f #define bXBTxAGC 0xf00 #define bXCTxAGC 0xf000 -#define bXDTxAGC 0xf0000 -#define bPAStart 0xf0000000 -#define bTRStart 0x00f00000 -#define bRFStart 0x0000f000 -#define bBBStart 0x000000f0 -#define bBBCCKStart 0x0000000f -#define bPAEnd 0xf /* Reg0x814 */ -#define bTREnd 0x0f000000 -#define bRFEnd 0x000f0000 -#define bCCAMask 0x000000f0 /* T2R */ -#define bR2RCCAMask 0x00000f00 -#define bHSSI_R2TDelay 0xf8000000 -#define bHSSI_T2RDelay 0xf80000 -#define bContTxHSSI 0x400 /* chane gain at continue Tx */ -#define bIGFromCCK 0x200 -#define bAGCAddress 0x3f -#define bRxHPTx 0x7000 -#define bRxHPT2R 0x38000 -#define bRxHPCCKIni 0xc0000 -#define bAGCTxCode 0xc00000 -#define bAGCRxCode 0x300000 #define b3WireDataLength 0x800 #define b3WireAddressLength 0x400 -#define b3WireRFPowerDown 0x1 -/* #define bHWSISelect 0x8 */ -#define b5GPAPEPolarity 0x40000000 -#define b2GPAPEPolarity 0x80000000 -#define bRFSW_TxDefaultAnt 0x3 -#define bRFSW_TxOptionAnt 0x30 -#define bRFSW_RxDefaultAnt 0x300 -#define bRFSW_RxOptionAnt 0x3000 -#define bRFSI_3WireData 0x1 -#define bRFSI_3WireClock 0x2 -#define bRFSI_3WireLoad 0x4 -#define bRFSI_3WireRW 0x8 -#define bRFSI_3Wire 0xf /* 3-wire total control */ #define bRFSI_RFENV 0x10 -#define bRFSI_TRSW 0x20 -#define bRFSI_TRSWB 0x40 -#define bRFSI_ANTSW 0x100 -#define bRFSI_ANTSWB 0x200 -#define bRFSI_PAPE 0x400 -#define bRFSI_PAPE5G 0x800 -#define bBandSelect 0x1 -#define bHTSIG2_GI 0x80 -#define bHTSIG2_Smoothing 0x01 -#define bHTSIG2_Sounding 0x02 -#define bHTSIG2_Aggreaton 0x08 -#define bHTSIG2_STBC 0x30 -#define bHTSIG2_AdvCoding 0x40 -#define bHTSIG2_NumOfHTLTF 0x300 -#define bHTSIG2_CRC8 0x3fc -#define bHTSIG1_MCS 0x7f -#define bHTSIG1_BandWidth 0x80 -#define bHTSIG1_HTLength 0xffff -#define bLSIG_Rate 0xf -#define bLSIG_Reserved 0x10 -#define bLSIG_Length 0x1fffe -#define bLSIG_Parity 0x20 -#define bCCKRxPhase 0x4 #define bLSSIReadAddress 0x3f000000 /* LSSI "Read" Address */ #define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ #define bLSSIReadBackData 0xfff -#define bLSSIReadOKFlag 0x1000 -#define bCCKSampleRate 0x8 /* 0: 44MHz, 1:88MHz */ -#define bRegulator0Standby 0x1 -#define bRegulatorPLLStandby 0x2 -#define bRegulator1Standby 0x4 -#define bPLLPowerUp 0x8 -#define bDPLLPowerUp 0x10 -#define bDA10PowerUp 0x20 -#define bAD7PowerUp 0x200 -#define bDA6PowerUp 0x2000 -#define bXtalPowerUp 0x4000 -#define b40MDClkPowerUP 0x8000 -#define bDA6DebugMode 0x20000 -#define bDA6Swing 0x380000 -#define bADClkPhase 0x4000000 -#define b80MClkDelay 0x18000000 -#define bAFEWatchDogEnable 0x20000000 #define bXtalCap 0x0f000000 -#define bIntDifClkEnable 0x400 -#define bExtSigClkEnable 0x800 -#define bBandgapMbiasPowerUp 0x10000 -#define bAD11SHGain 0xc0000 -#define bAD11InputRange 0x700000 -#define bAD11OPCurrent 0x3800000 -#define bIPathLoopback 0x4000000 -#define bQPathLoopback 0x8000000 -#define bAFELoopback 0x10000000 -#define bDA10Swing 0x7e0 -#define bDA10Reverse 0x800 -#define bDAClkSource 0x1000 -#define bAD7InputRange 0x6000 -#define bAD7Gain 0x38000 -#define bAD7OutputCMMode 0x40000 -#define bAD7InputCMMode 0x380000 -#define bAD7Current 0xc00000 -#define bRegulatorAdjust 0x7000000 -#define bAD11PowerUpAtTx 0x1 -#define bDA10PSAtTx 0x10 -#define bAD11PowerUpAtRx 0x100 -#define bDA10PSAtRx 0x1000 - -#define bCCKRxAGCFormat 0x200 - -#define bPSDFFTSamplepPoint 0xc000 -#define bPSDAverageNum 0x3000 -#define bIQPathControl 0xc00 -#define bPSDFreq 0x3ff -#define bPSDAntennaPath 0x30 -#define bPSDIQSwitch 0x40 -#define bPSDRxTrigger 0x400000 -#define bPSDTxTrigger 0x80000000 -#define bPSDSineToneScale 0x7f000000 -#define bPSDReport 0xffff /* page-9 */ #define bOFDMTxSC 0x30000000 From 5a894c757f44fa0a96927f20c68a5ed495ade0b8 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:27 +0100 Subject: [PATCH 555/903] staging:rtl8192u: Remove unused page-9 Bit Mask definitions - Style Remove the unused page-9 Bit Mask definitions. These definitions fail the checkpatch CamelCase naming tests. Since the definitions are unused in code they have simply been removed, rather then renaming. The change is purely a coding style change and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 211f34359e43..53beef72ceda 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -120,19 +120,6 @@ #define bLSSIReadBackData 0xfff #define bXtalCap 0x0f000000 -/* page-9 */ -#define bOFDMTxSC 0x30000000 -#define bCCKTxOn 0x1 -#define bOFDMTxOn 0x2 -#define bDebugPage 0xfff /* reset debug page and also HWord, LWord */ -#define bDebugItem 0xff /* reset debug page and LWord */ -#define bAntL 0x10 -#define bAntNonHT 0x100 -#define bAntHT1 0x1000 -#define bAntHT2 0x10000 -#define bAntHT1S1 0x100000 -#define bAntNonHTS1 0x1000000 - /* page-a */ #define bCCKBBMode 0x3 #define bCCKTxPowerSaving 0x80 From d7486940c76d2a3c908fe6bc03ec8341d8428d03 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:28 +0100 Subject: [PATCH 556/903] staging:rtl8192u: Remove unused page-a Bit Mask definitions - Style Remove the unused 'page-a' Bit Mask definitions. These definitions will fail the checkpatch CamelCase naming tests, rather then renaming, as the definitions are unused, they have simply been removed. This is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 78 ------------------------ 1 file changed, 78 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 53beef72ceda..af98067c0de0 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -121,85 +121,7 @@ #define bXtalCap 0x0f000000 /* page-a */ -#define bCCKBBMode 0x3 -#define bCCKTxPowerSaving 0x80 -#define bCCKRxPowerSaving 0x40 #define bCCKSideBand 0x10 -#define bCCKScramble 0x8 -#define bCCKAntDiversity 0x8000 -#define bCCKCarrierRecovery 0x4000 -#define bCCKTxRate 0x3000 -#define bCCKDCCancel 0x0800 -#define bCCKISICancel 0x0400 -#define bCCKMatchFilter 0x0200 -#define bCCKEqualizer 0x0100 -#define bCCKPreambleDetect 0x800000 -#define bCCKFastFalseCCA 0x400000 -#define bCCKChEstStart 0x300000 -#define bCCKCCACount 0x080000 -#define bCCKcs_lim 0x070000 -#define bCCKBistMode 0x80000000 -#define bCCKCCAMask 0x40000000 -#define bCCKTxDACPhase 0x4 -#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */ -#define bCCKr_cp_mode0 0x0100 -#define bCCKTxDCOffset 0xf0 -#define bCCKRxDCOffset 0xf -#define bCCKCCAMode 0xc000 -#define bCCKFalseCS_lim 0x3f00 -#define bCCKCS_ratio 0xc00000 -#define bCCKCorgBit_sel 0x300000 -#define bCCKPD_lim 0x0f0000 -#define bCCKNewCCA 0x80000000 -#define bCCKRxHPofIG 0x8000 -#define bCCKRxIG 0x7f00 -#define bCCKLNAPolarity 0x800000 -#define bCCKRx1stGain 0x7f0000 -#define bCCKRFExtend 0x20000000 /* CCK Rx initial gain polarity */ -#define bCCKRxAGCSatLevel 0x1f000000 -#define bCCKRxAGCSatCount 0xe0 -#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */ -#define bCCKFixedRxAGC 0x8000 -/* #define bCCKRxAGCFormat 0x4000 */ /* remove to HSSI register 0x824 */ -#define bCCKAntennaPolarity 0x2000 -#define bCCKTxFilterType 0x0c00 -#define bCCKRxAGCReportType 0x0300 -#define bCCKRxDAGCEn 0x80000000 -#define bCCKRxDAGCPeriod 0x20000000 -#define bCCKRxDAGCSatLevel 0x1f000000 -#define bCCKTimingRecovery 0x800000 -#define bCCKTxC0 0x3f0000 -#define bCCKTxC1 0x3f000000 -#define bCCKTxC2 0x3f -#define bCCKTxC3 0x3f00 -#define bCCKTxC4 0x3f0000 -#define bCCKTxC5 0x3f000000 -#define bCCKTxC6 0x3f -#define bCCKTxC7 0x3f00 -#define bCCKDebugPort 0xff0000 -#define bCCKDACDebug 0x0f000000 -#define bCCKFalseAlarmEnable 0x8000 -#define bCCKFalseAlarmRead 0x4000 -#define bCCKTRSSI 0x7f -#define bCCKRxAGCReport 0xfe -#define bCCKRxReport_AntSel 0x80000000 -#define bCCKRxReport_MFOff 0x40000000 -#define bCCKRxRxReport_SQLoss 0x20000000 -#define bCCKRxReport_Pktloss 0x10000000 -#define bCCKRxReport_Lockedbit 0x08000000 -#define bCCKRxReport_RateError 0x04000000 -#define bCCKRxReport_RxRate 0x03000000 -#define bCCKRxFACounterLower 0xff -#define bCCKRxFACounterUpper 0xff000000 -#define bCCKRxHPAGCStart 0xe000 -#define bCCKRxHPAGCFinal 0x1c00 - -#define bCCKRxFalseAlarmEnable 0x8000 -#define bCCKFACounterFreeze 0x4000 - -#define bCCKTxPathSel 0x10000000 -#define bCCKDefaultRxPath 0xc000000 -#define bCCKOptionRxPath 0x3000000 /* page c */ #define bNumOfSTF 0x3 From 3e4361f3e21dd2c5a8b8828a7adef61de7949592 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:29 +0100 Subject: [PATCH 557/903] staging:rtl8192u: Remove unused page c Bit Mask definitions - Style Remove the unused 'page c' Bit Mask definitions. These definitions will fail the checkpatch CamelCase naming test. Rather then renaming, as the definitions are unused in code, they have simply been removed. The change is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 163 ----------------------- 1 file changed, 163 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index af98067c0de0..b0bcef2e73a6 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -123,169 +123,6 @@ /* page-a */ #define bCCKSideBand 0x10 -/* page c */ -#define bNumOfSTF 0x3 -#define bShift_L 0xc0 -#define bGI_TH 0xc -#define bRxPathA 0x1 -#define bRxPathB 0x2 -#define bRxPathC 0x4 -#define bRxPathD 0x8 -#define bTxPathA 0x1 -#define bTxPathB 0x2 -#define bTxPathC 0x4 -#define bTxPathD 0x8 -#define bTRSSIFreq 0x200 -#define bADCBackoff 0x3000 -#define bDFIRBackoff 0xc000 -#define bTRSSILatchPhase 0x10000 -#define bRxIDCOffset 0xff -#define bRxQDCOffset 0xff00 -#define bRxDFIRMode 0x1800000 -#define bRxDCNFType 0xe000000 -#define bRXIQImb_A 0x3ff -#define bRXIQImb_B 0xfc00 -#define bRXIQImb_C 0x3f0000 -#define bRXIQImb_D 0xffc00000 -#define bDC_dc_Notch 0x60000 -#define bRxNBINotch 0x1f000000 -#define bPD_TH 0xf -#define bPD_TH_Opt2 0xc000 -#define bPWED_TH 0x700 -#define bIfMF_Win_L 0x800 -#define bPD_Option 0x1000 -#define bMF_Win_L 0xe000 -#define bBW_Search_L 0x30000 -#define bwin_enh_L 0xc0000 -#define bBW_TH 0x700000 -#define bED_TH2 0x3800000 -#define bBW_option 0x4000000 -#define bRatio_TH 0x18000000 -#define bWindow_L 0xe0000000 -#define bSBD_Option 0x1 -#define bFrame_TH 0x1c -#define bFS_Option 0x60 -#define bDC_Slope_check 0x80 -#define bFGuard_Counter_DC_L 0xe00 -#define bFrame_Weight_Short 0x7000 -#define bSub_Tune 0xe00000 -#define bFrame_DC_Length 0xe000000 -#define bSBD_start_offset 0x30000000 -#define bFrame_TH_2 0x7 -#define bFrame_GI2_TH 0x38 -#define bGI2_Sync_en 0x40 -#define bSarch_Short_Early 0x300 -#define bSarch_Short_Late 0xc00 -#define bSarch_GI2_Late 0x70000 -#define bCFOAntSum 0x1 -#define bCFOAcc 0x2 -#define bCFOStartOffset 0xc -#define bCFOLookBack 0x70 -#define bCFOSumWeight 0x80 -#define bDAGCEnable 0x10000 -#define bTXIQImb_A 0x3ff -#define bTXIQImb_B 0xfc00 -#define bTXIQImb_C 0x3f0000 -#define bTXIQImb_D 0xffc00000 -#define bTxIDCOffset 0xff -#define bTxQDCOffset 0xff00 -#define bTxDFIRMode 0x10000 -#define bTxPesudoNoiseOn 0x4000000 -#define bTxPesudoNoise_A 0xff -#define bTxPesudoNoise_B 0xff00 -#define bTxPesudoNoise_C 0xff0000 -#define bTxPesudoNoise_D 0xff000000 -#define bCCADropOption 0x20000 -#define bCCADropThres 0xfff00000 -#define bEDCCA_H 0xf -#define bEDCCA_L 0xf0 -#define bLambda_ED 0x300 -#define bRxInitialGain 0x7f -#define bRxAntDivEn 0x80 -#define bRxAGCAddressForLNA 0x7f00 -#define bRxHighPowerFlow 0x8000 -#define bRxAGCFreezeThres 0xc0000 -#define bRxFreezeStep_AGC1 0x300000 -#define bRxFreezeStep_AGC2 0xc00000 -#define bRxFreezeStep_AGC3 0x3000000 -#define bRxFreezeStep_AGC0 0xc000000 -#define bRxRssi_Cmp_En 0x10000000 -#define bRxQuickAGCEn 0x20000000 -#define bRxAGCFreezeThresMode 0x40000000 -#define bRxOverFlowCheckType 0x80000000 -#define bRxAGCShift 0x7f -#define bTRSW_Tri_Only 0x80 -#define bPowerThres 0x300 -#define bRxAGCEn 0x1 -#define bRxAGCTogetherEn 0x2 -#define bRxAGCMin 0x4 -#define bRxHP_Ini 0x7 -#define bRxHP_TRLNA 0x70 -#define bRxHP_RSSI 0x700 -#define bRxHP_BBP1 0x7000 -#define bRxHP_BBP2 0x70000 -#define bRxHP_BBP3 0x700000 -#define bRSSI_H 0x7f0000 /* the threshold for high power */ -#define bRSSI_Gen 0x7f000000 /* the threshold for ant diversity */ -#define bRxSettle_TRSW 0x7 -#define bRxSettle_LNA 0x38 -#define bRxSettle_RSSI 0x1c0 -#define bRxSettle_BBP 0xe00 -#define bRxSettle_RxHP 0x7000 -#define bRxSettle_AntSW_RSSI 0x38000 -#define bRxSettle_AntSW 0xc0000 -#define bRxProcessTime_DAGC 0x300000 -#define bRxSettle_HSSI 0x400000 -#define bRxProcessTime_BBPPW 0x800000 -#define bRxAntennaPowerShift 0x3000000 -#define bRSSITableSelect 0xc000000 -#define bRxHP_Final 0x7000000 -#define bRxHTSettle_BBP 0x7 -#define bRxHTSettle_HSSI 0x8 -#define bRxHTSettle_RxHP 0x70 -#define bRxHTSettle_BBPPW 0x80 -#define bRxHTSettle_Idle 0x300 -#define bRxHTSettle_Reserved 0x1c00 -#define bRxHTRxHPEn 0x8000 -#define bRxHTAGCFreezeThres 0x30000 -#define bRxHTAGCTogetherEn 0x40000 -#define bRxHTAGCMin 0x80000 -#define bRxHTAGCEn 0x100000 -#define bRxHTDAGCEn 0x200000 -#define bRxHTRxHP_BBP 0x1c00000 -#define bRxHTRxHP_Final 0xe0000000 -#define bRxPWRatioTH 0x3 -#define bRxPWRatioEn 0x4 -#define bRxMFHold 0x3800 -#define bRxPD_Delay_TH1 0x38 -#define bRxPD_Delay_TH2 0x1c0 -#define bRxPD_DC_COUNT_MAX 0x600 -/* #define bRxMF_Hold 0x3800 */ -#define bRxPD_Delay_TH 0x8000 -#define bRxProcess_Delay 0xf0000 -#define bRxSearchrange_GI2_Early 0x700000 -#define bRxFrame_Guard_Counter_L 0x3800000 -#define bRxSGI_Guard_L 0xc000000 -#define bRxSGI_Search_L 0x30000000 -#define bRxSGI_TH 0xc0000000 -#define bDFSCnt0 0xff -#define bDFSCnt1 0xff00 -#define bDFSFlag 0xf0000 - -#define bMFWeightSum 0x300000 -#define bMinIdxTH 0x7f000000 - -#define bDAFormat 0x40000 - -#define bTxChEmuEnable 0x01000000 - -#define bTRSWIsolation_A 0x7f -#define bTRSWIsolation_B 0x7f00 -#define bTRSWIsolation_C 0x7f0000 -#define bTRSWIsolation_D 0x7f000000 - -#define bExtLNAGain 0x7c00 - /* page d */ #define bSTBCEn 0x4 #define bAntennaMapping 0x10 From b544d0f31d145951976a89faa2bd9e3ba25a073b Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:30 +0100 Subject: [PATCH 558/903] staging:rtl8192u: Remove unused page d Bit Mask definitions - Style Remove the unused 'page d' Bit Mask definitions. These definitions will fail the checkpatch CamelCase naming test. Since the definitions are unused in code they have been removed, rather then renaming. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 107 ----------------------- 1 file changed, 107 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index b0bcef2e73a6..671fd35297d5 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -123,113 +123,6 @@ /* page-a */ #define bCCKSideBand 0x10 -/* page d */ -#define bSTBCEn 0x4 -#define bAntennaMapping 0x10 -#define bNss 0x20 -#define bCFOAntSumD 0x200 -#define bPHYCounterReset 0x8000000 -#define bCFOReportGet 0x4000000 -#define bOFDMContinueTx 0x10000000 -#define bOFDMSingleCarrier 0x20000000 -#define bOFDMSingleTone 0x40000000 -/* #define bRxPath1 0x01 - * #define bRxPath2 0x02 - * #define bRxPath3 0x04 - * #define bRxPath4 0x08 - * #define bTxPath1 0x10 - * #define bTxPath2 0x20 - */ -#define bHTDetect 0x100 -#define bCFOEn 0x10000 -#define bCFOValue 0xfff00000 -#define bSigTone_Re 0x3f -#define bSigTone_Im 0x7f00 -#define bCounter_CCA 0xffff -#define bCounter_ParityFail 0xffff0000 -#define bCounter_RateIllegal 0xffff -#define bCounter_CRC8Fail 0xffff0000 -#define bCounter_MCSNoSupport 0xffff -#define bCounter_FastSync 0xffff -#define bShortCFO 0xfff -#define bShortCFOTLength 12 /* total */ -#define bShortCFOFLength 11 /* fraction */ -#define bLongCFO 0x7ff -#define bLongCFOTLength 11 -#define bLongCFOFLength 11 -#define bTailCFO 0x1fff -#define bTailCFOTLength 13 -#define bTailCFOFLength 12 - -#define bmax_en_pwdB 0xffff -#define bCC_power_dB 0xffff0000 -#define bnoise_pwdB 0xffff -#define bPowerMeasTLength 10 -#define bPowerMeasFLength 3 -#define bRx_HT_BW 0x1 -#define bRxSC 0x6 -#define bRx_HT 0x8 - -#define bNB_intf_det_on 0x1 -#define bIntf_win_len_cfg 0x30 -#define bNB_Intf_TH_cfg 0x1c0 - -#define bRFGain 0x3f -#define bTableSel 0x40 -#define bTRSW 0x80 - -#define bRxSNR_A 0xff -#define bRxSNR_B 0xff00 -#define bRxSNR_C 0xff0000 -#define bRxSNR_D 0xff000000 -#define bSNREVMTLength 8 -#define bSNREVMFLength 1 - -#define bCSI1st 0xff -#define bCSI2nd 0xff00 -#define bRxEVM1st 0xff0000 -#define bRxEVM2nd 0xff000000 - -#define bSIGEVM 0xff -#define bPWDB 0xff00 -#define bSGIEN 0x10000 - -#define bSFactorQAM1 0xf -#define bSFactorQAM2 0xf0 -#define bSFactorQAM3 0xf00 -#define bSFactorQAM4 0xf000 -#define bSFactorQAM5 0xf0000 -#define bSFactorQAM6 0xf0000 -#define bSFactorQAM7 0xf00000 -#define bSFactorQAM8 0xf000000 -#define bSFactorQAM9 0xf0000000 -#define bCSIScheme 0x100000 - -#define bNoiseLvlTopSet 0x3 -#define bChSmooth 0x4 -#define bChSmoothCfg1 0x38 -#define bChSmoothCfg2 0x1c0 -#define bChSmoothCfg3 0xe00 -#define bChSmoothCfg4 0x7000 -#define bMRCMode 0x800000 -#define bTHEVMCfg 0x7000000 - -#define bLoopFitType 0x1 -#define bUpdCFO 0x40 -#define bUpdCFOOffData 0x80 -#define bAdvUpdCFO 0x100 -#define bAdvTimeCtrl 0x800 -#define bUpdClko 0x1000 -#define bFC 0x6000 -#define bTrackingMode 0x8000 -#define bPhCmpEnable 0x10000 -#define bUpdClkoLTF 0x20000 -#define bComChCFO 0x40000 -#define bCSIEstiMode 0x80000 -#define bAdvUpdEqz 0x100000 -#define bUChCfg 0x7000000 -#define bUpdEqz 0x8000000 - /* page e */ #define bTxAGCRate18_06 0x7f7f7f7f #define bTxAGCRate54_24 0x7f7f7f7f From 8e5aad33b7218e395aa3d672da19af5c213cfde3 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:31 +0100 Subject: [PATCH 559/903] staging:rtl8192u: Remove unused page e Bit Mask definitions - Style Remove the unused 'page e' Bit Mask definitions. These definitions will fail the checkpatch CamelCase naming tests. As they are unused in code they have simply been removed rather then renaming. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 671fd35297d5..93be2b2cf899 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -124,15 +124,7 @@ #define bCCKSideBand 0x10 /* page e */ -#define bTxAGCRate18_06 0x7f7f7f7f -#define bTxAGCRate54_24 0x7f7f7f7f -#define bTxAGCRateMCS32 0x7f #define bTxAGCRateCCK 0x7f00 -#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f -#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f -#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f -#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f - /* Rx Pseduo noise */ #define bRxPesudoNoiseOn 0x20000000 From ac21097a65c2053b0b617d70de7e33548524c5a0 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:32 +0100 Subject: [PATCH 560/903] staging:rtl8192u: Remove unused Rx Pseduo noise Bit Mask defs - Style Remove the unused 'Rx Pseduo noise' Bit Mask definitions. These definitions will fail the checkpatch CamelCase naming test. Since the definitions are unused in code they have simply been removed, rather then renaming. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 93be2b2cf899..b3f9f7e65073 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -126,17 +126,6 @@ /* page e */ #define bTxAGCRateCCK 0x7f00 -/* Rx Pseduo noise */ -#define bRxPesudoNoiseOn 0x20000000 -#define bRxPesudoNoise_A 0xff -#define bRxPesudoNoise_B 0xff00 -#define bRxPesudoNoise_C 0xff0000 -#define bRxPesudoNoise_D 0xff000000 -#define bPesudoNoiseState_A 0xffff -#define bPesudoNoiseState_B 0xffff0000 -#define bPesudoNoiseState_C 0xffff -#define bPesudoNoiseState_D 0xffff0000 - /* RF * Zebra1 */ From 946fb23dc751f9fbe449b7fc56e88a8cab4d4b58 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:33 +0100 Subject: [PATCH 561/903] staging:rtl8192u: Remove unused RF Zebra1 Bit Mask definitions - Style Remove the unused 'RF Zebra1' bit mask definitions. These definitions fail the checkpatch CamelCase naming tests. Since the definitions are unused in code they have simply been removed, rather then renaming. This is a coding style change which will have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index b3f9f7e65073..09eade1f4dbe 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -129,15 +129,7 @@ /* RF * Zebra1 */ -#define bZebra1_HSSIEnable 0x8 -#define bZebra1_TRxControl 0xc00 -#define bZebra1_TRxGainSetting 0x07f -#define bZebra1_RxCorner 0xc00 -#define bZebra1_TxChargePump 0x38 -#define bZebra1_RxChargePump 0x7 #define bZebra1_ChannelNum 0xf80 -#define bZebra1_TxLPFBW 0x400 -#define bZebra1_RxLPFBW 0x600 /* Zebra4 */ #define bRTL8256RegModeCtrl1 0x100 From 2e7394899f3ecdc8c31f34821ba9c4a1471db640 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:34 +0100 Subject: [PATCH 562/903] staging:rtl8192u: Remove unused Zebra4 bit mask definitions - Style Remove the unused 'Zebra4' bit mask definitions. These definitions fail the checkpatch CamelCase naming tests. Rather then renaming, as the definitions are unused they have simply been removed. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 09eade1f4dbe..708dae62c644 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -131,12 +131,6 @@ */ #define bZebra1_ChannelNum 0xf80 -/* Zebra4 */ -#define bRTL8256RegModeCtrl1 0x100 -#define bRTL8256RegModeCtrl0 0x40 -#define bRTL8256_TxLPFBW 0x18 -#define bRTL8256_RxLPFBW 0x600 - /* RTL8258 */ #define bRTL8258_TxLPFBW 0xc #define bRTL8258_RxLPFBW 0xc00 From 8faf8e9c9f428fb027bed7d438b0c9738315fae2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 22 Jul 2018 23:10:35 +0100 Subject: [PATCH 563/903] staging:rtl8192u: Remove unused RTL8258 bit mask definitions - Style Remove the unused 'RTL8258' bit mask definitions. These definitions fail the checkpatch CamelCase naming tests. Since the definitions are unused in code they have been removed, rather then renaming. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phyreg.h | 59 ------------------------ 1 file changed, 59 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 708dae62c644..65ee6088324c 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -132,24 +132,10 @@ #define bZebra1_ChannelNum 0xf80 /* RTL8258 */ -#define bRTL8258_TxLPFBW 0xc -#define bRTL8258_RxLPFBW 0xc00 -#define bRTL8258_RSSILPFBW 0xc0 - -/* byte endable for sb_write */ -#define bByte0 0x1 -#define bByte1 0x2 -#define bByte2 0x4 -#define bByte3 0x8 -#define bWord0 0x3 -#define bWord1 0xc -#define bDWord 0xf - /* for PutRegsetting & GetRegSetting BitMask */ #define bMaskByte0 0xff #define bMaskByte1 0xff00 #define bMaskByte2 0xff0000 -#define bMaskByte3 0xff000000 #define bMaskHWord 0xffff0000 #define bMaskLWord 0x0000ffff #define bMaskDWord 0xffffffff @@ -157,49 +143,4 @@ /* for PutRFRegsetting & GetRFRegSetting BitMask */ #define bMask12Bits 0xfff -#define bEnable 0x1 -#define bDisable 0x0 - -#define LeftAntenna 0x0 -#define RightAntenna 0x1 - -#define tCheckTxStatus 500 /* 500ms */ -#define tUpdateRxCounter 100 /* 100ms */ - -#define rateCCK 0 -#define rateOFDM 1 -#define rateHT 2 - -/* define Register-End */ -#define bPMAC_End 0x1ff -#define bFPGAPHY0_End 0x8ff -#define bFPGAPHY1_End 0x9ff -#define bCCKPHY0_End 0xaff -#define bOFDMPHY0_End 0xcff -#define bOFDMPHY1_End 0xdff - -/* define max debug item in each debug page - * #define bMaxItem_FPGA_PHY0 0x9 - * #define bMaxItem_FPGA_PHY1 0x3 - * #define bMaxItem_PHY_11B 0x16 - * #define bMaxItem_OFDM_PHY0 0x29 - * #define bMaxItem_OFDM_PHY1 0x0 - */ - -#define bPMACControl 0x0 -#define bWMACControl 0x1 -#define bWNICControl 0x2 - -#define PathA 0x0 -#define PathB 0x1 -#define PathC 0x2 -#define PathD 0x3 - -#define rRTL8256RxMixerPole 0xb -#define bZebraRxMixerPole 0x6 -#define rRTL8256TxBBOPBias 0x9 -#define bRTL8256TxBBOPBias 0x400 -#define rRTL8256TxBBBW 19 -#define bRTL8256TxBBBW 0x18 - #endif /* __INC_HAL8190PCIPHYREG_H */ From c808e16d17b7f30aa02a8daccffc3f0b41b42300 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:17 +0100 Subject: [PATCH 564/903] staging:rtl8192u: Remove typedef of u32 to QOS_MODE - Style The typedef of QOS_MODE as a u32 is contrary to coding standard and fails the checkpatch tests for defining new types in code. Definitions of type QOS_MODE have simply been replaced with a u32 type. This is a coding style change which should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 96e9621e9887..45ba96a13b13 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -16,7 +16,6 @@ // QOS_HCCA = 4, //}QOS_MODE,*PQOS_MODE; // -typedef u32 QOS_MODE, *PQOS_MODE; #define QOS_DISABLE 0 #define QOS_WMM 1 #define QOS_WMMSA 2 @@ -454,8 +453,8 @@ typedef struct _STA_QOS { u8 *WMMIE; // Part 1. Self QoS Mode. - QOS_MODE QosCapability; //QoS Capability, 2006-06-14 Isaiah - QOS_MODE CurrentQosMode; + u32 QosCapability; // QOS_MODE QoS Capability, 2006-06-14 Isaiah + u32 CurrentQosMode; // QOS_MODE // For WMM Power Save Mode : // ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah @@ -502,7 +501,7 @@ typedef struct _STA_QOS { // Ref: BssDscr in 8185 code. [def. in BssDscr.h] // typedef struct _BSS_QOS { - QOS_MODE bdQoSMode; + u32 bdQoSMode; // QOS_MODE u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; u8 *bdWMMIE; From 3171b2ced26f6a2581deb1355123f84b8881a772 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:18 +0100 Subject: [PATCH 565/903] staging:rtl8192u: Remove unused enumerated type ACK_POLICY - Style The enumerated type ACK_POLICY is not used in code so it has been removed from the source code. This is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 45ba96a13b13..fb2745da5844 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -26,15 +26,6 @@ #define AC_PARAM_SIZE 4 #define WMM_PARAM_ELE_BODY_LEN 18 -// -// QoS ACK Policy Field Values -// Ref: WMM spec 2.1.6: QoS Control Field, p.10. -// -typedef enum _ACK_POLICY { - eAckPlc0_ACK = 0x00, - eAckPlc1_NoACK = 0x01, -} ACK_POLICY, *PACK_POLICY; - #define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) // From 5a2e242f6758496a38f1433e25b2fa45ba00a96c Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:19 +0100 Subject: [PATCH 566/903] staging:rtl8192u: Remove unused QOS definitions - Style Remove the unused QOS related types. Since definitions are not used simply remove from code. This change is a coding style change and should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index fb2745da5844..a83abaf3a2ea 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -4,25 +4,6 @@ #define MAX_WMMELE_LENGTH 64 -// -// QoS mode. -// enum 0, 1, 2, 4: since we can use the OR(|) operation. -// -// QOS_MODE is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko. -//typedef enum _QOS_MODE{ -// QOS_DISABLE = 0, -// QOS_WMM = 1, -// QOS_EDCA = 2, -// QOS_HCCA = 4, -//}QOS_MODE,*PQOS_MODE; -// -#define QOS_DISABLE 0 -#define QOS_WMM 1 -#define QOS_WMMSA 2 -#define QOS_EDCA 4 -#define QOS_HCCA 8 -#define QOS_WMM_UAPSD 16 //WMM Power Save, 2006-06-14 Isaiah - #define AC_PARAM_SIZE 4 #define WMM_PARAM_ELE_BODY_LEN 18 @@ -506,14 +487,11 @@ typedef struct _BSS_QOS { AC_PARAM AcParameter[4]; } BSS_QOS, *PBSS_QOS; - // // Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code. //#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0) // #define sQoSCtlLng 2 -#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE) ? sQoSCtlLng : 0) - //Added by joseph //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP From a61c15e653f83444fa1a26297a90683315d80a65 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:20 +0100 Subject: [PATCH 567/903] staging:rtl8192u: Removed unused structure BSS_QOS - Style The structure BSS_QOS is not used in code so has simply been removed. The change is a coding style change and should not impact runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index a83abaf3a2ea..d202244b8cac 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -468,25 +468,6 @@ typedef struct _STA_QOS { } STA_QOS, *PSTA_QOS; -// -// BSS QOS data. -// Ref: BssDscr in 8185 code. [def. in BssDscr.h] -// -typedef struct _BSS_QOS { - u32 bdQoSMode; // QOS_MODE - - u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; - u8 *bdWMMIE; - - QOS_ELE_SUBTYPE EleSubType; - - u8 *pWMMInfoEle; - u8 *pWMMParamEle; - - QOS_INFO_FIELD QosInfoField; - AC_PARAM AcParameter[4]; -} BSS_QOS, *PBSS_QOS; - // // Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code. //#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0) From 7b877cef67e8f1e75d865019619d9edee0d025d3 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:21 +0100 Subject: [PATCH 568/903] staging:rtl8192u: Remove unused structure STA_QOS - Style Remove structure STA_QOS as it is unused in code. This change is a coding style change so should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index d202244b8cac..da74d4a29ed2 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -415,59 +415,6 @@ typedef struct _OCTET_STRING { u16 Length; } OCTET_STRING, *POCTET_STRING; -// -// STA QoS data. -// Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h] -// -typedef struct _STA_QOS { - //DECLARE_RT_OBJECT(STA_QOS); - u8 WMMIEBuf[MAX_WMMELE_LENGTH]; - u8 *WMMIE; - - // Part 1. Self QoS Mode. - u32 QosCapability; // QOS_MODE QoS Capability, 2006-06-14 Isaiah - u32 CurrentQosMode; // QOS_MODE - - // For WMM Power Save Mode : - // ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah - AC_UAPSD b4ac_Uapsd; //VoUapsd(bit0), ViUapsd(bit1), BkUapsd(bit2), BeUapsd(bit3), - AC_UAPSD Curr4acUapsd; - u8 bInServicePeriod; - u8 MaxSPLength; - int NumBcnBeforeTrigger; - - // Part 2. EDCA Parameter (perAC) - u8 *pWMMInfoEle; - u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; - u8 WMMPELength; - - // - //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element. - // By Bruce, 2008-01-30. - // Part 2. EDCA Parameter (perAC) - QOS_INFO_FIELD QosInfoField_STA; // Maintained by STA - QOS_INFO_FIELD QosInfoField_AP; // Retrieved from AP - - AC_PARAM CurAcParameters[4]; - - // Part 3. ACM - ACM acm[4]; - ACM_METHOD AcmMethod; - - // Part 4. Per TID (Part 5: TCLASS will be described by TStream) - QOS_TSTREAM TStream[16]; - WMM_TSPEC TSpec; - - u32 QBssWirelessMode; - - // No Ack Setting - u8 bNoAck; - - // Enable/Disable Rx immediate BA capability. - u8 bEnableRxImmBA; - -} STA_QOS, *PSTA_QOS; - // // Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code. //#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0) From 31bd6754f4bc9f31608e58b1ee94c86484009ac9 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:22 +0100 Subject: [PATCH 569/903] staging:rtl8192u: Remove unused structure QOS_CTRL_FIELD - Style The structure QOS_CTRL_FIELD is unused in code so has simply been removed from source. This is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index da74d4a29ed2..90f5939c9ecc 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -9,56 +9,6 @@ #define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) -// -// QoS Control Field -// Ref: -// 1. WMM spec 2.1.6: QoS Control Field, p.9. -// 2. 802.11e/D13.0 7.1.3.5, p.26. -// -typedef union _QOS_CTRL_FIELD { - u8 charData[2]; - u16 shortData; - - // WMM spec - struct { - u8 UP:3; - u8 usRsvd1:1; - u8 EOSP:1; - u8 AckPolicy:2; - u8 usRsvd2:1; - u8 ucRsvdByte; - } WMM; - - // 802.11e: QoS data type frame sent by non-AP QSTAs. - struct { - u8 TID:4; - u8 bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size. - u8 AckPolicy:2; - u8 usRsvd:1; - u8 TxopOrQsize; // (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size. - } BySta; - - // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC. - struct { - u8 TID:4; - u8 EOSP:1; - u8 AckPolicy:2; - u8 usRsvd:1; - u8 PSBufState; // QAP PS Buffer State. - } ByHc_Data; - - // 802.11e: QoS (+) CF-Poll frames sent by HC. - struct { - u8 TID:4; - u8 EOSP:1; - u8 AckPolicy:2; - u8 usRsvd:1; - u8 TxopLimit; // TXOP Limit. - } ByHc_CFP; - -} QOS_CTRL_FIELD, *PQOS_CTRL_FIELD; - - // // QoS Info Field // Ref: From 28598fbe6fe00f2cf5d5925b9953af544c7876aa Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:23 +0100 Subject: [PATCH 570/903] staging:rtl8192u: Remove unused union QOS_INFO_FIELD - Style The union QOS_INFO_FIELD is unused in code so has been removed from source. This change is a coding style change so should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 86 ------------------- 1 file changed, 86 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 90f5939c9ecc..e0c51c5c6816 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -9,92 +9,6 @@ #define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) -// -// QoS Info Field -// Ref: -// 1. WMM spec 2.2.1: WME Information Element, p.11. -// 2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h] -// -typedef union _QOS_INFO_FIELD { - u8 charData; - - struct { - u8 ucParameterSetCount:4; - u8 ucReserved:4; - } WMM; - - struct { - //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah - u8 ucAC_VO_UAPSD:1; - u8 ucAC_VI_UAPSD:1; - u8 ucAC_BE_UAPSD:1; - u8 ucAC_BK_UAPSD:1; - u8 ucReserved1:1; - u8 ucMaxSPLen:2; - u8 ucReserved2:1; - - } ByWmmPsSta; - - struct { - //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah - u8 ucParameterSetCount:4; - u8 ucReserved:3; - u8 ucApUapsd:1; - } ByWmmPsAp; - - struct { - u8 ucAC3_UAPSD:1; - u8 ucAC2_UAPSD:1; - u8 ucAC1_UAPSD:1; - u8 ucAC0_UAPSD:1; - u8 ucQAck:1; - u8 ucMaxSPLen:2; - u8 ucMoreDataAck:1; - } By11eSta; - - struct { - u8 ucParameterSetCount:4; - u8 ucQAck:1; - u8 ucQueueReq:1; - u8 ucTXOPReq:1; - u8 ucReserved:1; - } By11eAp; - - struct { - u8 ucReserved1:4; - u8 ucQAck:1; - u8 ucReserved2:2; - u8 ucMoreDataAck:1; - } ByWmmsaSta; - - struct { - u8 ucReserved1:4; - u8 ucQAck:1; - u8 ucQueueReq:1; - u8 ucTXOPReq:1; - u8 ucReserved2:1; - } ByWmmsaAp; - - struct { - u8 ucAC3_UAPSD:1; - u8 ucAC2_UAPSD:1; - u8 ucAC1_UAPSD:1; - u8 ucAC0_UAPSD:1; - u8 ucQAck:1; - u8 ucMaxSPLen:2; - u8 ucMoreDataAck:1; - } ByAllSta; - - struct { - u8 ucParameterSetCount:4; - u8 ucQAck:1; - u8 ucQueueReq:1; - u8 ucTXOPReq:1; - u8 ucApUapsd:1; - } ByAllAp; - -} QOS_INFO_FIELD, *PQOS_INFO_FIELD; - // // ACI to AC coding. // Ref: WMM spec 2.2.2: WME Parameter Element, p.13. From f3bbec3bb77f6c64b70aa0fe69a4905a50624d10 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:24 +0100 Subject: [PATCH 571/903] staging:rtl8192u: Remove the unused AC_CODING definitions - Style The AC_CODING definitions are unused in code, so have simply been removed from source. This is a coding style change and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index e0c51c5c6816..455b87edc7fb 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -9,26 +9,6 @@ #define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) -// -// ACI to AC coding. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.13. -// -// AC_CODING is redefined for enum can't be ++, | under C++ compiler, 2006.05.17, by rcnjko. -//typedef enum _AC_CODING{ -// AC0_BE = 0, // ACI: 0x00 // Best Effort -// AC1_BK = 1, // ACI: 0x01 // Background -// AC2_VI = 2, // ACI: 0x10 // Video -// AC3_VO = 3, // ACI: 0x11 // Voice -// AC_MAX = 4, // Max: define total number; Should not to be used as a real enum. -//}AC_CODING,*PAC_CODING; -// -typedef u32 AC_CODING; -#define AC0_BE 0 // ACI: 0x00 // Best Effort -#define AC1_BK 1 // ACI: 0x01 // Background -#define AC2_VI 2 // ACI: 0x10 // Video -#define AC3_VO 3 // ACI: 0x11 // Voice -#define AC_MAX 4 // Max: define total number; Should not to be used as a real enum. - // // ACI/AIFSN Field. // Ref: WMM spec 2.2.2: WME Parameter Element, p.12. From 1a59f17aa3d4c82a5e0187aac118b05c435e1696 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:25 +0100 Subject: [PATCH 572/903] staging:rtl8192u: Remove unused enumerated type QOS_ELE_SUBTYPE - Style The enumerated type QOS_ELE_SUBTYPE is unused in code so has been removed from code. This is a coding style change which should have not impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 455b87edc7fb..6cfae00919c1 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -51,17 +51,6 @@ typedef union _AC_PARAM { } f; // Field } AC_PARAM, *PAC_PARAM; - - -// -// QoS element subtype -// -typedef enum _QOS_ELE_SUBTYPE { - QOSELE_TYPE_INFO = 0x00, // 0x00: Information element - QOSELE_TYPE_PARAM = 0x01, // 0x01: parameter element -} QOS_ELE_SUBTYPE, *PQOS_ELE_SUBTYPE; - - // // Direction Field Values. // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. From 8d2314368f2469b1ec89817ee04db6b2d3e2e680 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:26 +0100 Subject: [PATCH 573/903] staging:rtl8192u: Remove unused structure QOS_TSTREAM - Style The structure QOS_TSTREAM is unused in code so has simply been removed. This change is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 6cfae00919c1..7028c9ae888a 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -214,17 +214,6 @@ typedef union _QOS_TCLAS { } TYPE2_8021Q; } QOS_TCLAS, *PQOS_TCLAS; -//typedef struct _WMM_TSTREAM{ -// -//- TSPEC -//- AC (which to mapping) -//} WMM_TSTREAM, *PWMM_TSTREAM; -typedef struct _QOS_TSTREAM { - u8 AC; - WMM_TSPEC TSpec; - QOS_TCLAS TClass; -} QOS_TSTREAM, *PQOS_TSTREAM; - //typedef struct _U_APSD{ //- TriggerEnable [4] //- MaxSPLength From 2f20e918e84de3def6c41e5745315fc676d5ea92 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:27 +0100 Subject: [PATCH 574/903] staging:rtl8192u: Remove unused structure WMM_TSPEC - Style Remove the structure WMM_TSPEC as it is unused. This change is a coding style change and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 7028c9ae888a..58101d1ff2b8 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -112,21 +112,6 @@ typedef union _TSPEC_BODY { } f; // Field } TSPEC_BODY, *PTSPEC_BODY; - -// -// WMM TSPEC Element. -// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16. -// -typedef struct _WMM_TSPEC { - u8 ID; - u8 Length; - u8 OUI[3]; - u8 OUI_Type; - u8 OUI_SubType; - u8 Version; - TSPEC_BODY Body; -} WMM_TSPEC, *PWMM_TSPEC; - // // ACM implementation method. // Annie, 2005-12-13. From 5f155b1de5339be2a4667ac245b996e2705a63f4 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:28 +0100 Subject: [PATCH 575/903] staging:rtl8192u: Remove unused enumerated type ACM_METHOD - Style Remove the enumerated type ACM_METHOD as it is unused in code. This is a coding style change and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 58101d1ff2b8..49d9184f22ec 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -112,17 +112,6 @@ typedef union _TSPEC_BODY { } f; // Field } TSPEC_BODY, *PTSPEC_BODY; -// -// ACM implementation method. -// Annie, 2005-12-13. -// -typedef enum _ACM_METHOD { - eAcmWay0_SwAndHw = 0, // By SW and HW. - eAcmWay1_HW = 1, // By HW. - eAcmWay2_SW = 2, // By SW. -} ACM_METHOD, *PACM_METHOD; - - typedef struct _ACM { // u8 RegEnableACM; u64 UsedTime; From 90c7dbf0bb38941989bee70eaedf6c7e5955490e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:29 +0100 Subject: [PATCH 576/903] staging:rtl8192u: Remove unused structure ACM - Style Remove the structure ACM as it is unused in code. This change is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 49d9184f22ec..878c467e7b89 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -112,13 +112,6 @@ typedef union _TSPEC_BODY { } f; // Field } TSPEC_BODY, *PTSPEC_BODY; -typedef struct _ACM { -// u8 RegEnableACM; - u64 UsedTime; - u64 MediumTime; - u8 HwAcmCtl; // TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B). -} ACM, *PACM; - typedef u8 AC_UAPSD, *PAC_UAPSD; #define GET_VO_UAPSD(_apsd) ((_apsd) & BIT(0)) From 1026e4aa828e7a03790e241a319b19cbad0edf9e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:30 +0100 Subject: [PATCH 577/903] staging:rtl8192u: Remove unused AC_UAPSD definitions - Style Remove the definitions associated with AC_UAPSD. These definitions are not used in code so have simply been removed. This is a coding style change and should have no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 878c467e7b89..471874dd8cb5 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -112,21 +112,6 @@ typedef union _TSPEC_BODY { } f; // Field } TSPEC_BODY, *PTSPEC_BODY; -typedef u8 AC_UAPSD, *PAC_UAPSD; - -#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT(0)) -#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT(0)) - -#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT(1)) -#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT(1)) - -#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT(2)) -#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT(2)) - -#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT(3)) -#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT(3)) - - //typedef struct _TCLASS{ // TODO //} TCLASS, *PTCLASS; From 670c6365c91e345582bf905e946ed35fb684891e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Mon, 23 Jul 2018 21:50:31 +0100 Subject: [PATCH 578/903] staging:rtl8192u: Remove unused definition of sQoSCtlLng - Style Remove sQoSCtlLng. The constant sQoSCtlLng is never used in code so has been removed. This is a coding style change so should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 471874dd8cb5..8ee9370520f3 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -189,12 +189,6 @@ typedef struct _OCTET_STRING { u16 Length; } OCTET_STRING, *POCTET_STRING; -// -// Ref: sQoSCtlLng and QoSCtl definition in 8185 QoS code. -//#define QoSCtl (( (Adapter->bRegQoS) && (Adapter->dot11QoS.QoSMode &(QOS_EDCA|QOS_HCCA)) ) ?sQoSCtlLng:0) -// -#define sQoSCtlLng 2 - //Added by joseph //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP //#define UP2AC(up) ((up<3)?((up==0)?1:0):(up>>1)) From 4a965c5f89decd636129cddc47e5f2c61e8f13e6 Mon Sep 17 00:00:00 2001 From: Jacob Feder Date: Sun, 22 Jul 2018 21:27:37 -0400 Subject: [PATCH 579/903] staging: add driver for Xilinx AXI-Stream FIFO v4.1 IP core This IP core has read and write AXI-Stream FIFOs, the contents of which can be accessed from the AXI4 memory-mapped interface. This is useful for transferring data from a processor into the FPGA fabric. The driver creates a character device that can be read/written to with standard open/read/write/close. See Xilinx PG080 document for IP details. https://www.xilinx.com/support/documentation/ip_documentation/axi_fifo_mm_s/v4_1/pg080-axi-fifo-mm-s.pdf The driver currently supports only store-forward mode with a 32-bit AXI4 Lite interface. DOES NOT support: - cut-through mode - AXI4 (non-lite) Signed-off-by: Jacob Feder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/axis-fifo/Kconfig | 9 + drivers/staging/axis-fifo/Makefile | 1 + drivers/staging/axis-fifo/README | 0 drivers/staging/axis-fifo/axis-fifo.c | 1108 +++++++++++++++++++++++ drivers/staging/axis-fifo/axis-fifo.txt | 89 ++ 7 files changed, 1210 insertions(+) create mode 100644 drivers/staging/axis-fifo/Kconfig create mode 100644 drivers/staging/axis-fifo/Makefile create mode 100644 drivers/staging/axis-fifo/README create mode 100644 drivers/staging/axis-fifo/axis-fifo.c create mode 100644 drivers/staging/axis-fifo/axis-fifo.txt diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 3fa39109bd75..17fd9b455ec6 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -124,4 +124,6 @@ source "drivers/staging/mt7621-dts/Kconfig" source "drivers/staging/gasket/Kconfig" +source "drivers/staging/axis-fifo/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 7a0ff10f5ebb..231698f2da7d 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-mmc/ obj-$(CONFIG_SOC_MT7621) += mt7621-eth/ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ +obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/ diff --git a/drivers/staging/axis-fifo/Kconfig b/drivers/staging/axis-fifo/Kconfig new file mode 100644 index 000000000000..687537203d9c --- /dev/null +++ b/drivers/staging/axis-fifo/Kconfig @@ -0,0 +1,9 @@ +# +# "Xilinx AXI-Stream FIFO IP core driver" +# +config XIL_AXIS_FIFO + tristate "Xilinx AXI-Stream FIFO IP core driver" + default n + help + This adds support for the Xilinx AXI-Stream + FIFO IP core driver. diff --git a/drivers/staging/axis-fifo/Makefile b/drivers/staging/axis-fifo/Makefile new file mode 100644 index 000000000000..fe62cd1ac5de --- /dev/null +++ b/drivers/staging/axis-fifo/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo.o diff --git a/drivers/staging/axis-fifo/README b/drivers/staging/axis-fifo/README new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c new file mode 100644 index 000000000000..2a73302620ec --- /dev/null +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -0,0 +1,1108 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx AXIS FIFO: interface to the Xilinx AXI-Stream FIFO IP core + * + * Copyright (C) 2018 Jacob Feder + * + * Authors: Jacob Feder + * + * See Xilinx PG080 document for IP details + */ + +/* ---------------------------- + * includes + * ---------------------------- + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* ---------------------------- + * driver parameters + * ---------------------------- + */ + +#define DRIVER_NAME "axis_fifo" + +#define READ_BUF_SIZE 128U /* read buffer length in words */ +#define WRITE_BUF_SIZE 128U /* write buffer length in words */ + +/* ---------------------------- + * IP register offsets + * ---------------------------- + */ + +#define XLLF_ISR_OFFSET 0x00000000 /* Interrupt Status */ +#define XLLF_IER_OFFSET 0x00000004 /* Interrupt Enable */ + +#define XLLF_TDFR_OFFSET 0x00000008 /* Transmit Reset */ +#define XLLF_TDFV_OFFSET 0x0000000c /* Transmit Vacancy */ +#define XLLF_TDFD_OFFSET 0x00000010 /* Transmit Data */ +#define XLLF_TLR_OFFSET 0x00000014 /* Transmit Length */ + +#define XLLF_RDFR_OFFSET 0x00000018 /* Receive Reset */ +#define XLLF_RDFO_OFFSET 0x0000001c /* Receive Occupancy */ +#define XLLF_RDFD_OFFSET 0x00000020 /* Receive Data */ +#define XLLF_RLR_OFFSET 0x00000024 /* Receive Length */ +#define XLLF_SRR_OFFSET 0x00000028 /* Local Link Reset */ +#define XLLF_TDR_OFFSET 0x0000002C /* Transmit Destination */ +#define XLLF_RDR_OFFSET 0x00000030 /* Receive Destination */ + +/* ---------------------------- + * reset register masks + * ---------------------------- + */ + +#define XLLF_RDFR_RESET_MASK 0x000000a5 /* receive reset value */ +#define XLLF_TDFR_RESET_MASK 0x000000a5 /* Transmit reset value */ +#define XLLF_SRR_RESET_MASK 0x000000a5 /* Local Link reset value */ + +/* ---------------------------- + * interrupt masks + * ---------------------------- + */ + +#define XLLF_INT_RPURE_MASK 0x80000000 /* Receive under-read */ +#define XLLF_INT_RPORE_MASK 0x40000000 /* Receive over-read */ +#define XLLF_INT_RPUE_MASK 0x20000000 /* Receive underrun (empty) */ +#define XLLF_INT_TPOE_MASK 0x10000000 /* Transmit overrun */ +#define XLLF_INT_TC_MASK 0x08000000 /* Transmit complete */ +#define XLLF_INT_RC_MASK 0x04000000 /* Receive complete */ +#define XLLF_INT_TSE_MASK 0x02000000 /* Transmit length mismatch */ +#define XLLF_INT_TRC_MASK 0x01000000 /* Transmit reset complete */ +#define XLLF_INT_RRC_MASK 0x00800000 /* Receive reset complete */ +#define XLLF_INT_TFPF_MASK 0x00400000 /* Tx FIFO Programmable Full */ +#define XLLF_INT_TFPE_MASK 0x00200000 /* Tx FIFO Programmable Empty */ +#define XLLF_INT_RFPF_MASK 0x00100000 /* Rx FIFO Programmable Full */ +#define XLLF_INT_RFPE_MASK 0x00080000 /* Rx FIFO Programmable Empty */ +#define XLLF_INT_ALL_MASK 0xfff80000 /* All the ints */ +#define XLLF_INT_ERROR_MASK 0xf2000000 /* Error status ints */ +#define XLLF_INT_RXERROR_MASK 0xe0000000 /* Receive Error status ints */ +#define XLLF_INT_TXERROR_MASK 0x12000000 /* Transmit Error status ints */ + +/* ---------------------------- + * globals + * ---------------------------- + */ + +static struct class *axis_fifo_driver_class; /* char device class */ + +static int read_timeout = 1000; /* ms to wait before read() times out */ +static int write_timeout = 1000; /* ms to wait before write() times out */ + +/* ---------------------------- + * module command-line arguments + * ---------------------------- + */ + +module_param(read_timeout, int, 0444); +MODULE_PARM_DESC(read_timeout, "ms to wait before blocking read() timing out; set to -1 for no timeout"); +module_param(write_timeout, int, 0444); +MODULE_PARM_DESC(write_timeout, "ms to wait before blocking write() timing out; set to -1 for no timeout"); + +/* ---------------------------- + * types + * ---------------------------- + */ + +struct axis_fifo { + int irq; /* interrupt */ + struct resource *mem; /* physical memory */ + void __iomem *base_addr; /* kernel space memory */ + + unsigned int rx_fifo_depth; /* max words in the receive fifo */ + unsigned int tx_fifo_depth; /* max words in the transmit fifo */ + int has_rx_fifo; /* whether the IP has the rx fifo enabled */ + int has_tx_fifo; /* whether the IP has the tx fifo enabled */ + + wait_queue_head_t read_queue; /* wait queue for asynchronos read */ + spinlock_t read_queue_lock; /* lock for reading waitqueue */ + wait_queue_head_t write_queue; /* wait queue for asynchronos write */ + spinlock_t write_queue_lock; /* lock for writing waitqueue */ + unsigned int write_flags; /* write file flags */ + unsigned int read_flags; /* read file flags */ + + struct device *dt_device; /* device created from the device tree */ + struct device *device; /* device associated with char_device */ + dev_t devt; /* our char device number */ + struct cdev char_device; /* our char device */ +}; + +/* ---------------------------- + * sysfs entries + * ---------------------------- + */ + +static ssize_t sysfs_write(struct device *dev, const char *buf, + size_t count, unsigned int addr_offset) +{ + struct axis_fifo *fifo = dev_get_drvdata(dev); + unsigned long tmp; + int rc; + + rc = kstrtoul(buf, 0, &tmp); + if (rc < 0) + return rc; + + iowrite32(tmp, fifo->base_addr + addr_offset); + + return count; +} + +static ssize_t sysfs_read(struct device *dev, char *buf, + unsigned int addr_offset) +{ + struct axis_fifo *fifo = dev_get_drvdata(dev); + unsigned int read_val; + unsigned int len; + char tmp[32]; + + read_val = ioread32(fifo->base_addr + addr_offset); + len = snprintf(tmp, sizeof(tmp), "0x%x\n", read_val); + memcpy(buf, tmp, len); + + return len; +} + +static ssize_t isr_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_ISR_OFFSET); +} + +static ssize_t isr_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_read(dev, buf, XLLF_ISR_OFFSET); +} + +static DEVICE_ATTR_RW(isr); + +static ssize_t ier_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_IER_OFFSET); +} + +static ssize_t ier_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_read(dev, buf, XLLF_IER_OFFSET); +} + +static DEVICE_ATTR_RW(ier); + +static ssize_t tdfr_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_TDFR_OFFSET); +} + +static DEVICE_ATTR_WO(tdfr); + +static ssize_t tdfv_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_read(dev, buf, XLLF_TDFV_OFFSET); +} + +static DEVICE_ATTR_RO(tdfv); + +static ssize_t tdfd_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_TDFD_OFFSET); +} + +static DEVICE_ATTR_WO(tdfd); + +static ssize_t tlr_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_TLR_OFFSET); +} + +static DEVICE_ATTR_WO(tlr); + +static ssize_t rdfr_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_RDFR_OFFSET); +} + +static DEVICE_ATTR_WO(rdfr); + +static ssize_t rdfo_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_read(dev, buf, XLLF_RDFO_OFFSET); +} + +static DEVICE_ATTR_RO(rdfo); + +static ssize_t rdfd_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_read(dev, buf, XLLF_RDFD_OFFSET); +} + +static DEVICE_ATTR_RO(rdfd); + +static ssize_t rlr_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_read(dev, buf, XLLF_RLR_OFFSET); +} + +static DEVICE_ATTR_RO(rlr); + +static ssize_t srr_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_SRR_OFFSET); +} + +static DEVICE_ATTR_WO(srr); + +static ssize_t tdr_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return sysfs_write(dev, buf, count, XLLF_TDR_OFFSET); +} + +static DEVICE_ATTR_WO(tdr); + +static ssize_t rdr_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_read(dev, buf, XLLF_RDR_OFFSET); +} + +static DEVICE_ATTR_RO(rdr); + +static struct attribute *axis_fifo_attrs[] = { + &dev_attr_isr.attr, + &dev_attr_ier.attr, + &dev_attr_tdfr.attr, + &dev_attr_tdfv.attr, + &dev_attr_tdfd.attr, + &dev_attr_tlr.attr, + &dev_attr_rdfr.attr, + &dev_attr_rdfo.attr, + &dev_attr_rdfd.attr, + &dev_attr_rlr.attr, + &dev_attr_srr.attr, + &dev_attr_tdr.attr, + &dev_attr_rdr.attr, + NULL, +}; + +static const struct attribute_group axis_fifo_attrs_group = { + .name = "ip_registers", + .attrs = axis_fifo_attrs, +}; + +/* ---------------------------- + * implementation + * ---------------------------- + */ + +static void reset_ip_core(struct axis_fifo *fifo) +{ + iowrite32(XLLF_SRR_RESET_MASK, fifo->base_addr + XLLF_SRR_OFFSET); + iowrite32(XLLF_TDFR_RESET_MASK, fifo->base_addr + XLLF_TDFR_OFFSET); + iowrite32(XLLF_RDFR_RESET_MASK, fifo->base_addr + XLLF_RDFR_OFFSET); + iowrite32(XLLF_INT_TC_MASK | XLLF_INT_RC_MASK | XLLF_INT_RPURE_MASK | + XLLF_INT_RPORE_MASK | XLLF_INT_RPUE_MASK | + XLLF_INT_TPOE_MASK | XLLF_INT_TSE_MASK, + fifo->base_addr + XLLF_IER_OFFSET); + iowrite32(XLLF_INT_ALL_MASK, fifo->base_addr + XLLF_ISR_OFFSET); +} + +/* reads a single packet from the fifo as dictated by the tlast signal */ +static ssize_t axis_fifo_read(struct file *f, char __user *buf, + size_t len, loff_t *off) +{ + struct axis_fifo *fifo = (struct axis_fifo *)f->private_data; + size_t bytes_available; + unsigned int words_available; + unsigned int copied; + unsigned int copy; + unsigned int i; + int ret; + u32 tmp_buf[READ_BUF_SIZE]; + + if (fifo->read_flags & O_NONBLOCK) { + /* opened in non-blocking mode + * return if there are no packets available + */ + if (!ioread32(fifo->base_addr + XLLF_RDFO_OFFSET)) + return -EAGAIN; + } else { + /* opened in blocking mode + * wait for a packet available interrupt (or timeout) + * if nothing is currently available + */ + spin_lock_irq(&fifo->read_queue_lock); + ret = wait_event_interruptible_lock_irq_timeout( + fifo->read_queue, + ioread32(fifo->base_addr + XLLF_RDFO_OFFSET), + fifo->read_queue_lock, + (read_timeout >= 0) ? msecs_to_jiffies(read_timeout) : + MAX_SCHEDULE_TIMEOUT); + spin_unlock_irq(&fifo->read_queue_lock); + + if (ret == 0) { + /* timeout occurred */ + dev_dbg(fifo->dt_device, "read timeout"); + return -EAGAIN; + } else if (ret == -ERESTARTSYS) { + /* signal received */ + return -ERESTARTSYS; + } else if (ret < 0) { + dev_err(fifo->dt_device, "wait_event_interruptible_timeout() error in read (ret=%i)\n", + ret); + return ret; + } + } + + bytes_available = ioread32(fifo->base_addr + XLLF_RLR_OFFSET); + if (!bytes_available) { + dev_err(fifo->dt_device, "received a packet of length 0 - fifo core will be reset\n"); + reset_ip_core(fifo); + return -EIO; + } + + if (bytes_available > len) { + dev_err(fifo->dt_device, "user read buffer too small (available bytes=%zu user buffer bytes=%zu) - fifo core will be reset\n", + bytes_available, len); + reset_ip_core(fifo); + return -EINVAL; + } + + if (bytes_available % sizeof(u32)) { + /* this probably can't happen unless IP + * registers were previously mishandled + */ + dev_err(fifo->dt_device, "received a packet that isn't word-aligned - fifo core will be reset\n"); + reset_ip_core(fifo); + return -EIO; + } + + words_available = bytes_available / sizeof(u32); + + /* read data into an intermediate buffer, copying the contents + * to userspace when the buffer is full + */ + copied = 0; + while (words_available > 0) { + copy = min(words_available, READ_BUF_SIZE); + + for (i = 0; i < copy; i++) { + tmp_buf[i] = ioread32(fifo->base_addr + + XLLF_RDFD_OFFSET); + } + + if (copy_to_user(buf + copied * sizeof(u32), tmp_buf, + copy * sizeof(u32))) { + reset_ip_core(fifo); + return -EFAULT; + } + + copied += copy; + words_available -= copy; + } + + return bytes_available; +} + +static ssize_t axis_fifo_write(struct file *f, const char __user *buf, + size_t len, loff_t *off) +{ + struct axis_fifo *fifo = (struct axis_fifo *)f->private_data; + unsigned int words_to_write; + unsigned int copied; + unsigned int copy; + unsigned int i; + int ret; + u32 tmp_buf[WRITE_BUF_SIZE]; + + if (len % sizeof(u32)) { + dev_err(fifo->dt_device, + "tried to send a packet that isn't word-aligned\n"); + return -EINVAL; + } + + words_to_write = len / sizeof(u32); + + if (!words_to_write) { + dev_err(fifo->dt_device, + "tried to send a packet of length 0\n"); + return -EINVAL; + } + + if (words_to_write > fifo->tx_fifo_depth) { + dev_err(fifo->dt_device, "tried to write more words [%u] than slots in the fifo buffer [%u]\n", + words_to_write, fifo->tx_fifo_depth); + return -EINVAL; + } + + if (fifo->write_flags & O_NONBLOCK) { + /* opened in non-blocking mode + * return if there is not enough room available in the fifo + */ + if (words_to_write > ioread32(fifo->base_addr + + XLLF_TDFV_OFFSET)) { + return -EAGAIN; + } + } else { + /* opened in blocking mode */ + + /* wait for an interrupt (or timeout) if there isn't + * currently enough room in the fifo + */ + spin_lock_irq(&fifo->write_queue_lock); + ret = wait_event_interruptible_lock_irq_timeout( + fifo->write_queue, + ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) + >= words_to_write, + fifo->write_queue_lock, + (write_timeout >= 0) ? msecs_to_jiffies(write_timeout) : + MAX_SCHEDULE_TIMEOUT); + spin_unlock_irq(&fifo->write_queue_lock); + + if (ret == 0) { + /* timeout occurred */ + dev_dbg(fifo->dt_device, "write timeout\n"); + return -EAGAIN; + } else if (ret == -ERESTARTSYS) { + /* signal received */ + return -ERESTARTSYS; + } else if (ret < 0) { + /* unknown error */ + dev_err(fifo->dt_device, + "wait_event_interruptible_timeout() error in write (ret=%i)\n", + ret); + return ret; + } + } + + /* write data from an intermediate buffer into the fifo IP, refilling + * the buffer with userspace data as needed + */ + copied = 0; + while (words_to_write > 0) { + copy = min(words_to_write, WRITE_BUF_SIZE); + + if (copy_from_user(tmp_buf, buf + copied * sizeof(u32), + copy * sizeof(u32))) { + reset_ip_core(fifo); + return -EFAULT; + } + + for (i = 0; i < copy; i++) + iowrite32(tmp_buf[i], fifo->base_addr + + XLLF_TDFD_OFFSET); + + copied += copy; + words_to_write -= copy; + } + + /* write packet size to fifo */ + iowrite32(copied * sizeof(u32), fifo->base_addr + XLLF_TLR_OFFSET); + + return (ssize_t)copied * sizeof(u32); +} + +static irqreturn_t axis_fifo_irq(int irq, void *dw) +{ + struct axis_fifo *fifo = (struct axis_fifo *)dw; + unsigned int pending_interrupts; + + do { + pending_interrupts = ioread32(fifo->base_addr + + XLLF_IER_OFFSET) & + ioread32(fifo->base_addr + + XLLF_ISR_OFFSET); + if (pending_interrupts & XLLF_INT_RC_MASK) { + /* packet received */ + + /* wake the reader process if it is waiting */ + wake_up(&fifo->read_queue); + + /* clear interrupt */ + iowrite32(XLLF_INT_RC_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_TC_MASK) { + /* packet sent */ + + /* wake the writer process if it is waiting */ + wake_up(&fifo->write_queue); + + iowrite32(XLLF_INT_TC_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_TFPF_MASK) { + /* transmit fifo programmable full */ + + iowrite32(XLLF_INT_TFPF_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_TFPE_MASK) { + /* transmit fifo programmable empty */ + + iowrite32(XLLF_INT_TFPE_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_RFPF_MASK) { + /* receive fifo programmable full */ + + iowrite32(XLLF_INT_RFPF_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_RFPE_MASK) { + /* receive fifo programmable empty */ + + iowrite32(XLLF_INT_RFPE_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_TRC_MASK) { + /* transmit reset complete interrupt */ + + iowrite32(XLLF_INT_TRC_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_RRC_MASK) { + /* receive reset complete interrupt */ + + iowrite32(XLLF_INT_RRC_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_RPURE_MASK) { + /* receive fifo under-read error interrupt */ + dev_err(fifo->dt_device, + "receive under-read interrupt\n"); + + iowrite32(XLLF_INT_RPURE_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_RPORE_MASK) { + /* receive over-read error interrupt */ + dev_err(fifo->dt_device, + "receive over-read interrupt\n"); + + iowrite32(XLLF_INT_RPORE_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_RPUE_MASK) { + /* receive underrun error interrupt */ + dev_err(fifo->dt_device, + "receive underrun error interrupt\n"); + + iowrite32(XLLF_INT_RPUE_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_TPOE_MASK) { + /* transmit overrun error interrupt */ + dev_err(fifo->dt_device, + "transmit overrun error interrupt\n"); + + iowrite32(XLLF_INT_TPOE_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts & XLLF_INT_TSE_MASK) { + /* transmit length mismatch error interrupt */ + dev_err(fifo->dt_device, + "transmit length mismatch error interrupt\n"); + + iowrite32(XLLF_INT_TSE_MASK & XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } else if (pending_interrupts) { + /* unknown interrupt type */ + dev_err(fifo->dt_device, + "unknown interrupt(s) 0x%x\n", + pending_interrupts); + + iowrite32(XLLF_INT_ALL_MASK, + fifo->base_addr + XLLF_ISR_OFFSET); + } + } while (pending_interrupts); + + return IRQ_HANDLED; +} + +static int axis_fifo_open(struct inode *inod, struct file *f) +{ + struct axis_fifo *fifo = (struct axis_fifo *)container_of(inod->i_cdev, + struct axis_fifo, char_device); + f->private_data = fifo; + + if (((f->f_flags & O_ACCMODE) == O_WRONLY) || + ((f->f_flags & O_ACCMODE) == O_RDWR)) { + if (fifo->has_tx_fifo) { + fifo->write_flags = f->f_flags; + } else { + dev_err(fifo->dt_device, "tried to open device for write but the transmit fifo is disabled\n"); + return -EPERM; + } + } + + if (((f->f_flags & O_ACCMODE) == O_RDONLY) || + ((f->f_flags & O_ACCMODE) == O_RDWR)) { + if (fifo->has_rx_fifo) { + fifo->read_flags = f->f_flags; + } else { + dev_err(fifo->dt_device, "tried to open device for read but the receive fifo is disabled\n"); + return -EPERM; + } + } + + return 0; +} + +static int axis_fifo_close(struct inode *inod, struct file *f) +{ + f->private_data = NULL; + + return 0; +} + +static const struct file_operations fops = { + .owner = THIS_MODULE, + .open = axis_fifo_open, + .release = axis_fifo_close, + .read = axis_fifo_read, + .write = axis_fifo_write +}; + +/* read named property from the device tree */ +static int get_dts_property(struct axis_fifo *fifo, + char *name, unsigned int *var) +{ + int rc; + + rc = of_property_read_u32(fifo->dt_device->of_node, name, var); + if (rc) { + dev_err(fifo->dt_device, "couldn't read IP dts property '%s'", + name); + return rc; + } + dev_dbg(fifo->dt_device, "dts property '%s' = %u\n", + name, *var); + + return 0; +} + +static int axis_fifo_probe(struct platform_device *pdev) +{ + struct resource *r_irq; /* interrupt resources */ + struct resource *r_mem; /* IO mem resources */ + struct device *dev = &pdev->dev; /* OS device (from device tree) */ + struct axis_fifo *fifo = NULL; + + char device_name[32]; + + int rc = 0; /* error return value */ + + /* IP properties from device tree */ + unsigned int rxd_tdata_width; + unsigned int txc_tdata_width; + unsigned int txd_tdata_width; + unsigned int tdest_width; + unsigned int tid_width; + unsigned int tuser_width; + unsigned int data_interface_type; + unsigned int has_tdest; + unsigned int has_tid; + unsigned int has_tkeep; + unsigned int has_tstrb; + unsigned int has_tuser; + unsigned int rx_fifo_depth; + unsigned int rx_programmable_empty_threshold; + unsigned int rx_programmable_full_threshold; + unsigned int axi_id_width; + unsigned int axi4_data_width; + unsigned int select_xpm; + unsigned int tx_fifo_depth; + unsigned int tx_programmable_empty_threshold; + unsigned int tx_programmable_full_threshold; + unsigned int use_rx_cut_through; + unsigned int use_rx_data; + unsigned int use_tx_control; + unsigned int use_tx_cut_through; + unsigned int use_tx_data; + + /* ---------------------------- + * init wrapper device + * ---------------------------- + */ + + /* allocate device wrapper memory */ + fifo = devm_kmalloc(dev, sizeof(*fifo), GFP_KERNEL); + if (!fifo) + return -ENOMEM; + + dev_set_drvdata(dev, fifo); + fifo->dt_device = dev; + + init_waitqueue_head(&fifo->read_queue); + init_waitqueue_head(&fifo->write_queue); + + spin_lock_init(&fifo->read_queue_lock); + spin_lock_init(&fifo->write_queue_lock); + + /* ---------------------------- + * init device memory space + * ---------------------------- + */ + + /* get iospace for the device */ + r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!r_mem) { + dev_err(fifo->dt_device, "invalid address\n"); + rc = -ENODEV; + goto err_initial; + } + + fifo->mem = r_mem; + + /* request physical memory */ + if (!request_mem_region(fifo->mem->start, resource_size(fifo->mem), + DRIVER_NAME)) { + dev_err(fifo->dt_device, + "couldn't lock memory region at 0x%pa\n", + &fifo->mem->start); + rc = -EBUSY; + goto err_initial; + } + dev_dbg(fifo->dt_device, "got memory location [0x%pa - 0x%pa]\n", + &fifo->mem->start, &fifo->mem->end); + + /* map physical memory to kernel virtual address space */ + fifo->base_addr = ioremap(fifo->mem->start, resource_size(fifo->mem)); + if (!fifo->base_addr) { + dev_err(fifo->dt_device, "couldn't map physical memory\n"); + rc = -ENOMEM; + goto err_mem; + } + dev_dbg(fifo->dt_device, "remapped memory to 0x%p\n", fifo->base_addr); + + /* create unique device name */ + snprintf(device_name, sizeof(device_name), "%s_%pa", + DRIVER_NAME, &fifo->mem->start); + + dev_dbg(fifo->dt_device, "device name [%s]\n", device_name); + + /* ---------------------------- + * init IP + * ---------------------------- + */ + + /* retrieve device tree properties */ + rc = get_dts_property(fifo, "xlnx,axi-str-rxd-tdata-width", + &rxd_tdata_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,axi-str-txc-tdata-width", + &txc_tdata_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,axi-str-txd-tdata-width", + &txd_tdata_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,axis-tdest-width", &tdest_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,axis-tid-width", &tid_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,axis-tuser-width", &tuser_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,data-interface-type", + &data_interface_type); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,has-axis-tdest", &has_tdest); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,has-axis-tid", &has_tid); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,has-axis-tkeep", &has_tkeep); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,has-axis-tstrb", &has_tstrb); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,has-axis-tuser", &has_tuser); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,rx-fifo-depth", &rx_fifo_depth); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,rx-fifo-pe-threshold", + &rx_programmable_empty_threshold); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,rx-fifo-pf-threshold", + &rx_programmable_full_threshold); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,s-axi-id-width", &axi_id_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,s-axi4-data-width", &axi4_data_width); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,select-xpm", &select_xpm); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,tx-fifo-depth", &tx_fifo_depth); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,tx-fifo-pe-threshold", + &tx_programmable_empty_threshold); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,tx-fifo-pf-threshold", + &tx_programmable_full_threshold); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,use-rx-cut-through", + &use_rx_cut_through); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,use-rx-data", &use_rx_data); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,use-tx-ctrl", &use_tx_control); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,use-tx-cut-through", + &use_tx_cut_through); + if (rc) + goto err_unmap; + rc = get_dts_property(fifo, "xlnx,use-tx-data", &use_tx_data); + if (rc) + goto err_unmap; + + /* check validity of device tree properties */ + if (rxd_tdata_width != 32) { + dev_err(fifo->dt_device, + "rxd_tdata_width width [%u] unsupported\n", + rxd_tdata_width); + rc = -EIO; + goto err_unmap; + } + if (txd_tdata_width != 32) { + dev_err(fifo->dt_device, + "txd_tdata_width width [%u] unsupported\n", + txd_tdata_width); + rc = -EIO; + goto err_unmap; + } + if (has_tdest) { + dev_err(fifo->dt_device, "tdest not supported\n"); + rc = -EIO; + goto err_unmap; + } + if (has_tid) { + dev_err(fifo->dt_device, "tid not supported\n"); + rc = -EIO; + goto err_unmap; + } + if (has_tkeep) { + dev_err(fifo->dt_device, "tkeep not supported\n"); + rc = -EIO; + goto err_unmap; + } + if (has_tstrb) { + dev_err(fifo->dt_device, "tstrb not supported\n"); + rc = -EIO; + goto err_unmap; + } + if (has_tuser) { + dev_err(fifo->dt_device, "tuser not supported\n"); + rc = -EIO; + goto err_unmap; + } + if (use_rx_cut_through) { + dev_err(fifo->dt_device, "rx cut-through not supported\n"); + rc = -EIO; + goto err_unmap; + } + if (use_tx_cut_through) { + dev_err(fifo->dt_device, "tx cut-through not supported\n"); + rc = -EIO; + goto err_unmap; + } + if (use_tx_control) { + dev_err(fifo->dt_device, "tx control not supported\n"); + rc = -EIO; + goto err_unmap; + } + + /* TODO + * these exist in the device tree but it's unclear what they do + * - select-xpm + * - data-interface-type + */ + + /* set device wrapper properties based on IP config */ + fifo->rx_fifo_depth = rx_fifo_depth; + /* IP sets TDFV to fifo depth - 4 so we will do the same */ + fifo->tx_fifo_depth = tx_fifo_depth - 4; + fifo->has_rx_fifo = use_rx_data; + fifo->has_tx_fifo = use_tx_data; + + reset_ip_core(fifo); + + /* ---------------------------- + * init device interrupts + * ---------------------------- + */ + + /* get IRQ resource */ + r_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (!r_irq) { + dev_err(fifo->dt_device, "no IRQ found for 0x%pa\n", + &fifo->mem->start); + rc = -EIO; + goto err_unmap; + } + + /* request IRQ */ + fifo->irq = r_irq->start; + rc = request_irq(fifo->irq, &axis_fifo_irq, 0, DRIVER_NAME, fifo); + if (rc) { + dev_err(fifo->dt_device, "couldn't allocate interrupt %i\n", + fifo->irq); + goto err_unmap; + } + + /* ---------------------------- + * init char device + * ---------------------------- + */ + + /* allocate device number */ + rc = alloc_chrdev_region(&fifo->devt, 0, 1, DRIVER_NAME); + if (rc < 0) + goto err_irq; + dev_dbg(fifo->dt_device, "allocated device number major %i minor %i\n", + MAJOR(fifo->devt), MINOR(fifo->devt)); + + /* create driver file */ + fifo->device = device_create(axis_fifo_driver_class, NULL, fifo->devt, + NULL, device_name); + if (!fifo->device) { + dev_err(fifo->dt_device, + "couldn't create driver file\n"); + rc = -ENOMEM; + goto err_chrdev_region; + } + dev_set_drvdata(fifo->device, fifo); + + /* create character device */ + cdev_init(&fifo->char_device, &fops); + rc = cdev_add(&fifo->char_device, fifo->devt, 1); + if (rc < 0) { + dev_err(fifo->dt_device, "couldn't create character device\n"); + goto err_dev; + } + + /* create sysfs entries */ + rc = sysfs_create_group(&fifo->device->kobj, &axis_fifo_attrs_group); + if (rc < 0) { + dev_err(fifo->dt_device, "couldn't register sysfs group\n"); + goto err_cdev; + } + + dev_info(fifo->dt_device, "axis-fifo created at %pa mapped to 0x%pa, irq=%i, major=%i, minor=%i\n", + &fifo->mem->start, &fifo->base_addr, fifo->irq, + MAJOR(fifo->devt), MINOR(fifo->devt)); + + return 0; + +err_cdev: + cdev_del(&fifo->char_device); +err_dev: + device_destroy(axis_fifo_driver_class, fifo->devt); +err_chrdev_region: + unregister_chrdev_region(fifo->devt, 1); +err_irq: + free_irq(fifo->irq, fifo); +err_unmap: + iounmap(fifo->base_addr); +err_mem: + release_mem_region(fifo->mem->start, resource_size(fifo->mem)); +err_initial: + dev_set_drvdata(dev, NULL); + return rc; +} + +static int axis_fifo_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct axis_fifo *fifo = dev_get_drvdata(dev); + + sysfs_remove_group(&fifo->device->kobj, &axis_fifo_attrs_group); + cdev_del(&fifo->char_device); + dev_set_drvdata(fifo->device, NULL); + device_destroy(axis_fifo_driver_class, fifo->devt); + unregister_chrdev_region(fifo->devt, 1); + free_irq(fifo->irq, fifo); + iounmap(fifo->base_addr); + release_mem_region(fifo->mem->start, resource_size(fifo->mem)); + dev_set_drvdata(dev, NULL); + return 0; +} + +static const struct of_device_id axis_fifo_of_match[] = { + { .compatible = "xlnx,axi-fifo-mm-s-4.1", }, + {}, +}; +MODULE_DEVICE_TABLE(of, axis_fifo_of_match); + +static struct platform_driver axis_fifo_driver = { + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + .of_match_table = axis_fifo_of_match, + }, + .probe = axis_fifo_probe, + .remove = axis_fifo_remove, +}; + +static int __init axis_fifo_init(void) +{ + pr_info("axis-fifo driver loaded with parameters read_timeout = %i, write_timeout = %i\n", + read_timeout, write_timeout); + axis_fifo_driver_class = class_create(THIS_MODULE, DRIVER_NAME); + return platform_driver_register(&axis_fifo_driver); +} + +module_init(axis_fifo_init); + +static void __exit axis_fifo_exit(void) +{ + platform_driver_unregister(&axis_fifo_driver); + class_destroy(axis_fifo_driver_class); +} + +module_exit(axis_fifo_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Jacob Feder "); +MODULE_DESCRIPTION("Xilinx AXI-Stream FIFO v4.1 IP core driver"); diff --git a/drivers/staging/axis-fifo/axis-fifo.txt b/drivers/staging/axis-fifo/axis-fifo.txt new file mode 100644 index 000000000000..85d88c010e72 --- /dev/null +++ b/drivers/staging/axis-fifo/axis-fifo.txt @@ -0,0 +1,89 @@ +Xilinx AXI-Stream FIFO v4.1 IP core + +This IP core has read and write AXI-Stream FIFOs, the contents of which can +be accessed from the AXI4 memory-mapped interface. This is useful for +transferring data from a processor into the FPGA fabric. The driver creates +a character device that can be read/written to with standard +open/read/write/close. + +See Xilinx PG080 document for IP details. + +Currently supports only store-forward mode with a 32-bit +AXI4-Lite interface. DOES NOT support: + - cut-through mode + - AXI4 (non-lite) + +Required properties: +- compatible: Should be "xlnx,axi-fifo-mm-s-4.1" +- interrupt-names: Should be "interrupt" +- interrupt-parent: Should be <&intc> +- interrupts: Should contain interrupts lines. +- reg: Should contain registers location and length. +- xlnx,axi-str-rxd-protocol: Should be "XIL_AXI_STREAM_ETH_DATA" +- xlnx,axi-str-rxd-tdata-width: Should be <0x20> +- xlnx,axi-str-txc-protocol: Should be "XIL_AXI_STREAM_ETH_CTRL" +- xlnx,axi-str-txc-tdata-width: Should be <0x20> +- xlnx,axi-str-txd-protocol: Should be "XIL_AXI_STREAM_ETH_DATA" +- xlnx,axi-str-txd-tdata-width: Should be <0x20> +- xlnx,axis-tdest-width: AXI-Stream TDEST width +- xlnx,axis-tid-width: AXI-Stream TID width +- xlnx,axis-tuser-width: AXI-Stream TUSER width +- xlnx,data-interface-type: Should be <0x0> +- xlnx,has-axis-tdest: Should be <0x0> (this feature isn't supported) +- xlnx,has-axis-tid: Should be <0x0> (this feature isn't supported) +- xlnx,has-axis-tkeep: Should be <0x0> (this feature isn't supported) +- xlnx,has-axis-tstrb: Should be <0x0> (this feature isn't supported) +- xlnx,has-axis-tuser: Should be <0x0> (this feature isn't supported) +- xlnx,rx-fifo-depth: Depth of RX FIFO in words +- xlnx,rx-fifo-pe-threshold: RX programmable empty interrupt threshold +- xlnx,rx-fifo-pf-threshold: RX programmable full interrupt threshold +- xlnx,s-axi-id-width: Should be <0x4> +- xlnx,s-axi4-data-width: Should be <0x20> +- xlnx,select-xpm: Should be <0x0> +- xlnx,tx-fifo-depth: Depth of TX FIFO in words +- xlnx,tx-fifo-pe-threshold: TX programmable empty interrupt threshold +- xlnx,tx-fifo-pf-threshold: TX programmable full interrupt threshold +- xlnx,use-rx-cut-through: Should be <0x0> (this feature isn't supported) +- xlnx,use-rx-data: <0x1> if RX FIFO is enabled, <0x0> otherwise +- xlnx,use-tx-ctrl: Should be <0x0> (this feature isn't supported) +- xlnx,use-tx-cut-through: Should be <0x0> (this feature isn't supported) +- xlnx,use-tx-data: <0x1> if TX FIFO is enabled, <0x0> otherwise + +Example: + +axi_fifo_mm_s_0: axi_fifo_mm_s@43c00000 { + compatible = "xlnx,axi-fifo-mm-s-4.1"; + interrupt-names = "interrupt"; + interrupt-parent = <&intc>; + interrupts = <0 29 4>; + reg = <0x43c00000 0x10000>; + xlnx,axi-str-rxd-protocol = "XIL_AXI_STREAM_ETH_DATA"; + xlnx,axi-str-rxd-tdata-width = <0x20>; + xlnx,axi-str-txc-protocol = "XIL_AXI_STREAM_ETH_CTRL"; + xlnx,axi-str-txc-tdata-width = <0x20>; + xlnx,axi-str-txd-protocol = "XIL_AXI_STREAM_ETH_DATA"; + xlnx,axi-str-txd-tdata-width = <0x20>; + xlnx,axis-tdest-width = <0x4>; + xlnx,axis-tid-width = <0x4>; + xlnx,axis-tuser-width = <0x4>; + xlnx,data-interface-type = <0x0>; + xlnx,has-axis-tdest = <0x0>; + xlnx,has-axis-tid = <0x0>; + xlnx,has-axis-tkeep = <0x0>; + xlnx,has-axis-tstrb = <0x0>; + xlnx,has-axis-tuser = <0x0>; + xlnx,rx-fifo-depth = <0x200>; + xlnx,rx-fifo-pe-threshold = <0x2>; + xlnx,rx-fifo-pf-threshold = <0x1fb>; + xlnx,s-axi-id-width = <0x4>; + xlnx,s-axi4-data-width = <0x20>; + xlnx,select-xpm = <0x0>; + xlnx,tx-fifo-depth = <0x8000>; + xlnx,tx-fifo-pe-threshold = <0x200>; + xlnx,tx-fifo-pf-threshold = <0x7ffb>; + xlnx,use-rx-cut-through = <0x0>; + xlnx,use-rx-data = <0x0>; + xlnx,use-tx-ctrl = <0x0>; + xlnx,use-tx-cut-through = <0x0>; + xlnx,use-tx-data = <0x1>; +}; From 5a4e33c1c53ae7d4425f7d94e60e4458a37b349e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 25 Jun 2018 11:03:07 +0300 Subject: [PATCH 580/903] iio: ad9523: Fix displayed phase Fix the displayed phase for the ad9523 driver. Currently the most significant decimal place is dropped and all other digits are shifted one to the left. This is due to a multiplication by 10, which is not necessary, so remove it. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Fixes: cd1678f9632 ("iio: frequency: New driver for AD9523 SPI Low Jitter Clock Generator") Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/ad9523.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 48ea46a1bc38..37504739c277 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -653,7 +653,7 @@ static int ad9523_read_raw(struct iio_dev *indio_dev, code = (AD9523_CLK_DIST_DIV_PHASE_REV(ret) * 3141592) / AD9523_CLK_DIST_DIV_REV(ret); *val = code / 1000000; - *val2 = (code % 1000000) * 10; + *val2 = code % 1000000; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; From c5b974bee9d2ceae4c441ae5a01e498c2674e100 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Sat, 7 Jul 2018 12:44:01 -0500 Subject: [PATCH 581/903] iio: sca3000: Fix missing return in switch The IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY case is missing a return and will fall through to the default case and errorenously return -EINVAL. Fix this by adding in missing *return ret*. Fixes: 626f971b5b07 ("staging:iio:accel:sca3000 Add write support to the low pass filter control") Reported-by: Jonathan Cameron Signed-off-by: Gustavo A. R. Silva Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/accel/sca3000.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c index 4dceb75e3586..4964561595f5 100644 --- a/drivers/iio/accel/sca3000.c +++ b/drivers/iio/accel/sca3000.c @@ -797,6 +797,7 @@ static int sca3000_write_raw(struct iio_dev *indio_dev, mutex_lock(&st->lock); ret = sca3000_write_3db_freq(st, val); mutex_unlock(&st->lock); + return ret; default: return -EINVAL; } From 6cefe675f12f1b53f963f6b867d40aa4237a35d9 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:28 -0700 Subject: [PATCH 582/903] staging: gasket: save struct device for a gasket device Save the struct device pointer to a gasket device in gasket's metadata, to facilitate use of standard logging calls and in anticipation of non-PCI gasket devices in the future. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 5 +++-- drivers/staging/gasket/gasket_core.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 732218773c3c..e8f3b021c20d 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -450,6 +450,7 @@ static int gasket_alloc_dev( gasket_dev->internal_desc = internal_desc; gasket_dev->dev_idx = dev_idx; snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", kobj_name); + gasket_dev->dev = parent; /* gasket_bar_data is uninitialized. */ gasket_dev->num_page_tables = driver_desc->num_page_tables; /* max_page_table_size and *page table are uninit'ed */ @@ -925,7 +926,7 @@ static int gasket_enable_dev( &gasket_dev->bar_data[ driver_desc->page_table_bar_index], &driver_desc->page_table_configs[tbl_idx], - &gasket_dev->pci_dev->dev, gasket_dev->pci_dev, true); + gasket_dev->dev, gasket_dev->pci_dev, true); if (ret) { gasket_log_error( gasket_dev, @@ -2028,7 +2029,7 @@ const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev) */ struct device *gasket_get_device(struct gasket_dev *dev) { - return &dev->pci_dev->dev; + return dev->dev; } /** diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index bf4ed3769efb..8bd431ad3b58 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -263,6 +263,9 @@ struct gasket_dev { /* Pointer to the internal driver description for this device. */ struct gasket_internal_desc *internal_desc; + /* Device info */ + struct device *dev; + /* PCI subsystem metadata. */ struct pci_dev *pci_dev; From 803ff424e46260d058daa998cc474639ca017f38 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:29 -0700 Subject: [PATCH 583/903] staging: gasket: core: convert to standard logging Use standard logging functions, drop use of gasket log functions. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 295 ++++++++++++--------------- 1 file changed, 134 insertions(+), 161 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index e8f3b021c20d..f44805c38159 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -10,15 +10,16 @@ #include "gasket_interrupt.h" #include "gasket_ioctl.h" -#include "gasket_logging.h" #include "gasket_page_table.h" #include "gasket_sysfs.h" #include #include +#include #include #include #include +#include #ifdef GASKET_KERNEL_TRACE_SUPPORT #define CREATE_TRACE_POINTS @@ -205,8 +206,8 @@ static inline int check_and_invoke_callback( { int ret = 0; - gasket_log_debug(gasket_dev, "check_and_invoke_callback %p", - cb_function); + dev_dbg(gasket_dev->dev, "check_and_invoke_callback %p\n", + cb_function); if (cb_function) { mutex_lock(&gasket_dev->mutex); ret = cb_function(gasket_dev); @@ -228,8 +229,8 @@ static inline int gasket_check_and_invoke_callback_nolock( int ret = 0; if (cb_function) { - gasket_log_debug( - gasket_dev, "Invoking device-specific callback."); + dev_dbg(gasket_dev->dev, + "Invoking device-specific callback.\n"); ret = cb_function(gasket_dev); } return ret; @@ -250,7 +251,7 @@ static int __init gasket_init(void) { int i; - gasket_nodev_info("Performing one-time init of the Gasket framework."); + pr_info("Performing one-time init of the Gasket framework.\n"); /* Check for duplicates and find a free slot. */ mutex_lock(&g_mutex); for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { @@ -267,7 +268,7 @@ static int __init gasket_init(void) static void __exit gasket_exit(void) { /* No deinit/dealloc needed at present. */ - gasket_nodev_info("Removing Gasket framework module."); + pr_info("Removing Gasket framework module.\n"); } /* See gasket_core.h for description. */ @@ -277,15 +278,14 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) int desc_idx = -1; struct gasket_internal_desc *internal; - gasket_nodev_info("Initializing Gasket framework device"); + pr_info("Initializing Gasket framework device\n"); /* Check for duplicates and find a free slot. */ mutex_lock(&g_mutex); for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { if (g_descs[i].driver_desc == driver_desc) { - gasket_nodev_error( - "%s driver already loaded/registered", - driver_desc->name); + pr_err("%s driver already loaded/registered\n", + driver_desc->name); mutex_unlock(&g_mutex); return -EBUSY; } @@ -301,17 +301,17 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) } mutex_unlock(&g_mutex); - gasket_nodev_info("Loaded %s driver, framework version %s", - driver_desc->name, GASKET_FRAMEWORK_VERSION); + pr_info("Loaded %s driver, framework version %s\n", + driver_desc->name, GASKET_FRAMEWORK_VERSION); if (desc_idx == -1) { - gasket_nodev_error("Too many Gasket drivers loaded: %d\n", - GASKET_FRAMEWORK_DESC_MAX); + pr_err("Too many Gasket drivers loaded: %d\n", + GASKET_FRAMEWORK_DESC_MAX); return -EBUSY; } /* Internal structure setup. */ - gasket_nodev_info("Performing initial internal structure setup."); + pr_debug("Performing initial internal structure setup.\n"); internal = &g_descs[desc_idx]; mutex_init(&internal->mutex); memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX); @@ -324,8 +324,8 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) class_create(driver_desc->module, driver_desc->name); if (IS_ERR(internal->class)) { - gasket_nodev_error("Cannot register %s class [ret=%ld]", - driver_desc->name, PTR_ERR(internal->class)); + pr_err("Cannot register %s class [ret=%ld]\n", + driver_desc->name, PTR_ERR(internal->class)); ret = PTR_ERR(internal->class); goto unregister_gasket_driver; } @@ -334,25 +334,24 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) * Not using pci_register_driver() (without underscores), as it * depends on KBUILD_MODNAME, and this is a shared file. */ - gasket_nodev_info("Registering PCI driver."); + pr_debug("Registering PCI driver.\n"); ret = __pci_register_driver( &internal->pci, driver_desc->module, driver_desc->name); if (ret) { - gasket_nodev_error( - "cannot register pci driver [ret=%d]", ret); + pr_err("cannot register pci driver [ret=%d]\n", ret); goto fail1; } - gasket_nodev_info("Registering char driver."); + pr_debug("Registering char driver.\n"); ret = register_chrdev_region( MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, driver_desc->name); if (ret) { - gasket_nodev_error("cannot register char driver [ret=%d]", ret); + pr_err("cannot register char driver [ret=%d]\n", ret); goto fail2; } - gasket_nodev_info("Driver registered successfully."); + pr_info("Driver registered successfully.\n"); return 0; fail2: @@ -386,10 +385,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) mutex_unlock(&g_mutex); if (!internal_desc) { - gasket_nodev_error( - "request to unregister unknown desc: %s, %d:%d", - driver_desc->name, driver_desc->major, - driver_desc->minor); + pr_err("request to unregister unknown desc: %s, %d:%d\n", + driver_desc->name, driver_desc->major, + driver_desc->minor); return; } @@ -405,7 +403,7 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) g_descs[desc_idx].driver_desc = NULL; mutex_unlock(&g_mutex); - gasket_nodev_info("removed %s driver", driver_desc->name); + pr_info("removed %s driver\n", driver_desc->name); } EXPORT_SYMBOL(gasket_unregister_device); @@ -430,7 +428,7 @@ static int gasket_alloc_dev( struct gasket_dev *gasket_dev; struct gasket_cdev_info *dev_info; - gasket_nodev_info("Allocating a Gasket device %s.", kobj_name); + pr_debug("Allocating a Gasket device %s.\n", kobj_name); *pdev = NULL; @@ -440,7 +438,7 @@ static int gasket_alloc_dev( gasket_dev = *pdev = kzalloc(sizeof(*gasket_dev), GFP_KERNEL); if (!gasket_dev) { - gasket_nodev_error("no memory for device"); + pr_err("no memory for device\n"); return -ENOMEM; } internal_desc->devs[dev_idx] = gasket_dev; @@ -466,7 +464,7 @@ static int gasket_alloc_dev( dev_info->device = device_create(internal_desc->class, parent, dev_info->devt, gasket_dev, dev_info->name); - gasket_nodev_info("Gasket device allocated: %p.", dev_info->device); + dev_dbg(dev_info->device, "Gasket device allocated.\n"); /* cdev has not yet been added; cdev_added is 0 */ dev_info->gasket_dev_ptr = gasket_dev; @@ -509,7 +507,7 @@ static int gasket_find_dev_slot( for (i = 0; i < GASKET_DEV_MAX; i++) { if (internal_desc->devs[i] && strcmp(internal_desc->devs[i]->kobj_name, kobj_name) == 0) { - gasket_nodev_error("Duplicate device %s", kobj_name); + pr_err("Duplicate device %s\n", kobj_name); mutex_unlock(&internal_desc->mutex); return -EBUSY; } @@ -522,8 +520,7 @@ static int gasket_find_dev_slot( } if (i == GASKET_DEV_MAX) { - gasket_nodev_info( - "Too many registered devices; max %d", GASKET_DEV_MAX); + pr_err("Too many registered devices; max %d\n", GASKET_DEV_MAX); mutex_unlock(&internal_desc->mutex); return -EBUSY; } @@ -552,13 +549,13 @@ static int gasket_pci_probe( const struct gasket_driver_desc *driver_desc; struct device *parent; - gasket_nodev_info("Add Gasket device %s", kobj_name); + pr_info("Add Gasket device %s\n", kobj_name); mutex_lock(&g_mutex); internal_desc = lookup_internal_desc(pci_dev); mutex_unlock(&g_mutex); if (!internal_desc) { - gasket_nodev_info("PCI probe called for unknown driver type"); + pr_err("PCI probe called for unknown driver type\n"); return -ENODEV; } @@ -569,9 +566,9 @@ static int gasket_pci_probe( if (ret) return ret; if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) { - gasket_nodev_error("Cannot create %s device %s [ret = %ld]", - driver_desc->name, gasket_dev->dev_info.name, - PTR_ERR(gasket_dev->dev_info.device)); + pr_err("Cannot create %s device %s [ret = %ld]\n", + driver_desc->name, gasket_dev->dev_info.name, + PTR_ERR(gasket_dev->dev_info.device)); ret = -ENODEV; goto fail1; } @@ -583,7 +580,7 @@ static int gasket_pci_probe( ret = check_and_invoke_callback(gasket_dev, driver_desc->add_dev_cb); if (ret) { - gasket_log_error(gasket_dev, "Error in add device cb: %d", ret); + dev_err(gasket_dev->dev, "Error in add device cb: %d\n", ret); goto fail2; } @@ -599,8 +596,8 @@ static int gasket_pci_probe( ret = sysfs_create_link(&gasket_dev->dev_info.device->kobj, &pci_dev->dev.kobj, dev_name(&pci_dev->dev)); if (ret) { - gasket_log_error( - gasket_dev, "Cannot create sysfs pci link: %d", ret); + dev_err(gasket_dev->dev, + "Cannot create sysfs pci link: %d\n", ret); goto fail3; } ret = gasket_sysfs_create_entries( @@ -611,14 +608,13 @@ static int gasket_pci_probe( ret = check_and_invoke_callback( gasket_dev, driver_desc->sysfs_setup_cb); if (ret) { - gasket_log_error( - gasket_dev, "Error in sysfs setup cb: %d", ret); + dev_err(gasket_dev->dev, "Error in sysfs setup cb: %d\n", ret); goto fail5; } ret = gasket_enable_dev(internal_desc, gasket_dev); if (ret) { - gasket_nodev_error("cannot setup %s device", driver_desc->name); + pr_err("cannot setup %s device\n", driver_desc->name); gasket_disable_dev(gasket_dev); goto fail5; } @@ -677,8 +673,7 @@ static void gasket_pci_remove(struct pci_dev *pci_dev) if (!gasket_dev) return; - gasket_nodev_info( - "remove %s device %s", internal_desc->driver_desc->name, + pr_info("remove %s device %s\n", internal_desc->driver_desc->name, gasket_dev->kobj_name); gasket_disable_dev(gasket_dev); @@ -711,7 +706,7 @@ static int gasket_setup_pci( gasket_dev->pci_dev = pci_dev; ret = pci_enable_device(pci_dev); if (ret) { - gasket_log_error(gasket_dev, "cannot enable PCI device"); + dev_err(gasket_dev->dev, "cannot enable PCI device\n"); return ret; } @@ -777,17 +772,16 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) gasket_dev->bar_data[bar_num].phys_base = (ulong)pci_resource_start(gasket_dev->pci_dev, bar_num); if (!gasket_dev->bar_data[bar_num].phys_base) { - gasket_log_error(gasket_dev, "Cannot get BAR%u base address", - bar_num); + dev_err(gasket_dev->dev, "Cannot get BAR%u base address\n", + bar_num); return -EINVAL; } gasket_dev->bar_data[bar_num].length_bytes = (ulong)pci_resource_len(gasket_dev->pci_dev, bar_num); if (gasket_dev->bar_data[bar_num].length_bytes < desc_bytes) { - gasket_log_error( - gasket_dev, - "PCI BAR %u space is too small: %lu; expected >= %lu", + dev_err(gasket_dev->dev, + "PCI BAR %u space is too small: %lu; expected >= %lu\n", bar_num, gasket_dev->bar_data[bar_num].length_bytes, desc_bytes); return -ENOMEM; @@ -796,9 +790,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) if (!request_mem_region(gasket_dev->bar_data[bar_num].phys_base, gasket_dev->bar_data[bar_num].length_bytes, gasket_dev->dev_info.name)) { - gasket_log_error( - gasket_dev, - "Cannot get BAR %d memory region %p", + dev_err(gasket_dev->dev, + "Cannot get BAR %d memory region %p\n", bar_num, &gasket_dev->pci_dev->resource[bar_num]); return -EINVAL; } @@ -807,9 +800,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) ioremap_nocache(gasket_dev->bar_data[bar_num].phys_base, gasket_dev->bar_data[bar_num].length_bytes); if (!gasket_dev->bar_data[bar_num].virt_base) { - gasket_log_error( - gasket_dev, - "Cannot remap BAR %d memory region %p", + dev_err(gasket_dev->dev, + "Cannot remap BAR %d memory region %p\n", bar_num, &gasket_dev->pci_dev->resource[bar_num]); ret = -ENOMEM; goto fail; @@ -852,8 +844,8 @@ static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num) base = pci_resource_start(dev->pci_dev, bar_num); if (!base) { - gasket_log_error( - dev, "cannot get PCI BAR%u base address", bar_num); + dev_err(dev->dev, "cannot get PCI BAR%u base address\n", + bar_num); return; } @@ -877,9 +869,8 @@ static int gasket_add_cdev( dev_info->cdev.owner = owner; ret = cdev_add(&dev_info->cdev, dev_info->devt, 1); if (ret) { - gasket_log_error( - dev_info->gasket_dev_ptr, - "cannot add char device [ret=%d]", ret); + dev_err(dev_info->gasket_dev_ptr->dev, + "cannot add char device [ret=%d]\n", ret); return ret; } dev_info->cdev_added = 1; @@ -911,16 +902,15 @@ static int gasket_enable_dev( driver_desc->interrupt_bar_index, driver_desc->wire_interrupt_offsets); if (ret) { - gasket_log_error(gasket_dev, - "Critical failure to allocate interrupts: %d", - ret); + dev_err(gasket_dev->dev, + "Critical failure to allocate interrupts: %d\n", ret); gasket_interrupt_cleanup(gasket_dev); return ret; } for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { - gasket_log_debug( - gasket_dev, "Initializing page table %d.", tbl_idx); + dev_dbg(gasket_dev->dev, "Initializing page table %d.\n", + tbl_idx); ret = gasket_page_table_init( &gasket_dev->page_table[tbl_idx], &gasket_dev->bar_data[ @@ -928,9 +918,8 @@ static int gasket_enable_dev( &driver_desc->page_table_configs[tbl_idx], gasket_dev->dev, gasket_dev->pci_dev, true); if (ret) { - gasket_log_error( - gasket_dev, - "Couldn't init page table %d: %d", + dev_err(gasket_dev->dev, + "Couldn't init page table %d: %d\n", tbl_idx, ret); return ret; } @@ -948,23 +937,23 @@ static int gasket_enable_dev( ret = check_and_invoke_callback( gasket_dev, driver_desc->hardware_revision_cb); if (ret < 0) { - gasket_log_error( - gasket_dev, "Error getting hardware revision: %d", ret); + dev_err(gasket_dev->dev, + "Error getting hardware revision: %d\n", ret); return ret; } gasket_dev->hardware_revision = ret; ret = check_and_invoke_callback(gasket_dev, driver_desc->enable_dev_cb); if (ret) { - gasket_log_error( - gasket_dev, "Error in enable device cb: %d", ret); + dev_err(gasket_dev->dev, "Error in enable device cb: %d\n", + ret); return ret; } /* device_status_cb returns a device status, not an error code. */ gasket_dev->status = gasket_get_hw_status(gasket_dev); if (gasket_dev->status == GASKET_STATUS_DEAD) - gasket_log_error(gasket_dev, "Device reported as unhealthy."); + dev_err(gasket_dev->dev, "Device reported as unhealthy.\n"); ret = gasket_add_cdev( &gasket_dev->dev_info, &gasket_file_ops, driver_desc->module); @@ -1084,31 +1073,29 @@ static int gasket_open(struct inode *inode, struct file *filp) filp->private_data = gasket_dev; inode->i_size = 0; - gasket_log_debug( - gasket_dev, + dev_dbg(gasket_dev->dev, "Attempting to open with tgid %u (%s) (f_mode: 0%03o, " - "fmode_write: %d is_root: %u)", + "fmode_write: %d is_root: %u)\n", current->tgid, task_name, filp->f_mode, (filp->f_mode & FMODE_WRITE), is_root); /* Always allow non-writing accesses. */ if (!(filp->f_mode & FMODE_WRITE)) { - gasket_log_debug(gasket_dev, "Allowing read-only opening."); + dev_dbg(gasket_dev->dev, "Allowing read-only opening.\n"); return 0; } mutex_lock(&gasket_dev->mutex); - gasket_log_debug( - gasket_dev, "Current owner open count (owning tgid %u): %d.", + dev_dbg(gasket_dev->dev, + "Current owner open count (owning tgid %u): %d.\n", ownership->owner, ownership->write_open_count); /* Opening a node owned by another TGID is an error (unless root) */ if (ownership->is_owned && ownership->owner != current->tgid && !is_root) { - gasket_log_error( - gasket_dev, - "Process %u is opening a node held by %u.", + dev_err(gasket_dev->dev, + "Process %u is opening a node held by %u.\n", current->tgid, ownership->owner); mutex_unlock(&gasket_dev->mutex); return -EPERM; @@ -1119,21 +1106,21 @@ static int gasket_open(struct inode *inode, struct file *filp) ret = gasket_check_and_invoke_callback_nolock( gasket_dev, driver_desc->device_open_cb); if (ret) { - gasket_log_error( - gasket_dev, "Error in device open cb: %d", ret); + dev_err(gasket_dev->dev, + "Error in device open cb: %d\n", ret); mutex_unlock(&gasket_dev->mutex); return ret; } ownership->is_owned = 1; ownership->owner = current->tgid; - gasket_log_debug(gasket_dev, "Device owner is now tgid %u", - ownership->owner); + dev_dbg(gasket_dev->dev, "Device owner is now tgid %u\n", + ownership->owner); } ownership->write_open_count++; - gasket_log_debug(gasket_dev, "New open count (owning tgid %u): %d", - ownership->owner, ownership->write_open_count); + dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n", + ownership->owner, ownership->write_open_count); mutex_unlock(&gasket_dev->mutex); return 0; @@ -1167,19 +1154,18 @@ static int gasket_release(struct inode *inode, struct file *file) get_task_comm(task_name, current); mutex_lock(&gasket_dev->mutex); - gasket_log_debug( - gasket_dev, + dev_dbg(gasket_dev->dev, "Releasing device node. Call origin: tgid %u (%s) " - "(f_mode: 0%03o, fmode_write: %d, is_root: %u)", + "(f_mode: 0%03o, fmode_write: %d, is_root: %u)\n", current->tgid, task_name, file->f_mode, (file->f_mode & FMODE_WRITE), capable(CAP_SYS_ADMIN)); - gasket_log_debug(gasket_dev, "Current open count (owning tgid %u): %d", - ownership->owner, ownership->write_open_count); + dev_dbg(gasket_dev->dev, "Current open count (owning tgid %u): %d\n", + ownership->owner, ownership->write_open_count); if (file->f_mode & FMODE_WRITE) { ownership->write_open_count--; if (ownership->write_open_count == 0) { - gasket_log_debug(gasket_dev, "Device is now free"); + dev_dbg(gasket_dev->dev, "Device is now free\n"); ownership->is_owned = 0; ownership->owner = 0; @@ -1200,8 +1186,7 @@ static int gasket_release(struct inode *inode, struct file *file) } } - gasket_log_debug( - gasket_dev, "New open count (owning tgid %u): %d", + dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n", ownership->owner, ownership->write_open_count); mutex_unlock(&gasket_dev->mutex); return 0; @@ -1227,7 +1212,7 @@ static bool gasket_mmap_has_permissions( /* Never allow non-sysadmins to access to a dead device. */ if (gasket_dev->status != GASKET_STATUS_ALIVE) { - gasket_log_debug(gasket_dev, "Device is dead."); + dev_dbg(gasket_dev->dev, "Device is dead.\n"); return false; } @@ -1235,10 +1220,9 @@ static bool gasket_mmap_has_permissions( requested_permissions = (vma->vm_flags & (VM_WRITE | VM_READ | VM_EXEC)); if (requested_permissions & ~(bar_permissions)) { - gasket_log_debug( - gasket_dev, + dev_dbg(gasket_dev->dev, "Attempting to map a region with requested permissions " - "0x%x, but region has permissions 0x%x.", + "0x%x, but region has permissions 0x%x.\n", requested_permissions, bar_permissions); return false; } @@ -1246,10 +1230,9 @@ static bool gasket_mmap_has_permissions( /* Do not allow a non-owner to write. */ if ((vma->vm_flags & VM_WRITE) && !gasket_owned_by_current_tgid(&gasket_dev->dev_info)) { - gasket_log_debug( - gasket_dev, + dev_dbg(gasket_dev->dev, "Attempting to mmap a region for write without owning " - "device."); + "device.\n"); return false; } @@ -1462,8 +1445,8 @@ static enum do_map_region_status do_map_region( (phys_base + mapped_bytes) >> PAGE_SHIFT, chunk_size, vma->vm_page_prot); if (ret) { - gasket_log_error( - gasket_dev, "Error remapping PFN range."); + dev_err(gasket_dev->dev, + "Error remapping PFN range.\n"); goto fail; } mapped_bytes += chunk_size; @@ -1475,9 +1458,8 @@ fail: /* Unmap the partial chunk we mapped. */ mappable_region->length_bytes = mapped_bytes; if (gasket_mm_unmap_region(gasket_dev, vma, mappable_region)) - gasket_log_error( - gasket_dev, - "Error unmapping partial region 0x%lx (0x%lx bytes)", + dev_err(gasket_dev->dev, + "Error unmapping partial region 0x%lx (0x%lx bytes)\n", (ulong)virt_offset, (ulong)mapped_bytes); @@ -1502,9 +1484,8 @@ static int gasket_mm_vma_bar_offset( driver_desc->legacy_mmap_address_offset; bar_index = gasket_get_bar_index(gasket_dev, raw_offset); if (bar_index < 0) { - gasket_log_error( - gasket_dev, - "Unable to find matching bar for address 0x%lx", + dev_err(gasket_dev->dev, + "Unable to find matching bar for address 0x%lx\n", raw_offset); trace_gasket_mmap_exit(bar_index); return bar_index; @@ -1537,7 +1518,7 @@ static int gasket_mmap_coherent( permissions = driver_desc->coherent_buffer_description.permissions; if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) { - gasket_log_error(gasket_dev, "Permission checking failed."); + dev_err(gasket_dev->dev, "Permission checking failed.\n"); trace_gasket_mmap_exit(-EPERM); return -EPERM; } @@ -1549,8 +1530,8 @@ static int gasket_mmap_coherent( (gasket_dev->coherent_buffer.phys_base) >> PAGE_SHIFT, requested_length, vma->vm_page_prot); if (ret) { - gasket_log_error( - gasket_dev, "Error remapping PFN range err=%d.", ret); + dev_err(gasket_dev->dev, "Error remapping PFN range err=%d.\n", + ret); trace_gasket_mmap_exit(ret); return ret; } @@ -1592,8 +1573,8 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) driver_desc = gasket_dev->internal_desc->driver_desc; if (vma->vm_start & ~PAGE_MASK) { - gasket_log_error( - gasket_dev, "Base address not page-aligned: 0x%lx\n", + dev_err(gasket_dev->dev, + "Base address not page-aligned: 0x%lx\n", vma->vm_start); trace_gasket_mmap_exit(-EINVAL); return -EINVAL; @@ -1613,18 +1594,16 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) bar_index = gasket_get_bar_index(gasket_dev, raw_offset); is_coherent_region = gasket_is_coherent_region(driver_desc, raw_offset); if (bar_index < 0 && !is_coherent_region) { - gasket_log_error( - gasket_dev, - "Unable to find matching bar for address 0x%lx", + dev_err(gasket_dev->dev, + "Unable to find matching bar for address 0x%lx\n", raw_offset); trace_gasket_mmap_exit(bar_index); return bar_index; } if (bar_index > 0 && is_coherent_region) { - gasket_log_error( - gasket_dev, + dev_err(gasket_dev->dev, "double matching bar and coherent buffers for address " - "0x%lx", + "0x%lx\n", raw_offset); trace_gasket_mmap_exit(bar_index); return -EINVAL; @@ -1644,7 +1623,7 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) bar_desc = &driver_desc->bar_descriptions[bar_index]; permissions = bar_desc->permissions; if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) { - gasket_log_error(gasket_dev, "Permission checking failed."); + dev_err(gasket_dev->dev, "Permission checking failed.\n"); trace_gasket_mmap_exit(-EPERM); return -EPERM; } @@ -1657,8 +1636,8 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) } else { if (!gasket_mmap_has_permissions(gasket_dev, vma, bar_desc->permissions)) { - gasket_log_error( - gasket_dev, "Permission checking failed."); + dev_err(gasket_dev->dev, + "Permission checking failed.\n"); trace_gasket_mmap_exit(-EPERM); return -EPERM; } @@ -1674,7 +1653,7 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) } if (!map_regions || num_map_regions == 0) { - gasket_log_error(gasket_dev, "No mappable regions returned!"); + dev_err(gasket_dev->dev, "No mappable regions returned!\n"); return -EINVAL; } @@ -1697,9 +1676,8 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) /* If we could not map any memory, the request was invalid. */ if (!has_mapped_anything) { - gasket_log_error( - gasket_dev, - "Map request did not contain a valid region."); + dev_err(gasket_dev->dev, + "Map request did not contain a valid region.\n"); trace_gasket_mmap_exit(-EINVAL); return -EINVAL; } @@ -1713,8 +1691,8 @@ fail: for (i = 0; i < num_map_regions; i++) if (gasket_mm_unmap_region(gasket_dev, vma, &bar_desc->mappable_regions[i])) - gasket_log_error( - gasket_dev, "Error unmapping range %d.", i); + dev_err(gasket_dev->dev, "Error unmapping range %d.\n", + i); kfree(map_regions); return ret; @@ -1738,16 +1716,15 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) status = gasket_check_and_invoke_callback_nolock( gasket_dev, driver_desc->device_status_cb); if (status != GASKET_STATUS_ALIVE) { - gasket_log_debug(gasket_dev, "Hardware reported status %d.", - status); + dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n", + status); return status; } status = gasket_interrupt_system_status(gasket_dev); if (status != GASKET_STATUS_ALIVE) { - gasket_log_debug(gasket_dev, - "Interrupt system reported status %d.", - status); + dev_dbg(gasket_dev->dev, + "Interrupt system reported status %d.\n", status); return status; } @@ -1755,8 +1732,8 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) status = gasket_page_table_system_status( gasket_dev->page_table[i]); if (status != GASKET_STATUS_ALIVE) { - gasket_log_debug( - gasket_dev, "Page table %d reported status %d.", + dev_dbg(gasket_dev->dev, + "Page table %d reported status %d.\n", i, status); return status; } @@ -1786,9 +1763,8 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) gasket_dev = (struct gasket_dev *)filp->private_data; driver_desc = gasket_dev->internal_desc->driver_desc; if (!driver_desc) { - gasket_log_debug( - gasket_dev, - "Unable to find device descriptor for file %s", + dev_dbg(gasket_dev->dev, + "Unable to find device descriptor for file %s\n", d_path(&filp->f_path, path, 256)); return -ENODEV; } @@ -1802,8 +1778,7 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) if (driver_desc->ioctl_handler_cb) return driver_desc->ioctl_handler_cb(filp, cmd, argp); - gasket_log_debug( - gasket_dev, "Received unknown ioctl 0x%x", cmd); + dev_dbg(gasket_dev->dev, "Received unknown ioctl 0x%x\n", cmd); return -EINVAL; } @@ -1834,8 +1809,8 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) /* Perform a device reset of the requested type. */ ret = driver_desc->device_reset_cb(gasket_dev, reset_type); if (ret) { - gasket_log_debug( - gasket_dev, "Device reset cb returned %d.", ret); + dev_dbg(gasket_dev->dev, "Device reset cb returned %d.\n", + ret); return ret; } @@ -1845,15 +1820,15 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) ret = gasket_interrupt_reinit(gasket_dev); if (ret) { - gasket_log_debug( - gasket_dev, "Unable to reinit interrupts: %d.", ret); + dev_dbg(gasket_dev->dev, "Unable to reinit interrupts: %d.\n", + ret); return ret; } /* Get current device health. */ gasket_dev->status = gasket_get_hw_status(gasket_dev); if (gasket_dev->status == GASKET_STATUS_DEAD) { - gasket_log_debug(gasket_dev, "Device reported as dead."); + dev_dbg(gasket_dev->dev, "Device reported as dead.\n"); return -EINVAL; } @@ -1909,15 +1884,13 @@ static ssize_t gasket_sysfs_data_show( gasket_dev = gasket_sysfs_get_device_data(device); if (!gasket_dev) { - gasket_nodev_error( - "No sysfs mapping found for device 0x%p", device); + dev_err(device, "No sysfs mapping found for device\n"); return 0; } gasket_attr = gasket_sysfs_get_attr(device, attr); if (!gasket_attr) { - gasket_nodev_error( - "No sysfs attr found for device 0x%p", device); + dev_err(device, "No sysfs attr found for device\n"); gasket_sysfs_put_device_data(device, gasket_dev); return 0; } @@ -2005,8 +1978,8 @@ static ssize_t gasket_sysfs_data_show( } break; default: - gasket_log_debug( - gasket_dev, "Unknown attribute: %s", attr->attr.name); + dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", + attr->attr.name); ret = 0; break; } @@ -2059,8 +2032,8 @@ int gasket_wait_with_reschedule( msleep(delay_ms); retries++; } - gasket_log_debug(gasket_dev, "%s timeout: reg %llx timeout (%llu ms)", - __func__, offset, max_retries * delay_ms); + dev_dbg(gasket_dev->dev, "%s timeout: reg %llx timeout (%llu ms)\n", + __func__, offset, max_retries * delay_ms); return -ETIMEDOUT; } EXPORT_SYMBOL(gasket_wait_with_reschedule); From 952b02a281764f41491759e529e62a59628133b5 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:30 -0700 Subject: [PATCH 584/903] staging: gasket: interrupt: convert to standard logging Convert gasket logging calls to standard functions. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 67 +++++++++++------------ 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 2b8c26d06533..3be8e24c126d 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -5,9 +5,10 @@ #include "gasket_constants.h" #include "gasket_core.h" -#include "gasket_logging.h" #include "gasket_sysfs.h" +#include #include +#include #include #ifdef GASKET_KERNEL_TRACE_SUPPORT #define CREATE_TRACE_POINTS @@ -165,8 +166,8 @@ int gasket_interrupt_init( case PCI_MSI: case PLATFORM_WIRE: default: - gasket_nodev_error( - "Cannot handle unsupported interrupt type %d.", + dev_err(gasket_dev->dev, + "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); ret = -EINVAL; }; @@ -175,8 +176,8 @@ int gasket_interrupt_init( /* Failing to setup interrupts will cause the device to report * GASKET_STATUS_LAMED. But it is not fatal. */ - gasket_log_warn( - gasket_dev, "Couldn't initialize interrupts: %d", ret); + dev_warn(gasket_dev->dev, + "Couldn't initialize interrupts: %d\n", ret); return 0; } @@ -216,7 +217,7 @@ static int gasket_interrupt_msix_init( interrupt_data); if (ret) { - gasket_nodev_error( + dev_err(&interrupt_data->pci_dev->dev, "Cannot get IRQ for interrupt %d, vector %d; " "%d\n", i, interrupt_data->msix_entries[i].vector, ret); @@ -287,9 +288,8 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) int ret; if (!gasket_dev->interrupt_data) { - gasket_log_debug( - gasket_dev, - "Attempted to reinit uninitialized interrupt data."); + dev_dbg(gasket_dev->dev, + "Attempted to reinit uninitialized interrupt data\n"); return -EINVAL; } @@ -305,8 +305,8 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) case PCI_MSI: case PLATFORM_WIRE: default: - gasket_nodev_debug( - "Cannot handle unsupported interrupt type %d.", + dev_dbg(gasket_dev->dev, + "Cannot handle unsupported interrupt type %d\n", gasket_dev->interrupt_data->type); ret = -EINVAL; }; @@ -315,7 +315,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) /* Failing to setup MSIx will cause the device * to report GASKET_STATUS_LAMED, but is not fatal. */ - gasket_log_warn(gasket_dev, "Couldn't init msix: %d", ret); + dev_warn(gasket_dev->dev, "Couldn't init msix: %d\n", ret); return 0; } @@ -327,7 +327,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) /* See gasket_interrupt.h for description. */ int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev) { - gasket_log_debug(gasket_dev, "Clearing interrupt counts."); + dev_dbg(gasket_dev->dev, "Clearing interrupt counts\n"); memset(gasket_dev->interrupt_data->interrupt_counts, 0, gasket_dev->interrupt_data->num_interrupts * sizeof(*gasket_dev->interrupt_data->interrupt_counts)); @@ -351,12 +351,11 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) gasket_dev->interrupt_data; if (!interrupt_data) { - gasket_log_debug( - gasket_dev, "Interrupt data is not initialized."); + dev_dbg(gasket_dev->dev, "Interrupt data is not initialized\n"); return; } - gasket_log_debug(gasket_dev, "Running interrupt setup."); + dev_dbg(gasket_dev->dev, "Running interrupt setup\n"); if (interrupt_data->type == PLATFORM_WIRE || interrupt_data->type == PCI_MSI) { @@ -365,8 +364,8 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) } if (interrupt_data->type != PCI_MSIX) { - gasket_nodev_debug( - "Cannot handle unsupported interrupt type %d.", + dev_dbg(gasket_dev->dev, + "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); return; } @@ -379,10 +378,9 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) * the register directly. If not, we need to deal with a read- * modify-write and shift based on the packing index. */ - gasket_log_debug( - gasket_dev, + dev_dbg(gasket_dev->dev, "Setting up interrupt index %d with index 0x%llx and " - "packing %d", + "packing %d\n", interrupt_data->interrupts[i].index, interrupt_data->interrupts[i].reg, interrupt_data->interrupts[i].packing); @@ -403,9 +401,9 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) pack_shift = 3 * interrupt_data->pack_width; break; default: - gasket_nodev_debug( + dev_dbg(gasket_dev->dev, "Found interrupt description with " - "unknown enum %d.", + "unknown enum %d\n", interrupt_data->interrupts[i].packing); return; } @@ -445,8 +443,8 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) case PCI_MSI: case PLATFORM_WIRE: default: - gasket_nodev_debug( - "Cannot handle unsupported interrupt type %d.", + dev_dbg(gasket_dev->dev, + "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); }; @@ -460,18 +458,19 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) int gasket_interrupt_system_status(struct gasket_dev *gasket_dev) { if (!gasket_dev->interrupt_data) { - gasket_nodev_debug("Interrupt data is null."); + dev_dbg(gasket_dev->dev, "Interrupt data is null\n"); return GASKET_STATUS_DEAD; } if (!gasket_dev->interrupt_data->msix_configured) { - gasket_nodev_debug("Interrupt not initialized."); + dev_dbg(gasket_dev->dev, "Interrupt not initialized\n"); return GASKET_STATUS_LAMED; } if (gasket_dev->interrupt_data->num_configured != gasket_dev->interrupt_data->num_interrupts) { - gasket_nodev_debug("Not all interrupts were configured."); + dev_dbg(gasket_dev->dev, + "Not all interrupts were configured\n"); return GASKET_STATUS_LAMED; } @@ -516,15 +515,13 @@ static ssize_t interrupt_sysfs_show( gasket_dev = gasket_sysfs_get_device_data(device); if (!gasket_dev) { - gasket_nodev_debug( - "No sysfs mapping found for device 0x%p", device); + dev_dbg(device, "No sysfs mapping found for device\n"); return 0; } gasket_attr = gasket_sysfs_get_attr(device, attr); if (!gasket_attr) { - gasket_nodev_debug( - "No sysfs attr data found for device 0x%p", device); + dev_dbg(device, "No sysfs attr data found for device\n"); gasket_sysfs_put_device_data(device, gasket_dev); return 0; } @@ -545,8 +542,8 @@ static ssize_t interrupt_sysfs_show( ret = total_written; break; default: - gasket_log_debug( - gasket_dev, "Unknown attribute: %s", attr->attr.name); + dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", + attr->attr.name); ret = 0; break; } @@ -574,7 +571,7 @@ static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id) } } if (interrupt == -1) { - gasket_nodev_error("Received unknown irq %d", irq); + pr_err("Received unknown irq %d\n", irq); return IRQ_HANDLED; } trace_gasket_interrupt_event(interrupt_data->name, interrupt); From e25bed80b618c41bcb3ec1db38f373f91aed2550 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:31 -0700 Subject: [PATCH 585/903] staging: gasket: ioctl: convert to standard logging Replace gasket logging calls with standard logging calls. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 63e139ab7ff8..78a132a60cc4 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -5,9 +5,9 @@ #include "gasket_constants.h" #include "gasket_core.h" #include "gasket_interrupt.h" -#include "gasket_logging.h" #include "gasket_page_table.h" #include +#include #include #include @@ -73,7 +73,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) } } else if (!gasket_ioctl_check_permissions(filp, cmd)) { trace_gasket_ioctl_exit(-EPERM); - gasket_log_debug(gasket_dev, "ioctl cmd=%x noperm.", cmd); + dev_dbg(gasket_dev->dev, "ioctl cmd=%x noperm\n", cmd); return -EPERM; } @@ -132,10 +132,9 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) * the arg. */ trace_gasket_ioctl_integer_data(arg); - gasket_log_debug( - gasket_dev, + dev_dbg(gasket_dev->dev, "Unknown ioctl cmd=0x%x not caught by " - "gasket_is_supported_ioctl", + "gasket_is_supported_ioctl\n", cmd); retval = -EINVAL; break; @@ -186,12 +185,9 @@ static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd) struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data; alive = (gasket_dev->status == GASKET_STATUS_ALIVE); - if (!alive) { - gasket_nodev_error( - "%s alive %d status %d.", - __func__, - alive, gasket_dev->status); - } + if (!alive) + dev_dbg(gasket_dev->dev, "%s alive %d status %d\n", + __func__, alive, gasket_dev->status); read = !!(filp->f_mode & FMODE_READ); write = !!(filp->f_mode & FMODE_WRITE); @@ -329,9 +325,8 @@ static int gasket_partition_page_table( gasket_dev->page_table[ibuf.page_table_index]); if (ibuf.size > max_page_table_size) { - gasket_log_debug( - gasket_dev, - "Partition request 0x%llx too large, max is 0x%x.", + dev_dbg(gasket_dev->dev, + "Partition request 0x%llx too large, max is 0x%x\n", ibuf.size, max_page_table_size); return -EINVAL; } From c423d3447874929fd8ec0211a54085b1f1446b45 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:32 -0700 Subject: [PATCH 586/903] staging: gasket: page table: convert to standard logging Replace gasket logging calls with standard logging calls. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 131 +++++++++------------ 1 file changed, 54 insertions(+), 77 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 55ab59303247..8ea8ea1c5174 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -33,6 +33,7 @@ */ #include "gasket_page_table.h" +#include #include #include #include @@ -43,7 +44,6 @@ #include "gasket_constants.h" #include "gasket_core.h" -#include "gasket_logging.h" /* Constants & utility macros */ /* The number of pages that can be mapped into each second-level page table. */ @@ -79,11 +79,6 @@ */ #define GASKET_EXTENDED_LVL1_SHIFT 12 -/* Page-table specific error logging. */ -#define gasket_pg_tbl_error(pg_tbl, format, arg...) \ - gasket_dev_log(err, (pg_tbl)->device, (struct pci_dev *)NULL, format, \ - ##arg) - /* Type declarations */ /* Valid states for a struct gasket_page_table_entry. */ enum pte_status { @@ -306,24 +301,23 @@ int gasket_page_table_init( * hardware register that contains the page table size. */ if (total_entries == ULONG_MAX) { - gasket_nodev_debug( - "Error reading page table size. " - "Initializing page table with size 0."); + dev_dbg(device, "Error reading page table size. " + "Initializing page table with size 0\n"); total_entries = 0; } - gasket_nodev_debug( - "Attempting to initialize page table of size 0x%lx.", + dev_dbg(device, + "Attempting to initialize page table of size 0x%lx\n", total_entries); - gasket_nodev_debug( - "Table has base reg 0x%x, extended offset reg 0x%x.", + dev_dbg(device, + "Table has base reg 0x%x, extended offset reg 0x%x\n", page_table_config->base_reg, page_table_config->extended_reg); *ppg_tbl = kzalloc(sizeof(**ppg_tbl), GFP_KERNEL); if (!*ppg_tbl) { - gasket_nodev_debug("No memory for page table."); + dev_dbg(device, "No memory for page table\n"); return -ENOMEM; } @@ -332,8 +326,8 @@ int gasket_page_table_init( if (bytes != 0) { pg_tbl->entries = vzalloc(bytes); if (!pg_tbl->entries) { - gasket_nodev_debug( - "No memory for address translation metadata."); + dev_dbg(device, + "No memory for address translation metadata\n"); kfree(pg_tbl); *ppg_tbl = NULL; return -ENOMEM; @@ -361,7 +355,7 @@ int gasket_page_table_init( pg_tbl->pci_dev = pci_dev; pg_tbl->dma_ops = has_dma_ops; - gasket_nodev_debug("Page table initialized successfully."); + dev_dbg(device, "Page table initialized successfully\n"); return 0; } @@ -398,7 +392,7 @@ int gasket_page_table_partition( for (i = start; i < pg_tbl->config.total_entries; i++) { if (pg_tbl->entries[i].status != PTE_FREE) { - gasket_pg_tbl_error(pg_tbl, "entry %d is not free", i); + dev_err(pg_tbl->device, "entry %d is not free\n", i); mutex_unlock(&pg_tbl->mutex); return -EBUSY; } @@ -443,11 +437,9 @@ int gasket_page_table_map( mutex_unlock(&pg_tbl->mutex); - gasket_nodev_debug( - "%s done: ha %llx daddr %llx num %d, " - "ret %d\n", - __func__, - (unsigned long long)host_addr, + dev_dbg(pg_tbl->device, + "%s done: ha %llx daddr %llx num %d, ret %d\n", + __func__, (unsigned long long)host_addr, (unsigned long long)dev_addr, num_pages, ret); return ret; } @@ -562,9 +554,8 @@ bool gasket_page_table_are_addrs_bad( ulong bytes) { if (host_addr & (PAGE_SIZE - 1)) { - gasket_pg_tbl_error( - pg_tbl, - "host mapping address 0x%lx must be page aligned", + dev_err(pg_tbl->device, + "host mapping address 0x%lx must be page aligned\n", host_addr); return true; } @@ -580,16 +571,14 @@ bool gasket_page_table_is_dev_addr_bad( uint num_pages = bytes / PAGE_SIZE; if (bytes & (PAGE_SIZE - 1)) { - gasket_pg_tbl_error( - pg_tbl, - "mapping size 0x%lX must be page aligned", bytes); + dev_err(pg_tbl->device, + "mapping size 0x%lX must be page aligned\n", bytes); return true; } if (num_pages == 0) { - gasket_pg_tbl_error( - pg_tbl, - "requested mapping is less than one page: %lu / %lu", + dev_err(pg_tbl->device, + "requested mapping is less than one page: %lu / %lu\n", bytes, PAGE_SIZE); return true; } @@ -644,7 +633,7 @@ int gasket_page_table_system_status(struct gasket_page_table *page_table) return GASKET_STATUS_LAMED; if (gasket_page_table_num_entries(page_table) == 0) { - gasket_nodev_debug("Page table size is 0."); + dev_dbg(page_table->device, "Page table size is 0\n"); return GASKET_STATUS_LAMED; } @@ -682,9 +671,8 @@ static int gasket_map_simple_pages( ret = gasket_alloc_simple_entries(pg_tbl, dev_addr, num_pages); if (ret) { - gasket_pg_tbl_error( - pg_tbl, - "page table slots %u (@ 0x%lx) to %u are not available", + dev_err(pg_tbl->device, + "page table slots %u (@ 0x%lx) to %u are not available\n", slot_idx, dev_addr, slot_idx + num_pages - 1); return ret; } @@ -695,7 +683,7 @@ static int gasket_map_simple_pages( if (ret) { gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages); - gasket_pg_tbl_error(pg_tbl, "gasket_perform_mapping %d.", ret); + dev_err(pg_tbl->device, "gasket_perform_mapping %d\n", ret); } return ret; } @@ -732,10 +720,9 @@ static int gasket_map_extended_pages( ret = gasket_alloc_extended_entries(pg_tbl, dev_addr, num_pages); if (ret) { dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1; - gasket_pg_tbl_error( - pg_tbl, + dev_err(pg_tbl->device, "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are " - "not available", + "not available\n", gasket_extended_lvl0_page_idx(pg_tbl, dev_addr), dev_addr, gasket_extended_lvl1_page_idx(pg_tbl, dev_addr), @@ -843,7 +830,7 @@ static int gasket_perform_mapping( for (i = 0; i < num_pages; i++) { page_addr = host_addr + i * PAGE_SIZE; offset = page_addr & (PAGE_SIZE - 1); - gasket_nodev_debug("%s i %d\n", __func__, i); + dev_dbg(pg_tbl->device, "%s i %d\n", __func__, i); if (is_coherent(pg_tbl, host_addr)) { u64 off = (u64)host_addr - @@ -857,10 +844,9 @@ static int gasket_perform_mapping( page_addr - offset, 1, 1, &page); if (ret <= 0) { - gasket_pg_tbl_error( - pg_tbl, + dev_err(pg_tbl->device, "get user pages failed for addr=0x%lx, " - "offset=0x%lx [ret=%d]", + "offset=0x%lx [ret=%d]\n", page_addr, offset, ret); return ret ? ret : -ENOMEM; } @@ -880,21 +866,17 @@ static int gasket_perform_mapping( DMA_BIDIRECTIONAL); } - gasket_nodev_debug( - "%s dev %p " - "i %d pte %p pfn %p -> mapped %llx\n", - __func__, - pg_tbl->device, i, &ptes[i], + dev_dbg(pg_tbl->device, + "%s i %d pte %p pfn %p -> mapped %llx\n", + __func__, i, &ptes[i], (void *)page_to_pfn(page), (unsigned long long)ptes[i].dma_addr); if (ptes[i].dma_addr == -1) { - gasket_nodev_debug( - "%s i %d" - " -> fail to map page %llx " + dev_dbg(pg_tbl->device, + "%s i %d -> fail to map page %llx " "[pfn %p ohys %p]\n", - __func__, - i, + __func__, i, (unsigned long long)ptes[i].dma_addr, (void *)page_to_pfn(page), (void *)page_to_phys(page)); @@ -996,9 +978,8 @@ static int gasket_alloc_extended_entries( if (pte->status == PTE_FREE) { ret = gasket_alloc_extended_subtable(pg_tbl, pte, slot); if (ret) { - gasket_pg_tbl_error( - pg_tbl, - "no memory for extended addr subtable"); + dev_err(pg_tbl->device, + "no memory for extended addr subtable\n"); return ret; } } else { @@ -1309,23 +1290,21 @@ static bool gasket_is_simple_dev_addr_bad( if (gasket_components_to_dev_address( pg_tbl, 1, page_index, page_offset) != dev_addr) { - gasket_pg_tbl_error( - pg_tbl, "address is invalid, 0x%lX", dev_addr); + dev_err(pg_tbl->device, "address is invalid, 0x%lX\n", + dev_addr); return true; } if (page_index >= pg_tbl->num_simple_entries) { - gasket_pg_tbl_error( - pg_tbl, - "starting slot at %lu is too large, max is < %u", + dev_err(pg_tbl->device, + "starting slot at %lu is too large, max is < %u\n", page_index, pg_tbl->num_simple_entries); return true; } if (page_index + num_pages > pg_tbl->num_simple_entries) { - gasket_pg_tbl_error( - pg_tbl, - "ending slot at %lu is too large, max is <= %u", + dev_err(pg_tbl->device, + "ending slot at %lu is too large, max is <= %u\n", page_index + num_pages, pg_tbl->num_simple_entries); return true; } @@ -1354,8 +1333,8 @@ static bool gasket_is_extended_dev_addr_bad( /* check if the device address is out of bound */ addr = dev_addr & ~((pg_tbl)->extended_flag); if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) { - gasket_pg_tbl_error(pg_tbl, "device address out of bound, 0x%p", - (void *)dev_addr); + dev_err(pg_tbl->device, "device address out of bound, 0x%p\n", + (void *)dev_addr); return true; } @@ -1372,23 +1351,21 @@ static bool gasket_is_extended_dev_addr_bad( if (gasket_components_to_dev_address( pg_tbl, 0, page_global_idx, page_offset) != dev_addr) { - gasket_pg_tbl_error( - pg_tbl, "address is invalid, 0x%p", (void *)dev_addr); + dev_err(pg_tbl->device, "address is invalid, 0x%p\n", + (void *)dev_addr); return true; } if (page_lvl0_idx >= pg_tbl->num_extended_entries) { - gasket_pg_tbl_error( - pg_tbl, + dev_err(pg_tbl->device, "starting level 0 slot at %lu is too large, max is < " - "%u", page_lvl0_idx, pg_tbl->num_extended_entries); + "%u\n", page_lvl0_idx, pg_tbl->num_extended_entries); return true; } if (page_lvl0_idx + num_lvl0_pages > pg_tbl->num_extended_entries) { - gasket_pg_tbl_error( - pg_tbl, - "ending level 0 slot at %lu is too large, max is <= %u", + dev_err(pg_tbl->device, + "ending level 0 slot at %lu is too large, max is <= %u\n", page_lvl0_idx + num_lvl0_pages, pg_tbl->num_extended_entries); return true; @@ -1597,8 +1574,8 @@ int gasket_set_user_virt( */ pg_tbl = gasket_dev->page_table[0]; if (!pg_tbl) { - gasket_nodev_debug( - "%s: invalid page table index", __func__); + dev_dbg(gasket_dev->dev, "%s: invalid page table index\n", + __func__); return 0; } for (j = 0; j < num_pages; j++) { From 0f647805c070c5d74b91ae1f914d7fabc485cbc8 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:33 -0700 Subject: [PATCH 587/903] staging: gasket: sysfs: convert to standard logging Drop gasket logging calls in favor of standard logging. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 73 +++++++++++++-------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index 1c5f7502e0d5..418b81797e63 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -3,7 +3,9 @@ #include "gasket_sysfs.h" #include "gasket_core.h" -#include "gasket_logging.h" + +#include +#include /* * Pair of kernel device and user-specified pointer. Used in lookups in sysfs @@ -66,7 +68,7 @@ static struct gasket_sysfs_mapping *get_mapping(struct device *device) int i; if (!device) { - gasket_nodev_error("Received NULL device!"); + pr_debug("%s: Received NULL device\n", __func__); return NULL; } @@ -80,7 +82,8 @@ static struct gasket_sysfs_mapping *get_mapping(struct device *device) mutex_unlock(&dev_mappings[i].mutex); } - gasket_nodev_info("Mapping to device %s not found.", device->kobj.name); + dev_dbg(device, "%s: Mapping to device %s not found\n", + __func__, device->kobj.name); return NULL; } @@ -103,16 +106,15 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) struct device *device; if (!mapping) { - gasket_nodev_info("Mapping should not be NULL."); + pr_debug("%s: Mapping should not be NULL\n", __func__); return; } mutex_lock(&mapping->mutex); if (refcount_read(&mapping->refcount.refcount) == 0) - gasket_nodev_error("Refcount is already 0!"); + dev_err(mapping->device, "Refcount is already 0\n"); if (kref_put(&mapping->refcount, release_entry)) { - gasket_nodev_info("Removing Gasket sysfs mapping, device %s", - mapping->device->kobj.name); + dev_dbg(mapping->device, "Removing Gasket sysfs mapping\n"); /* * We can't remove the sysfs nodes in the kref callback, since * device_remove_file() blocks until the node is free. @@ -182,16 +184,13 @@ int gasket_sysfs_create_mapping( static DEFINE_MUTEX(function_mutex); mutex_lock(&function_mutex); - - gasket_nodev_info( - "Creating sysfs entries for device pointer 0x%p.", device); + dev_dbg(device, "Creating sysfs entries for device\n"); /* Check that the device we're adding hasn't already been added. */ mapping = get_mapping(device); if (mapping) { - gasket_nodev_error( - "Attempting to re-initialize sysfs mapping for device " - "0x%p.", device); + dev_err(device, + "Attempting to re-initialize sysfs mapping for device\n"); put_mapping(mapping); mutex_unlock(&function_mutex); return -EBUSY; @@ -207,13 +206,13 @@ int gasket_sysfs_create_mapping( } if (map_idx == GASKET_SYSFS_NUM_MAPPINGS) { - gasket_nodev_error("All mappings have been exhausted!"); + dev_err(device, "All mappings have been exhausted\n"); mutex_unlock(&function_mutex); return -ENOMEM; } - gasket_nodev_info( - "Creating sysfs mapping for device %s.", device->kobj.name); + dev_dbg(device, "Creating sysfs mapping for device %s\n", + device->kobj.name); mapping = &dev_mappings[map_idx]; kref_init(&mapping->refcount); @@ -224,7 +223,7 @@ int gasket_sysfs_create_mapping( GFP_KERNEL); mapping->attribute_count = 0; if (!mapping->attributes) { - gasket_nodev_error("Unable to allocate sysfs attribute array."); + dev_dbg(device, "Unable to allocate sysfs attribute array\n"); mapping->device = NULL; mapping->gasket_dev = NULL; mutex_unlock(&mapping->mutex); @@ -247,10 +246,9 @@ int gasket_sysfs_create_entries( struct gasket_sysfs_mapping *mapping = get_mapping(device); if (!mapping) { - gasket_nodev_error( - "Creating entries for device 0x%p without first " - "initializing mapping.", - device); + dev_dbg(device, + "Creating entries for device without first " + "initializing mapping\n"); return -EINVAL; } @@ -258,9 +256,9 @@ int gasket_sysfs_create_entries( for (i = 0; strcmp(attrs[i].attr.attr.name, GASKET_ARRAY_END_MARKER); i++) { if (mapping->attribute_count == GASKET_SYSFS_MAX_NODES) { - gasket_nodev_error( + dev_err(device, "Maximum number of sysfs nodes reached for " - "device."); + "device\n"); mutex_unlock(&mapping->mutex); put_mapping(mapping); return -ENOMEM; @@ -268,7 +266,7 @@ int gasket_sysfs_create_entries( ret = device_create_file(device, &attrs[i].attr); if (ret) { - gasket_nodev_error("Unable to create device entries"); + dev_dbg(device, "Unable to create device entries\n"); mutex_unlock(&mapping->mutex); put_mapping(mapping); return ret; @@ -289,10 +287,9 @@ void gasket_sysfs_remove_mapping(struct device *device) struct gasket_sysfs_mapping *mapping = get_mapping(device); if (!mapping) { - gasket_nodev_error( + dev_err(device, "Attempted to remove non-existent sysfs mapping to " - "device 0x%p", - device); + "device\n"); return; } @@ -304,7 +301,7 @@ struct gasket_dev *gasket_sysfs_get_device_data(struct device *device) struct gasket_sysfs_mapping *mapping = get_mapping(device); if (!mapping) { - gasket_nodev_error("device %p not registered.", device); + dev_err(device, "device not registered\n"); return NULL; } @@ -342,8 +339,8 @@ struct gasket_sysfs_attribute *gasket_sysfs_get_attr( return &attrs[i]; } - gasket_nodev_error("Unable to find match for device_attribute %s", - attr->attr.name); + dev_err(device, "Unable to find match for device_attribute %s\n", + attr->attr.name); return NULL; } EXPORT_SYMBOL(gasket_sysfs_get_attr); @@ -368,8 +365,8 @@ void gasket_sysfs_put_attr( } } - gasket_nodev_error( - "Unable to put unknown attribute: %s", attr->attr.attr.name); + dev_err(device, "Unable to put unknown attribute: %s\n", + attr->attr.attr.name); } EXPORT_SYMBOL(gasket_sysfs_put_attr); @@ -383,26 +380,26 @@ ssize_t gasket_sysfs_register_store( struct gasket_sysfs_attribute *gasket_attr; if (count < 3 || buf[0] != '0' || buf[1] != 'x') { - gasket_nodev_error( - "sysfs register write format: \"0x\"."); + dev_err(device, + "sysfs register write format: \"0x\"\n"); return -EINVAL; } if (kstrtoul(buf, 16, &parsed_value) != 0) { - gasket_nodev_error( - "Unable to parse input as 64-bit hex value: %s.", buf); + dev_err(device, + "Unable to parse input as 64-bit hex value: %s\n", buf); return -EINVAL; } mapping = get_mapping(device); if (!mapping) { - gasket_nodev_info("Device driver may have been removed."); + dev_err(device, "Device driver may have been removed\n"); return 0; } gasket_dev = mapping->gasket_dev; if (!gasket_dev) { - gasket_nodev_info("Device driver may have been removed."); + dev_err(device, "Device driver may have been removed\n"); return 0; } From 3ed768ea90ec270d26d9da81bcc6798cddb87343 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:34 -0700 Subject: [PATCH 588/903] staging: gasket: apex: convert to standard logging Drop gasket logging calls in favor of standard logging. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 61 ++++++++++++---------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 6396b18b246a..73fc2683a834 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -7,11 +7,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include @@ -19,7 +21,6 @@ #include "gasket_core.h" #include "gasket_interrupt.h" -#include "gasket_logging.h" #include "gasket_page_table.h" #include "gasket_sysfs.h" @@ -362,11 +363,9 @@ static int apex_add_dev_cb(struct gasket_dev *gasket_dev) if (retries == APEX_RESET_RETRY) { if (!page_table_ready) - gasket_log_error( - gasket_dev, "Page table init timed out."); + dev_err(gasket_dev->dev, "Page table init timed out\n"); if (!msix_table_ready) - gasket_log_error( - gasket_dev, "MSI-X table init timed out."); + dev_err(gasket_dev->dev, "MSI-X table init timed out\n"); return -ETIMEDOUT; } @@ -420,12 +419,9 @@ static int apex_device_cleanup(struct gasket_dev *gasket_dev) gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS); - gasket_log_debug( - gasket_dev, - "%s 0x%p hib_error 0x%llx scalar_error " - "0x%llx.", - __func__, - gasket_dev, hib_error, scalar_error); + dev_dbg(gasket_dev->dev, + "%s 0x%p hib_error 0x%llx scalar_error 0x%llx\n", + __func__, gasket_dev, hib_error, scalar_error); if (allow_power_save) ret = apex_enter_reset(gasket_dev, APEX_CHIP_REINIT_RESET); @@ -452,7 +448,7 @@ static int apex_reset(struct gasket_dev *gasket_dev, uint type) /* We are not in reset - toggle the reset bit so as to force * re-init of custom block */ - gasket_log_debug(gasket_dev, "%s: toggle reset.", __func__); + dev_dbg(gasket_dev->dev, "%s: toggle reset\n", __func__); ret = apex_enter_reset(gasket_dev, type); if (ret) @@ -489,9 +485,9 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_USER_HIB_DMA_PAUSED, 1, 1, APEX_RESET_DELAY, APEX_RESET_RETRY)) { - gasket_log_error(gasket_dev, - "DMAs did not quiesce within timeout (%d ms)", - APEX_RESET_RETRY * APEX_RESET_DELAY); + dev_err(gasket_dev->dev, + "DMAs did not quiesce within timeout (%d ms)\n", + APEX_RESET_RETRY * APEX_RESET_DELAY); return -ETIMEDOUT; } @@ -511,9 +507,8 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 1 << 6, 1 << 6, APEX_RESET_DELAY, APEX_RESET_RETRY)) { - gasket_log_error( - gasket_dev, - "RAM did not shut down within timeout (%d ms)", + dev_err(gasket_dev->dev, + "RAM did not shut down within timeout (%d ms)\n", APEX_RESET_RETRY * APEX_RESET_DELAY); return -ETIMEDOUT; } @@ -560,9 +555,8 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 1 << 6, 0, APEX_RESET_DELAY, APEX_RESET_RETRY)) { - gasket_log_error( - gasket_dev, - "RAM did not enable within timeout (%d ms)", + dev_err(gasket_dev->dev, + "RAM did not enable within timeout (%d ms)\n", APEX_RESET_RETRY * APEX_RESET_DELAY); return -ETIMEDOUT; } @@ -572,9 +566,8 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) APEX_BAR2_REG_SCU_3, SCU3_CUR_RST_GCB_BIT_MASK, 0, APEX_RESET_DELAY, APEX_RESET_RETRY)) { - gasket_log_error( - gasket_dev, - "GCB did not leave reset within timeout (%d ms)", + dev_err(gasket_dev->dev, + "GCB did not leave reset within timeout (%d ms)\n", APEX_RESET_RETRY * APEX_RESET_DELAY); return -ETIMEDOUT; } @@ -589,9 +582,8 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); val1 = gasket_dev_read_32( gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); - gasket_log_debug( - gasket_dev, "Disallow HW clock gating 0x%x -> 0x%x", - val0, val1); + dev_dbg(gasket_dev->dev, + "Disallow HW clock gating 0x%x -> 0x%x\n", val0, val1); } else { val0 = gasket_dev_read_32( gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); @@ -602,9 +594,8 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); val1 = gasket_dev_read_32( gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); - gasket_log_debug( - gasket_dev, "Allow HW clock gating 0x%x -> 0x%x", val0, - val1); + dev_dbg(gasket_dev->dev, "Allow HW clock gating 0x%x -> 0x%x\n", + val0, val1); } return 0; @@ -668,7 +659,7 @@ static long apex_clock_gating(struct gasket_dev *gasket_dev, if (copy_from_user(&ibuf, argp, sizeof(ibuf))) return -EFAULT; - gasket_log_debug(gasket_dev, "%s %llu", __func__, ibuf.enable); + dev_dbg(gasket_dev->dev, "%s %llu\n", __func__, ibuf.enable); if (ibuf.enable) { /* Quiesce AXI, gate GCB clock. */ @@ -709,13 +700,13 @@ static ssize_t sysfs_show( gasket_dev = gasket_sysfs_get_device_data(device); if (!gasket_dev) { - gasket_nodev_error("No Apex device sysfs mapping found"); + dev_err(device, "No Apex device sysfs mapping found\n"); return -ENODEV; } gasket_attr = gasket_sysfs_get_attr(device, attr); if (!gasket_attr) { - gasket_nodev_error("No Apex device sysfs attr data found"); + dev_err(device, "No Apex device sysfs attr data found\n"); gasket_sysfs_put_device_data(device, gasket_dev); return -ENODEV; } @@ -738,8 +729,8 @@ static ssize_t sysfs_show( gasket_dev->page_table[0])); break; default: - gasket_log_debug( - gasket_dev, "Unknown attribute: %s", attr->attr.name); + dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", + attr->attr.name); ret = 0; break; } From 76fe4ae0e758fd20ea732b85c1733c4fb2d1745a Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:35 -0700 Subject: [PATCH 589/903] staging: gasket: remove gasket logging header Gasket logging functions no longer used. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_logging.h | 64 ------------------------- 1 file changed, 64 deletions(-) delete mode 100644 drivers/staging/gasket/gasket_logging.h diff --git a/drivers/staging/gasket/gasket_logging.h b/drivers/staging/gasket/gasket_logging.h deleted file mode 100644 index 54bbe516b071..000000000000 --- a/drivers/staging/gasket/gasket_logging.h +++ /dev/null @@ -1,64 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Common logging utilities for the Gasket driver framework. - * - * Copyright (C) 2018 Google, Inc. - */ - -#include -#include - -#ifndef _GASKET_LOGGING_H_ -#define _GASKET_LOGGING_H_ - -/* Base macro; other logging can/should be built on top of this. */ -#define gasket_dev_log(level, device, pci_dev, format, arg...) \ - if (false) { \ - if (pci_dev) { \ - dev_##level(&(pci_dev)->dev, "%s: " format "\n", \ - __func__, ##arg); \ - } else { \ - gasket_nodev_log(level, format, ##arg); \ - } \ - } - -/* "No-device" logging macros. */ -#define gasket_nodev_log(level, format, arg...) \ - if (false) pr_##level("gasket: %s: " format "\n", __func__, ##arg) - -#define gasket_nodev_debug(format, arg...) \ - if (false) gasket_nodev_log(debug, format, ##arg) - -#define gasket_nodev_info(format, arg...) \ - if (false) gasket_nodev_log(info, format, ##arg) - -#define gasket_nodev_warn(format, arg...) \ - if (false) gasket_nodev_log(warn, format, ##arg) - -#define gasket_nodev_error(format, arg...) \ - if (false) gasket_nodev_log(err, format, ##arg) - -/* gasket_dev logging macros */ -#define gasket_log_info(gasket_dev, format, arg...) \ - if (false) gasket_dev_log(info, (gasket_dev)->dev_info.device, \ - (gasket_dev)->pci_dev, format, ##arg) - -#define gasket_log_warn(gasket_dev, format, arg...) \ - if (false) gasket_dev_log(warn, (gasket_dev)->dev_info.device, \ - (gasket_dev)->pci_dev, format, ##arg) - -#define gasket_log_error(gasket_dev, format, arg...) \ - if (false) gasket_dev_log(err, (gasket_dev)->dev_info.device, \ - (gasket_dev)->pci_dev, format, ##arg) - -#define gasket_log_debug(gasket_dev, format, arg...) \ - if (false){ \ - if ((gasket_dev)->pci_dev) { \ - dev_dbg(&((gasket_dev)->pci_dev)->dev, "%s: " format \ - "\n", __func__, ##arg); \ - } else { \ - gasket_nodev_log(debug, format, ##arg); \ - } \ - } - -#endif From e8742fc322ab699862cfe585afbce5dbc59aa4f0 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:36 -0700 Subject: [PATCH 590/903] staging: gasket: TODO: remove entry for convert to standard logging Gasket/apex drivers now use standard logging, remove TODO entry for this. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO index d3c44ca4fda2..fb71997fb561 100644 --- a/drivers/staging/gasket/TODO +++ b/drivers/staging/gasket/TODO @@ -4,7 +4,6 @@ staging directory. - Document sysfs files with Documentation/ABI/ entries. - Use misc interface instead of major number for driver version description. - Add descriptions of module_param's -- Remove gasket-specific logging functions. - apex_get_status() should actually check status. - Static functions don't need kernel doc formatting, can be simplified. - Fix multi-line alignment formatting to look like: From 330e5f2425ad6857eb2505b0ca435057c8310c9a Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 26 Jul 2018 20:07:37 -0700 Subject: [PATCH 591/903] staging: gasket: don't print device addresses as kernel pointers Print device addresses as unsigned long, not as kernel pointers. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 8ea8ea1c5174..32f1c1e10c7e 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1333,8 +1333,8 @@ static bool gasket_is_extended_dev_addr_bad( /* check if the device address is out of bound */ addr = dev_addr & ~((pg_tbl)->extended_flag); if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) { - dev_err(pg_tbl->device, "device address out of bound, 0x%p\n", - (void *)dev_addr); + dev_err(pg_tbl->device, "device address out of bounds: 0x%lx\n", + dev_addr); return true; } @@ -1351,8 +1351,8 @@ static bool gasket_is_extended_dev_addr_bad( if (gasket_components_to_dev_address( pg_tbl, 0, page_global_idx, page_offset) != dev_addr) { - dev_err(pg_tbl->device, "address is invalid, 0x%p\n", - (void *)dev_addr); + dev_err(pg_tbl->device, "address is invalid: 0x%lx\n", + dev_addr); return true; } From 4e336dff0dcc250175f0068e45fdebf526f45b91 Mon Sep 17 00:00:00 2001 From: Georgios Tsotsos Date: Thu, 26 Jul 2018 18:41:51 +0300 Subject: [PATCH 592/903] Staging: octeon-usb: Adding SPDX license identifier Adding appropriate SPDX-License-Identifier (GPL-2) that were missing from code, header and make files. Signed-off-by: Georgios Tsotsos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/Makefile | 1 + drivers/staging/octeon-usb/octeon-hcd.c | 1 + drivers/staging/octeon-usb/octeon-hcd.h | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/staging/octeon-usb/Makefile b/drivers/staging/octeon-usb/Makefile index 5588be395f2a..9873a0130ad5 100644 --- a/drivers/staging/octeon-usb/Makefile +++ b/drivers/staging/octeon-usb/Makefile @@ -1 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 obj-${CONFIG_OCTEON_USB} := octeon-hcd.o diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index cded30f145aa..cff5e790b196 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * 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 diff --git a/drivers/staging/octeon-usb/octeon-hcd.h b/drivers/staging/octeon-usb/octeon-hcd.h index 3353aefe662e..769c36cf6614 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.h +++ b/drivers/staging/octeon-usb/octeon-hcd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Octeon HCD hardware register definitions. * From ff5c37987b112d09352b16a28943c149ca90afb2 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Wed, 25 Jul 2018 09:29:47 -0500 Subject: [PATCH 593/903] staging: fsl-dpaa2/ethsw: Fix error message Error message was referencing wrong function, fix it. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 0d54564e4f38..ecdd3d84f956 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -179,7 +179,7 @@ static int ethsw_port_set_flood(struct ethsw_port_priv *port_priv, u8 flag) port_priv->idx, flag); if (err) { netdev_err(port_priv->netdev, - "dpsw_fdb_set_learning_mode err %d\n", err); + "dpsw_if_set_flooding err %d\n", err); return err; } port_priv->flood = !!flag; From 227686b65256c550865bc7630684548fe079830b Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Fri, 27 Jul 2018 09:12:59 -0500 Subject: [PATCH 594/903] staging: fsl-dpaa2/eth: Update default hash key In our documentation, we claim to use a 5-tuple key for Rx hash distribution of flows. The code however configures a key composed of all supported header fields. Update the Rx hash key to contain only the documented fields: {IP src, IP dst, IP nextproto, L4 src, L4 dst}, which was the original intention and makes most sense as a default. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 6 +++--- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index da993ed80ecf..5dd73b148f66 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -2195,10 +2195,10 @@ static int bind_dpni(struct dpaa2_eth_priv *priv) return err; } - /* have the interface implicitly distribute traffic based on supported - * header fields + /* have the interface implicitly distribute traffic based on + * the default hash key */ - err = dpaa2_eth_set_hash(net_dev, DPAA2_RXH_SUPPORTED); + err = dpaa2_eth_set_hash(net_dev, DPAA2_RXH_DEFAULT); if (err) dev_err(dev, "Failed to configure hashing\n"); diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index 905a4e6be8fa..55897386979e 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -377,11 +377,14 @@ struct dpaa2_eth_priv { u64 rx_hash_fields; }; -/* default Rx hash options, set during probing */ #define DPAA2_RXH_SUPPORTED (RXH_L2DA | RXH_VLAN | RXH_L3_PROTO \ | RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 \ | RXH_L4_B_2_3) +/* default Rx hash options, set during probing */ +#define DPAA2_RXH_DEFAULT (RXH_L3_PROTO | RXH_IP_SRC | RXH_IP_DST | \ + RXH_L4_B_0_1 | RXH_L4_B_2_3) + #define dpaa2_eth_hash_enabled(priv) \ ((priv)->dpni_attrs.num_queues > 1) From 5b91b73b8c4eacd24cb354f1eb20824b0b8cde55 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Fri, 27 Jul 2018 09:13:00 -0500 Subject: [PATCH 595/903] staging: fsl-dpaa2/eth: Remove unused driver version We never really used the driver version, so no point in keeping it around. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 -- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 1 - drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 2 -- 3 files changed, 5 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 5dd73b148f66..41dd6d88ffc6 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -55,8 +55,6 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Freescale Semiconductor, Inc"); MODULE_DESCRIPTION("Freescale DPAA2 Ethernet Driver"); -const char dpaa2_eth_drv_version[] = "0.1"; - static void *dpaa2_iova_to_virt(struct iommu_domain *domain, dma_addr_t iova_addr) { diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index 55897386979e..6cf8a4bf23a9 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -392,7 +392,6 @@ struct dpaa2_eth_priv { #define DPAA2_CLASSIFIER_DMA_SIZE 256 extern const struct ethtool_ops dpaa2_ethtool_ops; -extern const char dpaa2_eth_drv_version[]; extern int dpaa2_phc_index; static inline int dpaa2_eth_cmp_dpni_ver(struct dpaa2_eth_priv *priv, diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c index 1ae779ae8c99..8a3c3da7dd5b 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c @@ -82,8 +82,6 @@ static void dpaa2_eth_get_drvinfo(struct net_device *net_dev, struct dpaa2_eth_priv *priv = netdev_priv(net_dev); strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); - strlcpy(drvinfo->version, dpaa2_eth_drv_version, - sizeof(drvinfo->version)); snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%u.%u", priv->dpni_ver_major, priv->dpni_ver_minor); From f970bec3cf9ab59ae5ae1ad03c76a912d0f72418 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Fri, 27 Jul 2018 17:43:17 +0300 Subject: [PATCH 596/903] staging: fsl-dpaa2/eth: document nested structs as per kernel-doc Document nested structs per kernel-doc requirements by moving all comments before the actual struct. Signed-off-by: Ioana Ciornei Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpkg.h | 70 +++++------- drivers/staging/fsl-dpaa2/ethernet/dpni.h | 129 ++++++++++++---------- 2 files changed, 99 insertions(+), 100 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h index 02290a088391..8057a25b1766 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h @@ -89,45 +89,41 @@ struct dpkg_mask { /** * struct dpkg_extract - A structure for defining a single extraction * @type: Determines how the union below is interpreted: - * DPKG_EXTRACT_FROM_HDR: selects 'from_hdr'; - * DPKG_EXTRACT_FROM_DATA: selects 'from_data'; - * DPKG_EXTRACT_FROM_PARSE: selects 'from_parse' + * DPKG_EXTRACT_FROM_HDR: selects 'from_hdr'; + * DPKG_EXTRACT_FROM_DATA: selects 'from_data'; + * DPKG_EXTRACT_FROM_PARSE: selects 'from_parse' * @extract: Selects extraction method + * @extract.from_hdr: Used when 'type = DPKG_EXTRACT_FROM_HDR' + * @extract.from_data: Used when 'type = DPKG_EXTRACT_FROM_DATA' + * @extract.from_parse: Used when 'type = DPKG_EXTRACT_FROM_PARSE' + * @extract.from_hdr.prot: Any of the supported headers + * @extract.from_hdr.type: Defines the type of header extraction: + * DPKG_FROM_HDR: use size & offset below; + * DPKG_FROM_FIELD: use field, size and offset below; + * DPKG_FULL_FIELD: use field below + * @extract.from_hdr.field: One of the supported fields (NH_FLD_) + * @extract.from_hdr.size: Size in bytes + * @extract.from_hdr.offset: Byte offset + * @extract.from_hdr.hdr_index: Clear for cases not listed below; + * Used for protocols that may have more than a single + * header, 0 indicates an outer header; + * Supported protocols (possible values): + * NET_PROT_VLAN (0, HDR_INDEX_LAST); + * NET_PROT_MPLS (0, 1, HDR_INDEX_LAST); + * NET_PROT_IP(0, HDR_INDEX_LAST); + * NET_PROT_IPv4(0, HDR_INDEX_LAST); + * NET_PROT_IPv6(0, HDR_INDEX_LAST); + * @extract.from_data.size: Size in bytes + * @extract.from_data.offset: Byte offset + * @extract.from_parse.size: Size in bytes + * @extract.from_parse.offset: Byte offset * @num_of_byte_masks: Defines the number of valid entries in the array below; * This is also the number of bytes to be used as masks * @masks: Masks parameters */ struct dpkg_extract { enum dpkg_extract_type type; - /** - * union extract - Selects extraction method - * @from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR' - * @from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA' - * @from_parse - Used when 'type = DPKG_EXTRACT_FROM_PARSE' - */ union { - /** - * struct from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR' - * @prot: Any of the supported headers - * @type: Defines the type of header extraction: - * DPKG_FROM_HDR: use size & offset below; - * DPKG_FROM_FIELD: use field, size and offset below; - * DPKG_FULL_FIELD: use field below - * @field: One of the supported fields (NH_FLD_) - * - * @size: Size in bytes - * @offset: Byte offset - * @hdr_index: Clear for cases not listed below; - * Used for protocols that may have more than a single - * header, 0 indicates an outer header; - * Supported protocols (possible values): - * NET_PROT_VLAN (0, HDR_INDEX_LAST); - * NET_PROT_MPLS (0, 1, HDR_INDEX_LAST); - * NET_PROT_IP(0, HDR_INDEX_LAST); - * NET_PROT_IPv4(0, HDR_INDEX_LAST); - * NET_PROT_IPv6(0, HDR_INDEX_LAST); - */ - struct { enum net_prot prot; enum dpkg_extract_from_hdr_type type; @@ -136,22 +132,10 @@ struct dpkg_extract { u8 offset; u8 hdr_index; } from_hdr; - /** - * struct from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA' - * @size: Size in bytes - * @offset: Byte offset - */ struct { u8 size; u8 offset; } from_data; - - /** - * struct from_parse - Used when - * 'type = DPKG_EXTRACT_FROM_PARSE' - * @size: Size in bytes - * @offset: Byte offset - */ struct { u8 size; u8 offset; diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni.h b/drivers/staging/fsl-dpaa2/ethernet/dpni.h index ce86a816af45..8eef4ee90490 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpni.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpni.h @@ -117,15 +117,12 @@ int dpni_close(struct fsl_mc_io *mc_io, * @num_dpbp: Number of DPBPs * @pools: Array of buffer pools parameters; The number of valid entries * must match 'num_dpbp' value + * @pools.dpbp_id: DPBP object ID + * @pools.buffer_size: Buffer size + * @pools.backup_pool: Backup pool */ struct dpni_pools_cfg { u8 num_dpbp; - /** - * struct pools - Buffer pools parameters - * @dpbp_id: DPBP object ID - * @buffer_size: Buffer size - * @backup_pool: Backup pool - */ struct { int dpbp_id; u16 buffer_size; @@ -424,16 +421,32 @@ int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, #define DPNI_STATISTICS_CNT 7 +/** + * union dpni_statistics - Union describing the DPNI statistics + * @page_0: Page_0 statistics structure + * @page_0.ingress_all_frames: Ingress frame count + * @page_0.ingress_all_bytes: Ingress byte count + * @page_0.ingress_multicast_frames: Ingress multicast frame count + * @page_0.ingress_multicast_bytes: Ingress multicast byte count + * @page_0.ingress_broadcast_frames: Ingress broadcast frame count + * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count + * @page_1: Page_1 statistics structure + * @page_1.egress_all_frames: Egress frame count + * @page_1.egress_all_bytes: Egress byte count + * @page_1.egress_multicast_frames: Egress multicast frame count + * @page_1.egress_multicast_bytes: Egress multicast byte count + * @page_1.egress_broadcast_frames: Egress broadcast frame count + * @page_1.egress_broadcast_bytes: Egress broadcast byte count + * @page_2: Page_2 statistics structure + * @page_2.ingress_filtered_frames: Ingress filtered frame count + * @page_2.ingress_discarded_frames: Ingress discarded frame count + * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to + * lack of buffers + * @page_2.egress_discarded_frames: Egress discarded frame count + * @page_2.egress_confirmed_frames: Egress confirmed frame count + * @raw: raw statistics structure, used to index counters + */ union dpni_statistics { - /** - * struct page_0 - Page_0 statistics structure - * @ingress_all_frames: Ingress frame count - * @ingress_all_bytes: Ingress byte count - * @ingress_multicast_frames: Ingress multicast frame count - * @ingress_multicast_bytes: Ingress multicast byte count - * @ingress_broadcast_frames: Ingress broadcast frame count - * @ingress_broadcast_bytes: Ingress broadcast byte count - */ struct { u64 ingress_all_frames; u64 ingress_all_bytes; @@ -442,15 +455,6 @@ union dpni_statistics { u64 ingress_broadcast_frames; u64 ingress_broadcast_bytes; } page_0; - /** - * struct page_1 - Page_1 statistics structure - * @egress_all_frames: Egress frame count - * @egress_all_bytes: Egress byte count - * @egress_multicast_frames: Egress multicast frame count - * @egress_multicast_bytes: Egress multicast byte count - * @egress_broadcast_frames: Egress broadcast frame count - * @egress_broadcast_bytes: Egress broadcast byte count - */ struct { u64 egress_all_frames; u64 egress_all_bytes; @@ -459,15 +463,6 @@ union dpni_statistics { u64 egress_broadcast_frames; u64 egress_broadcast_bytes; } page_1; - /** - * struct page_2 - Page_2 statistics structure - * @ingress_filtered_frames: Ingress filtered frame count - * @ingress_discarded_frames: Ingress discarded frame count - * @ingress_nobuffer_discards: Ingress discarded frame count - * due to lack of buffers - * @egress_discarded_frames: Egress discarded frame count - * @egress_confirmed_frames: Egress confirmed frame count - */ struct { u64 ingress_filtered_frames; u64 ingress_discarded_frames; @@ -475,9 +470,6 @@ union dpni_statistics { u64 egress_discarded_frames; u64 egress_confirmed_frames; } page_2; - /** - * struct raw - raw statistics structure - */ struct { u64 counter[DPNI_STATISTICS_CNT]; } raw; @@ -685,29 +677,52 @@ enum dpni_dest { /** * struct dpni_queue - Queue structure - * @user_context: User data, presented to the user along with any frames from - * this queue. Not relevant for Tx queues. + * @destination - Destination structure + * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0. + * Identifies either a DPIO or a DPCON object. + * Not relevant for Tx queues. + * @destination.type: May be one of the following: + * 0 - No destination, queue can be manually + * queried, but will not push traffic or + * notifications to a DPIO; + * 1 - The destination is a DPIO. When traffic + * becomes available in the queue a FQDAN + * (FQ data available notification) will be + * generated to selected DPIO; + * 2 - The destination is a DPCON. The queue is + * associated with a DPCON object for the + * purpose of scheduling between multiple + * queues. The DPCON may be independently + * configured to generate notifications. + * Not relevant for Tx queues. + * @destination.hold_active: Hold active, maintains a queue scheduled for longer + * in a DPIO during dequeue to reduce spread of traffic. + * Only relevant if queues are + * not affined to a single DPIO. + * @user_context: User data, presented to the user along with any frames + * from this queue. Not relevant for Tx queues. + * @flc: FD FLow Context structure + * @flc.value: Default FLC value for traffic dequeued from + * this queue. Please check description of FD + * structure for more information. + * Note that FLC values set using dpni_add_fs_entry, + * if any, take precedence over values per queue. + * @flc.stash_control: Boolean, indicates whether the 6 lowest + * - significant bits are used for stash control. + * significant bits are used for stash control. If set, the 6 + * least significant bits in value are interpreted as follows: + * - bits 0-1: indicates the number of 64 byte units of context + * that are stashed. FLC value is interpreted as a memory address + * in this case, excluding the 6 LS bits. + * - bits 2-3: indicates the number of 64 byte units of frame + * annotation to be stashed. Annotation is placed at FD[ADDR]. + * - bits 4-5: indicates the number of 64 byte units of frame + * data to be stashed. Frame data is placed at FD[ADDR] + + * FD[OFFSET]. + * For more details check the Frame Descriptor section in the + * hardware documentation. */ struct dpni_queue { -/** - * struct destination - Destination structure - * @id: ID of the destination, only relevant if DEST_TYPE is > 0. - * Identifies either a DPIO or a DPCON object. Not relevant for - * Tx queues. - * @type: May be one of the following: - * 0 - No destination, queue can be manually queried, but will not - * push traffic or notifications to a DPIO; - * 1 - The destination is a DPIO. When traffic becomes available in - * the queue a FQDAN (FQ data available notification) will be - * generated to selected DPIO; - * 2 - The destination is a DPCON. The queue is associated with a - * DPCON object for the purpose of scheduling between multiple - * queues. The DPCON may be independently configured to - * generate notifications. Not relevant for Tx queues. - * @hold_active: Hold active, maintains a queue scheduled for longer - * in a DPIO during dequeue to reduce spread of traffic. - * Only relevant if queues are not affined to a single DPIO. - */ struct { u16 id; enum dpni_dest type; From a89bac0a2ca45c9a44f2a35523252d9d8082aa03 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Fri, 27 Jul 2018 17:43:18 +0300 Subject: [PATCH 597/903] staging: fsl-dpaa2/ethsw: document nested structs as per kernel-doc Document nested structs per kernel-doc requirements by moving all comments before the actual struct. Signed-off-by: Ioana Ciornei Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/dpsw.h | 27 ++++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h index 82f80c409ec3..db43fa3782b8 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h @@ -79,24 +79,21 @@ enum dpsw_component_type { * struct dpsw_cfg - DPSW configuration * @num_ifs: Number of external and internal interfaces * @adv: Advanced parameters; default is all zeros; - * use this structure to change default settings + * use this structure to change default settings + * @adv.options: Enable/Disable DPSW features (bitmap) + * @adv.max_vlans: Maximum Number of VLAN's; 0 - indicates default 16 + * @adv.max_meters_per_if: Number of meters per interface + * @adv.max_fdbs: Maximum Number of FDB's; 0 - indicates default 16 + * @adv.max_fdb_entries: Number of FDB entries for default FDB table; + * 0 - indicates default 1024 entries. + * @adv.fdb_aging_time: Default FDB aging time for default FDB table; + * 0 - indicates default 300 seconds + * @adv.max_fdb_mc_groups: Number of multicast groups in each FDB table; + * 0 - indicates default 32 + * @adv.component_type: Indicates the component type of this bridge */ struct dpsw_cfg { u16 num_ifs; - /** - * struct adv - Advanced parameters - * @options: Enable/Disable DPSW features (bitmap) - * @max_vlans: Maximum Number of VLAN's; 0 - indicates default 16 - * @max_meters_per_if: Number of meters per interface - * @max_fdbs: Maximum Number of FDB's; 0 - indicates default 16 - * @max_fdb_entries: Number of FDB entries for default FDB table; - * 0 - indicates default 1024 entries. - * @fdb_aging_time: Default FDB aging time for default FDB table; - * 0 - indicates default 300 seconds - * @max_fdb_mc_groups: Number of multicast groups in each FDB table; - * 0 - indicates default 32 - * @component_type: Indicates the component type of this bridge - */ struct { u64 options; u16 max_vlans; From aea1286dcbbb87cf33595c2ac8b153c29a4611cb Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:44 +0800 Subject: [PATCH 598/903] staging: erofs: add on-disk layout This commit adds the on-disk layout header file of erofs. Note that the on-disk layout is still WIP, and some fields are reserved for the future use by design. Any comments are welcome. Thanks-to: Li Guifu Thanks-to: Sun Qiuyang Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/erofs_fs.h | 266 +++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 drivers/staging/erofs/erofs_fs.h diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h new file mode 100644 index 000000000000..2f8e2bf70941 --- /dev/null +++ b/drivers/staging/erofs/erofs_fs.h @@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 + * + * linux/drivers/staging/erofs/erofs_fs.h + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is dual-licensed; you may select either the GNU General Public + * License version 2 or Apache License, Version 2.0. See the file COPYING + * in the main directory of the Linux distribution for more details. + */ +#ifndef __EROFS_FS_H +#define __EROFS_FS_H + +/* Enhanced(Extended) ROM File System */ +#define EROFS_SUPER_MAGIC_V1 0xE0F5E1E2 +#define EROFS_SUPER_OFFSET 1024 + +struct erofs_super_block { +/* 0 */__le32 magic; /* in the little endian */ +/* 4 */__le32 checksum; /* crc32c(super_block) */ +/* 8 */__le32 features; +/* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */ +/* 13 */__u8 reserved; + +/* 14 */__le16 root_nid; +/* 16 */__le64 inos; /* total valid ino # (== f_files - f_favail) */ + +/* 24 */__le64 build_time; /* inode v1 time derivation */ +/* 32 */__le32 build_time_nsec; +/* 36 */__le32 blocks; /* used for statfs */ +/* 40 */__le32 meta_blkaddr; +/* 44 */__le32 xattr_blkaddr; +/* 48 */__u8 uuid[16]; /* 128-bit uuid for volume */ +/* 64 */__u8 volume_name[16]; /* volume name */ + +/* 80 */__u8 reserved2[48]; /* 128 bytes */ +} __packed; + +#define __EROFS_BIT(_prefix, _cur, _pre) enum { \ + _prefix ## _cur ## _BIT = _prefix ## _pre ## _BIT + \ + _prefix ## _pre ## _BITS } + +/* + * erofs inode data mapping: + * 0 - inode plain without inline data A: + * inode, [xattrs], ... | ... | no-holed data + * 1 - inode VLE compression B: + * inode, [xattrs], extents ... | ... + * 2 - inode plain with inline data C: + * inode, [xattrs], last_inline_data, ... | ... | no-holed data + * 3~7 - reserved + */ +enum { + EROFS_INODE_LAYOUT_PLAIN, + EROFS_INODE_LAYOUT_COMPRESSION, + EROFS_INODE_LAYOUT_INLINE, + EROFS_INODE_LAYOUT_MAX +}; +#define EROFS_I_VERSION_BITS 1 +#define EROFS_I_DATA_MAPPING_BITS 3 + +#define EROFS_I_VERSION_BIT 0 +__EROFS_BIT(EROFS_I_, DATA_MAPPING, VERSION); + +struct erofs_inode_v1 { +/* 0 */__le16 i_advise; + +/* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ +/* 2 */__le16 i_xattr_icount; +/* 4 */__le16 i_mode; +/* 6 */__le16 i_nlink; +/* 8 */__le32 i_size; +/* 12 */__le32 i_reserved; +/* 16 */union { + /* file total compressed blocks for data mapping 1 */ + __le32 compressed_blocks; + __le32 raw_blkaddr; + + /* for device files, used to indicate old/new device # */ + __le32 rdev; + } i_u __packed; +/* 20 */__le32 i_ino; /* only used for 32-bit stat compatibility */ +/* 24 */__le16 i_uid; +/* 26 */__le16 i_gid; +/* 28 */__le32 i_checksum; +} __packed; + +/* 32 bytes on-disk inode */ +#define EROFS_INODE_LAYOUT_V1 0 +/* 64 bytes on-disk inode */ +#define EROFS_INODE_LAYOUT_V2 1 + +struct erofs_inode_v2 { + __le16 i_advise; + + /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ + __le16 i_xattr_icount; + __le16 i_mode; + __le16 i_reserved; /* 8 bytes */ + __le64 i_size; /* 16 bytes */ + union { + /* file total compressed blocks for data mapping 1 */ + __le32 compressed_blocks; + __le32 raw_blkaddr; + + /* for device files, used to indicate old/new device # */ + __le32 rdev; + } i_u __packed; + + /* only used for 32-bit stat compatibility */ + __le32 i_ino; /* 24 bytes */ + + __le32 i_uid; + __le32 i_gid; + __le64 i_ctime; /* 32 bytes */ + __le32 i_ctime_nsec; + __le32 i_nlink; + __u8 i_reserved2[12]; + __le32 i_checksum; /* 64 bytes */ +} __packed; + +#define EROFS_MAX_SHARED_XATTRS (128) +/* h_shared_count between 129 ... 255 are special # */ +#define EROFS_SHARED_XATTR_EXTENT (255) + +/* + * inline xattrs (n == i_xattr_icount): + * erofs_xattr_ibody_header(1) + (n - 1) * 4 bytes + * 12 bytes / \ + * / \ + * /-----------------------\ + * | erofs_xattr_entries+ | + * +-----------------------+ + * inline xattrs must starts in erofs_xattr_ibody_header, + * for read-only fs, no need to introduce h_refcount + */ +struct erofs_xattr_ibody_header { + __le32 h_checksum; + __u8 h_shared_count; + __u8 h_reserved[7]; + __le32 h_shared_xattrs[0]; /* shared xattr id array */ +} __packed; + +/* Name indexes */ +#define EROFS_XATTR_INDEX_USER 1 +#define EROFS_XATTR_INDEX_POSIX_ACL_ACCESS 2 +#define EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT 3 +#define EROFS_XATTR_INDEX_TRUSTED 4 +#define EROFS_XATTR_INDEX_LUSTRE 5 +#define EROFS_XATTR_INDEX_SECURITY 6 + +/* xattr entry (for both inline & shared xattrs) */ +struct erofs_xattr_entry { + __u8 e_name_len; /* length of name */ + __u8 e_name_index; /* attribute name index */ + __le16 e_value_size; /* size of attribute value */ + /* followed by e_name and e_value */ + char e_name[0]; /* attribute name */ +} __packed; + +#define ondisk_xattr_ibody_size(count) ({\ + u32 __count = le16_to_cpu(count); \ + ((__count) == 0) ? 0 : \ + sizeof(struct erofs_xattr_ibody_header) + \ + sizeof(__u32) * ((__count) - 1); }) + +#define EROFS_XATTR_ALIGN(size) round_up(size, sizeof(struct erofs_xattr_entry)) +#define EROFS_XATTR_ENTRY_SIZE(entry) EROFS_XATTR_ALIGN( \ + sizeof(struct erofs_xattr_entry) + \ + (entry)->e_name_len + le16_to_cpu((entry)->e_value_size)) + +/* have to be aligned with 8 bytes on disk */ +struct erofs_extent_header { + __le32 eh_checksum; + __le32 eh_reserved[3]; +} __packed; + +/* + * Z_EROFS Variable-sized Logical Extent cluster type: + * 0 - literal (uncompressed) cluster + * 1 - compressed cluster (for the head logical cluster) + * 2 - compressed cluster (for the other logical clusters) + * + * In detail, + * 0 - literal (uncompressed) cluster, + * di_advise = 0 + * di_clusterofs = the literal data offset of the cluster + * di_blkaddr = the blkaddr of the literal cluster + * + * 1 - compressed cluster (for the head logical cluster) + * di_advise = 1 + * di_clusterofs = the decompressed data offset of the cluster + * di_blkaddr = the blkaddr of the compressed cluster + * + * 2 - compressed cluster (for the other logical clusters) + * di_advise = 2 + * di_clusterofs = + * the decompressed data offset in its own head cluster + * di_u.delta[0] = distance to its corresponding head cluster + * di_u.delta[1] = distance to its corresponding tail cluster + * (di_advise could be 0, 1 or 2) + */ +#define Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS 2 +#define Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT 0 + +struct z_erofs_vle_decompressed_index { + __le16 di_advise; + /* where to decompress in the head cluster */ + __le16 di_clusterofs; + + union { + /* for the head cluster */ + __le32 blkaddr; + /* + * for the rest clusters + * eg. for 4k page-sized cluster, maximum 4K*64k = 256M) + * [0] - pointing to the head cluster + * [1] - pointing to the tail cluster + */ + __le16 delta[2]; + } di_u __packed; /* 8 bytes */ +} __packed; + +#define Z_EROFS_VLE_EXTENT_ALIGN(size) round_up(size, \ + sizeof(struct z_erofs_vle_decompressed_index)) + +/* dirent sorts in alphabet order, thus we can do binary search */ +struct erofs_dirent { + __le64 nid; /* 0, node number */ + __le16 nameoff; /* 8, start offset of file name */ + __u8 file_type; /* 10, file type */ + __u8 reserved; /* 11, reserved */ +} __packed; + +/* file types used in inode_info->flags */ +enum { + EROFS_FT_UNKNOWN, + EROFS_FT_REG_FILE, + EROFS_FT_DIR, + EROFS_FT_CHRDEV, + EROFS_FT_BLKDEV, + EROFS_FT_FIFO, + EROFS_FT_SOCK, + EROFS_FT_SYMLINK, + EROFS_FT_MAX +}; + +#define EROFS_NAME_LEN 255 + +/* check the EROFS on-disk layout strictly at compile time */ +static inline void erofs_check_ondisk_layout_definitions(void) +{ + BUILD_BUG_ON(sizeof(struct erofs_super_block) != 128); + BUILD_BUG_ON(sizeof(struct erofs_inode_v1) != 32); + BUILD_BUG_ON(sizeof(struct erofs_inode_v2) != 64); + BUILD_BUG_ON(sizeof(struct erofs_xattr_ibody_header) != 12); + BUILD_BUG_ON(sizeof(struct erofs_xattr_entry) != 4); + BUILD_BUG_ON(sizeof(struct erofs_extent_header) != 16); + BUILD_BUG_ON(sizeof(struct z_erofs_vle_decompressed_index) != 8); + BUILD_BUG_ON(sizeof(struct erofs_dirent) != 12); +} + +#endif + From bfb8674dc0447da3ab65665dd21086475abb8e4c Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:45 +0800 Subject: [PATCH 599/903] staging: erofs: add erofs in-memory stuffs - erofs_sb_info: contains erofs-specific in-memory information. - erofs_vnode: contains vfs_inode and other fs-specific information. same as super block, the only one in-memory definition exists. - erofs_map_blocks plays a role in the file L2P mapping Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 281 +++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 drivers/staging/erofs/internal.h diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h new file mode 100644 index 000000000000..d0992d2239c2 --- /dev/null +++ b/drivers/staging/erofs/internal.h @@ -0,0 +1,281 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * linux/drivers/staging/erofs/internal.h + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#ifndef __INTERNAL_H +#define __INTERNAL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "erofs_fs.h" + +/* redefine pr_fmt "erofs: " */ +#undef pr_fmt +#define pr_fmt(fmt) "erofs: " fmt + +#define errln(x, ...) pr_err(x "\n", ##__VA_ARGS__) +#define infoln(x, ...) pr_info(x "\n", ##__VA_ARGS__) +#ifdef CONFIG_EROFS_FS_DEBUG +#define debugln(x, ...) pr_debug(x "\n", ##__VA_ARGS__) + +#define dbg_might_sleep might_sleep +#define DBG_BUGON BUG_ON +#else +#define debugln(x, ...) ((void)0) + +#define dbg_might_sleep() ((void)0) +#define DBG_BUGON(...) ((void)0) +#endif + +/* EROFS_SUPER_MAGIC_V1 to represent the whole file system */ +#define EROFS_SUPER_MAGIC EROFS_SUPER_MAGIC_V1 + +typedef u64 erofs_nid_t; + +struct erofs_sb_info { + u32 blocks; + u32 meta_blkaddr; + + /* inode slot unit size in bit shift */ + unsigned char islotbits; + + u32 build_time_nsec; + u64 build_time; + + /* what we really care is nid, rather than ino.. */ + erofs_nid_t root_nid; + /* used for statfs, f_files - f_favail */ + u64 inos; + + u8 uuid[16]; /* 128-bit uuid for volume */ + u8 volume_name[16]; /* volume name */ + char *dev_name; + + unsigned int mount_opt; +}; + +#define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) +#define EROFS_I_SB(inode) ((struct erofs_sb_info *)(inode)->i_sb->s_fs_info) + +#define clear_opt(sbi, option) ((sbi)->mount_opt &= ~EROFS_MOUNT_##option) +#define set_opt(sbi, option) ((sbi)->mount_opt |= EROFS_MOUNT_##option) +#define test_opt(sbi, option) ((sbi)->mount_opt & EROFS_MOUNT_##option) + +/* we strictly follow PAGE_SIZE and no buffer head yet */ +#define LOG_BLOCK_SIZE PAGE_SHIFT + +#undef LOG_SECTORS_PER_BLOCK +#define LOG_SECTORS_PER_BLOCK (PAGE_SHIFT - 9) + +#undef SECTORS_PER_BLOCK +#define SECTORS_PER_BLOCK (1 << SECTORS_PER_BLOCK) + +#define EROFS_BLKSIZ (1 << LOG_BLOCK_SIZE) + +#if (EROFS_BLKSIZ % 4096 || !EROFS_BLKSIZ) +#error erofs cannot be used in this platform +#endif + +#define ROOT_NID(sb) ((sb)->root_nid) + +typedef u64 erofs_off_t; + +/* data type for filesystem-wide blocks number */ +typedef u32 erofs_blk_t; + +#define erofs_blknr(addr) ((addr) / EROFS_BLKSIZ) +#define erofs_blkoff(addr) ((addr) % EROFS_BLKSIZ) +#define blknr_to_addr(nr) ((erofs_off_t)(nr) * EROFS_BLKSIZ) + +static inline erofs_off_t iloc(struct erofs_sb_info *sbi, erofs_nid_t nid) +{ + return blknr_to_addr(sbi->meta_blkaddr) + (nid << sbi->islotbits); +} + +#define inode_set_inited_xattr(inode) (EROFS_V(inode)->flags |= 1) +#define inode_has_inited_xattr(inode) (EROFS_V(inode)->flags & 1) + +struct erofs_vnode { + erofs_nid_t nid; + unsigned int flags; + + unsigned char data_mapping_mode; + /* inline size in bytes */ + unsigned char inode_isize; + unsigned short xattr_isize; + + unsigned xattr_shared_count; + unsigned *xattr_shared_xattrs; + + erofs_blk_t raw_blkaddr; + + /* the corresponding vfs inode */ + struct inode vfs_inode; +}; + +#define EROFS_V(ptr) \ + container_of(ptr, struct erofs_vnode, vfs_inode) + +#define __inode_advise(x, bit, bits) \ + (((x) >> (bit)) & ((1 << (bits)) - 1)) + +#define __inode_version(advise) \ + __inode_advise(advise, EROFS_I_VERSION_BIT, \ + EROFS_I_VERSION_BITS) + +#define __inode_data_mapping(advise) \ + __inode_advise(advise, EROFS_I_DATA_MAPPING_BIT,\ + EROFS_I_DATA_MAPPING_BITS) + +static inline unsigned long inode_datablocks(struct inode *inode) +{ + /* since i_size cannot be changed */ + return DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); +} + +static inline bool is_inode_layout_plain(struct inode *inode) +{ + return EROFS_V(inode)->data_mapping_mode == EROFS_INODE_LAYOUT_PLAIN; +} + +static inline bool is_inode_layout_compression(struct inode *inode) +{ + return EROFS_V(inode)->data_mapping_mode == + EROFS_INODE_LAYOUT_COMPRESSION; +} + +static inline bool is_inode_layout_inline(struct inode *inode) +{ + return EROFS_V(inode)->data_mapping_mode == EROFS_INODE_LAYOUT_INLINE; +} + +extern const struct super_operations erofs_sops; +extern const struct inode_operations erofs_dir_iops; +extern const struct file_operations erofs_dir_fops; + +extern const struct address_space_operations erofs_raw_access_aops; + +/* + * Logical to physical block mapping, used by erofs_map_blocks() + * + * Different with other file systems, it is used for 2 access modes: + * + * 1) RAW access mode: + * + * Users pass a valid (m_lblk, m_lofs -- usually 0) pair, + * and get the valid m_pblk, m_pofs and the longest m_len(in bytes). + * + * Note that m_lblk in the RAW access mode refers to the number of + * the compressed ondisk block rather than the uncompressed + * in-memory block for the compressed file. + * + * m_pofs equals to m_lofs except for the inline data page. + * + * 2) Normal access mode: + * + * If the inode is not compressed, it has no difference with + * the RAW access mode. However, if the inode is compressed, + * users should pass a valid (m_lblk, m_lofs) pair, and get + * the needed m_pblk, m_pofs, m_len to get the compressed data + * and the updated m_lblk, m_lofs which indicates the start + * of the corresponding uncompressed data in the file. + */ +enum { + BH_Zipped = BH_PrivateStart, +}; + +/* Has a disk mapping */ +#define EROFS_MAP_MAPPED (1 << BH_Mapped) +/* Located in metadata (could be copied from bd_inode) */ +#define EROFS_MAP_META (1 << BH_Meta) +/* The extent has been compressed */ +#define EROFS_MAP_ZIPPED (1 << BH_Zipped) + +struct erofs_map_blocks { + erofs_off_t m_pa, m_la; + u64 m_plen, m_llen; + + unsigned int m_flags; +}; + +/* Flags used by erofs_map_blocks() */ +#define EROFS_GET_BLOCKS_RAW 0x0001 + +/* data.c */ +extern struct page *erofs_get_meta_page(struct super_block *sb, + erofs_blk_t blkaddr, bool prio); +extern int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int); + +static inline struct page *erofs_get_inline_page(struct inode *inode, + erofs_blk_t blkaddr) +{ + return erofs_get_meta_page(inode->i_sb, + blkaddr, S_ISDIR(inode->i_mode)); +} + +/* inode.c */ +extern struct inode *erofs_iget(struct super_block *sb, + erofs_nid_t nid, bool dir); + +/* dir.c */ +int erofs_namei(struct inode *dir, struct qstr *name, + erofs_nid_t *nid, unsigned *d_type); + +/* xattr.c */ +extern const struct xattr_handler *erofs_xattr_handlers[]; + +/* symlink */ +static inline void set_inode_fast_symlink(struct inode *inode) +{ + inode->i_op = &simple_symlink_inode_operations; +} + +static inline bool is_inode_fast_symlink(struct inode *inode) +{ + return inode->i_op == &simple_symlink_inode_operations; +} + +static inline void *erofs_vmap(struct page **pages, unsigned int count) +{ +#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM + int i = 0; + + while (1) { + void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL); + /* retry two more times (totally 3 times) */ + if (addr != NULL || ++i >= 3) + return addr; + vm_unmap_aliases(); + } + return NULL; +#else + return vmap(pages, count, VM_MAP, PAGE_KERNEL); +#endif +} + +static inline void erofs_vunmap(const void *mem, unsigned int count) +{ +#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM + vm_unmap_ram(mem, count); +#else + vunmap(mem); +#endif +} + +#endif + From ba2b77a8202287d9a3b58e7a98fd647601e0ab57 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:46 +0800 Subject: [PATCH 600/903] staging: erofs: add super block operations This commit adds erofs super block operations, including (u)mount, remount_fs, show_options, statfs, in addition to some private icache management functions. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/super.c | 415 ++++++++++++++++++++++++++++++++++ 1 file changed, 415 insertions(+) create mode 100644 drivers/staging/erofs/super.c diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c new file mode 100644 index 000000000000..98ae03df30f3 --- /dev/null +++ b/drivers/staging/erofs/super.c @@ -0,0 +1,415 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/super.c + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include +#include +#include +#include +#include "internal.h" + +static struct kmem_cache *erofs_inode_cachep __read_mostly; + +static void init_once(void *ptr) +{ + struct erofs_vnode *vi = ptr; + + inode_init_once(&vi->vfs_inode); +} + +static int erofs_init_inode_cache(void) +{ + erofs_inode_cachep = kmem_cache_create("erofs_inode", + sizeof(struct erofs_vnode), 0, + SLAB_RECLAIM_ACCOUNT, init_once); + + return erofs_inode_cachep != NULL ? 0 : -ENOMEM; +} + +static void erofs_exit_inode_cache(void) +{ + BUG_ON(erofs_inode_cachep == NULL); + kmem_cache_destroy(erofs_inode_cachep); +} + +static struct inode *alloc_inode(struct super_block *sb) +{ + struct erofs_vnode *vi = + kmem_cache_alloc(erofs_inode_cachep, GFP_KERNEL); + + if (vi == NULL) + return NULL; + + /* zero out everything except vfs_inode */ + memset(vi, 0, offsetof(struct erofs_vnode, vfs_inode)); + return &vi->vfs_inode; +} + +static void i_callback(struct rcu_head *head) +{ + struct inode *inode = container_of(head, struct inode, i_rcu); + struct erofs_vnode *vi = EROFS_V(inode); + + /* be careful RCU symlink path (see ext4_inode_info->i_data)! */ + if (is_inode_fast_symlink(inode)) + kfree(inode->i_link); + + kfree(vi->xattr_shared_xattrs); + + kmem_cache_free(erofs_inode_cachep, vi); +} + +static void destroy_inode(struct inode *inode) +{ + call_rcu(&inode->i_rcu, i_callback); +} + +static int superblock_read(struct super_block *sb) +{ + struct erofs_sb_info *sbi; + struct buffer_head *bh; + struct erofs_super_block *layout; + unsigned blkszbits; + int ret; + + bh = sb_bread(sb, 0); + + if (bh == NULL) { + errln("cannot read erofs superblock"); + return -EIO; + } + + sbi = EROFS_SB(sb); + layout = (struct erofs_super_block *)((u8 *)bh->b_data + + EROFS_SUPER_OFFSET); + + ret = -EINVAL; + if (le32_to_cpu(layout->magic) != EROFS_SUPER_MAGIC_V1) { + errln("cannot find valid erofs superblock"); + goto out; + } + + blkszbits = layout->blkszbits; + /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ + if (unlikely(blkszbits != LOG_BLOCK_SIZE)) { + errln("blksize %u isn't supported on this platform", + 1 << blkszbits); + goto out; + } + + sbi->blocks = le32_to_cpu(layout->blocks); + sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr); + sbi->islotbits = ffs(sizeof(struct erofs_inode_v1)) - 1; + + sbi->root_nid = le16_to_cpu(layout->root_nid); + sbi->inos = le64_to_cpu(layout->inos); + + sbi->build_time = le64_to_cpu(layout->build_time); + sbi->build_time_nsec = le32_to_cpu(layout->build_time_nsec); + + memcpy(&sb->s_uuid, layout->uuid, sizeof(layout->uuid)); + memcpy(sbi->volume_name, layout->volume_name, + sizeof(layout->volume_name)); + + ret = 0; +out: + brelse(bh); + return ret; +} + +static void default_options(struct erofs_sb_info *sbi) +{ +} + +enum { + Opt_err +}; + +static match_table_t erofs_tokens = { + {Opt_err, NULL} +}; + +static int parse_options(struct super_block *sb, char *options) +{ + substring_t args[MAX_OPT_ARGS]; + char *p; + + if (!options) + return 0; + + while ((p = strsep(&options, ",")) != NULL) { + int token; + + if (!*p) + continue; + + args[0].to = args[0].from = NULL; + token = match_token(p, erofs_tokens, args); + + switch (token) { + default: + errln("Unrecognized mount option \"%s\" " + "or missing value", p); + return -EINVAL; + } + } + return 0; +} + +static int erofs_read_super(struct super_block *sb, + const char *dev_name, void *data, int silent) +{ + struct inode *inode; + struct erofs_sb_info *sbi; + int err = -EINVAL; + + infoln("read_super, device -> %s", dev_name); + infoln("options -> %s", (char *)data); + + if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) { + errln("failed to set erofs blksize"); + goto err; + } + + sbi = kzalloc(sizeof(struct erofs_sb_info), GFP_KERNEL); + if (unlikely(sbi == NULL)) { + err = -ENOMEM; + goto err; + } + sb->s_fs_info = sbi; + + err = superblock_read(sb); + if (err) + goto err_sbread; + + sb->s_magic = EROFS_SUPER_MAGIC; + sb->s_flags |= MS_RDONLY | MS_NOATIME; + sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_time_gran = 1; + + sb->s_op = &erofs_sops; + + /* set erofs default mount options */ + default_options(sbi); + + err = parse_options(sb, data); + if (err) + goto err_parseopt; + + if (!silent) + infoln("root inode @ nid %llu", ROOT_NID(sbi)); + + /* get the root inode */ + inode = erofs_iget(sb, ROOT_NID(sbi), true); + if (IS_ERR(inode)) { + err = PTR_ERR(inode); + goto err_iget; + } + + if (!S_ISDIR(inode->i_mode)) { + errln("rootino(nid %llu) is not a directory(i_mode %o)", + ROOT_NID(sbi), inode->i_mode); + err = -EINVAL; + goto err_isdir; + } + + sb->s_root = d_make_root(inode); + if (sb->s_root == NULL) { + err = -ENOMEM; + goto err_makeroot; + } + + /* save the device name to sbi */ + sbi->dev_name = __getname(); + if (sbi->dev_name == NULL) { + err = -ENOMEM; + goto err_devname; + } + + snprintf(sbi->dev_name, PATH_MAX, "%s", dev_name); + sbi->dev_name[PATH_MAX - 1] = '\0'; + + /* + * We already have a positive dentry, which was instantiated + * by d_make_root. Just need to d_rehash it. + */ + d_rehash(sb->s_root); + + if (!silent) + infoln("mounted on %s with opts: %s.", dev_name, + (char *)data); + return 0; + /* + * please add a label for each exit point and use + * the following name convention, thus new features + * can be integrated easily without renaming labels. + */ +err_devname: + dput(sb->s_root); +err_makeroot: +err_isdir: + if (sb->s_root == NULL) + iput(inode); +err_iget: +err_parseopt: +err_sbread: + sb->s_fs_info = NULL; + kfree(sbi); +err: + return err; +} + +/* + * could be triggered after deactivate_locked_super() + * is called, thus including umount and failed to initialize. + */ +static void erofs_put_super(struct super_block *sb) +{ + struct erofs_sb_info *sbi = EROFS_SB(sb); + + /* for cases which are failed in "read_super" */ + if (sbi == NULL) + return; + + WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC); + + infoln("unmounted for %s", sbi->dev_name); + __putname(sbi->dev_name); + + kfree(sbi); + sb->s_fs_info = NULL; +} + + +struct erofs_mount_private { + const char *dev_name; + char *options; +}; + +/* support mount_bdev() with options */ +static int erofs_fill_super(struct super_block *sb, + void *_priv, int silent) +{ + struct erofs_mount_private *priv = _priv; + + return erofs_read_super(sb, priv->dev_name, + priv->options, silent); +} + +static struct dentry *erofs_mount( + struct file_system_type *fs_type, int flags, + const char *dev_name, void *data) +{ + struct erofs_mount_private priv = { + .dev_name = dev_name, + .options = data + }; + + return mount_bdev(fs_type, flags, dev_name, + &priv, erofs_fill_super); +} + +static void erofs_kill_sb(struct super_block *sb) +{ + kill_block_super(sb); +} + +static struct file_system_type erofs_fs_type = { + .owner = THIS_MODULE, + .name = "erofs", + .mount = erofs_mount, + .kill_sb = erofs_kill_sb, + .fs_flags = FS_REQUIRES_DEV, +}; +MODULE_ALIAS_FS("erofs"); + +static int __init erofs_module_init(void) +{ + int err; + + erofs_check_ondisk_layout_definitions(); + infoln("initializing erofs " EROFS_VERSION); + + err = erofs_init_inode_cache(); + if (err) + goto icache_err; + + err = register_filesystem(&erofs_fs_type); + if (err) + goto fs_err; + + infoln("successfully to initialize erofs"); + return 0; + +fs_err: + erofs_exit_inode_cache(); +icache_err: + return err; +} + +static void __exit erofs_module_exit(void) +{ + unregister_filesystem(&erofs_fs_type); + erofs_exit_inode_cache(); + infoln("successfully finalize erofs"); +} + +/* get filesystem statistics */ +static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf) +{ + struct super_block *sb = dentry->d_sb; + struct erofs_sb_info *sbi = EROFS_SB(sb); + u64 id = huge_encode_dev(sb->s_bdev->bd_dev); + + buf->f_type = sb->s_magic; + buf->f_bsize = EROFS_BLKSIZ; + buf->f_blocks = sbi->blocks; + buf->f_bfree = buf->f_bavail = 0; + + buf->f_files = ULLONG_MAX; + buf->f_ffree = ULLONG_MAX - sbi->inos; + + buf->f_namelen = EROFS_NAME_LEN; + + buf->f_fsid.val[0] = (u32)id; + buf->f_fsid.val[1] = (u32)(id >> 32); + return 0; +} + +static int erofs_show_options(struct seq_file *seq, struct dentry *root) +{ + return 0; +} + +static int erofs_remount(struct super_block *sb, int *flags, char *data) +{ + BUG_ON(!sb_rdonly(sb)); + + *flags |= MS_RDONLY; + return 0; +} + +const struct super_operations erofs_sops = { + .put_super = erofs_put_super, + .alloc_inode = alloc_inode, + .destroy_inode = destroy_inode, + .statfs = erofs_statfs, + .show_options = erofs_show_options, + .remount_fs = erofs_remount, +}; + +module_init(erofs_module_init); +module_exit(erofs_module_exit); + +MODULE_DESCRIPTION("Enhanced ROM File System"); +MODULE_AUTHOR("Gao Xiang, Yu Chao, Miao Xie, CONSUMER BG, HUAWEI Inc."); +MODULE_LICENSE("GPL"); + From 81781b02f9845b44603d75f5b60c3af351415efa Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:47 +0800 Subject: [PATCH 601/903] staging: erofs: add raw address_space operations This commit adds functions for meta and raw data, and also provides address_space_operations for raw data access. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/data.c | 362 +++++++++++++++++++++++++++++++++++ 1 file changed, 362 insertions(+) create mode 100644 drivers/staging/erofs/data.c diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c new file mode 100644 index 000000000000..4ddb5c086b44 --- /dev/null +++ b/drivers/staging/erofs/data.c @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/data.c + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include "internal.h" +#include + +static inline void read_endio(struct bio *bio) +{ + int i; + struct bio_vec *bvec; + const blk_status_t err = bio->bi_status; + + bio_for_each_segment_all(bvec, bio, i) { + struct page *page = bvec->bv_page; + + /* page is already locked */ + BUG_ON(PageUptodate(page)); + + if (unlikely(err)) + SetPageError(page); + else + SetPageUptodate(page); + + unlock_page(page); + /* page could be reclaimed now */ + } + bio_put(bio); +} + +static void __submit_bio(struct bio *bio, unsigned op, unsigned op_flags) +{ + bio_set_op_attrs(bio, op, op_flags); + submit_bio(bio); +} + +static struct bio *prepare_bio(struct super_block *sb, + erofs_blk_t blkaddr, unsigned nr_pages) +{ + struct bio *bio = bio_alloc(GFP_NOIO | __GFP_NOFAIL, nr_pages); + + BUG_ON(bio == NULL); + + bio->bi_end_io = read_endio; + bio_set_dev(bio, sb->s_bdev); + bio->bi_iter.bi_sector = blkaddr << LOG_SECTORS_PER_BLOCK; + + return bio; +} + +/* prio -- true is used for dir */ +struct page *erofs_get_meta_page(struct super_block *sb, + erofs_blk_t blkaddr, bool prio) +{ + struct inode *bd_inode = sb->s_bdev->bd_inode; + struct address_space *mapping = bd_inode->i_mapping; + struct page *page; + +repeat: + page = find_or_create_page(mapping, blkaddr, + /* + * Prefer looping in the allocator rather than here, + * at least that code knows what it's doing. + */ + mapping_gfp_constraint(mapping, ~__GFP_FS) | __GFP_NOFAIL); + + BUG_ON(!page || !PageLocked(page)); + + if (!PageUptodate(page)) { + struct bio *bio; + int err; + + bio = prepare_bio(sb, blkaddr, 1); + err = bio_add_page(bio, page, PAGE_SIZE, 0); + BUG_ON(err != PAGE_SIZE); + + __submit_bio(bio, REQ_OP_READ, + REQ_META | (prio ? REQ_PRIO : 0)); + + lock_page(page); + + /* the page has been truncated by others? */ + if (unlikely(page->mapping != mapping)) { + unlock_page(page); + put_page(page); + goto repeat; + } + + /* more likely a read error */ + if (unlikely(!PageUptodate(page))) { + unlock_page(page); + put_page(page); + + page = ERR_PTR(-EIO); + } + } + return page; +} + +static int erofs_map_blocks_flatmode(struct inode *inode, + struct erofs_map_blocks *map, + int flags) +{ + erofs_blk_t nblocks, lastblk; + u64 offset = map->m_la; + struct erofs_vnode *vi = EROFS_V(inode); + + BUG_ON(is_inode_layout_compression(inode)); + + nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE); + lastblk = nblocks - is_inode_layout_inline(inode); + + if (unlikely(offset >= inode->i_size)) { + /* leave out-of-bound access unmapped */ + map->m_flags = 0; + map->m_plen = 0; + goto out; + } + + /* there is no hole in flatmode */ + map->m_flags = EROFS_MAP_MAPPED; + + if (offset < blknr_to_addr(lastblk)) { + map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la; + map->m_plen = blknr_to_addr(lastblk) - offset; + } else if (is_inode_layout_inline(inode)) { + /* 2 - inode inline B: inode, [xattrs], inline last blk... */ + struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); + + map->m_pa = iloc(sbi, vi->nid) + vi->inode_isize + + vi->xattr_isize + erofs_blkoff(map->m_la); + map->m_plen = inode->i_size - offset; + + /* inline data should locate in one meta block */ + BUG_ON(erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE); + map->m_flags |= EROFS_MAP_META; + } else { + errln("internal error @ nid: %llu (size %llu), m_la 0x%llx", + vi->nid, inode->i_size, map->m_la); + BUG(); + } + +out: + map->m_llen = map->m_plen; + debugln("%s, m_la 0x%llx m_pa %llx m_len %llu", + __func__, map->m_la, map->m_pa, map->m_plen); + return 0; +} + +int erofs_map_blocks(struct inode *inode, + struct erofs_map_blocks *map, int flags) +{ + if (unlikely(is_inode_layout_compression(inode))) + return -ENOTSUPP; + + return erofs_map_blocks_flatmode(inode, map, flags); +} + +static inline struct bio *erofs_read_raw_page( + struct bio *bio, + struct address_space *mapping, + struct page *page, + erofs_off_t *last_block, + unsigned nblocks, + bool ra) +{ + struct inode *inode = mapping->host; + erofs_off_t current_block = (erofs_off_t)page->index; + int err; + + BUG_ON(!nblocks); + + if (PageUptodate(page)) { + err = 0; + goto has_updated; + } + + if (cleancache_get_page(page) == 0) { + err = 0; + SetPageUptodate(page); + goto has_updated; + } + + /* note that for readpage case, bio also equals to NULL */ + if (bio != NULL && + /* not continuous */ + *last_block + 1 != current_block) { +submit_bio_retry: + __submit_bio(bio, REQ_OP_READ, 0); + bio = NULL; + } + + if (bio == NULL) { + struct erofs_map_blocks map = { + .m_la = blknr_to_addr(current_block), + }; + + err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW); + if (unlikely(err)) + goto err_out; + + /* zero out the holed page */ + if (unlikely(!(map.m_flags & EROFS_MAP_MAPPED))) { + zero_user_segment(page, 0, PAGE_SIZE); + SetPageUptodate(page); + + /* imply err = 0, see erofs_map_blocks */ + goto has_updated; + } + + /* for RAW access mode, m_plen must be equal to m_llen */ + BUG_ON(map.m_plen != map.m_llen); + + /* deal with inline page */ + if (map.m_flags & EROFS_MAP_META) { + void *vsrc, *vto; + struct page *ipage; + + BUG_ON(map.m_plen > PAGE_SIZE); + + ipage = erofs_get_meta_page(inode->i_sb, + erofs_blknr(map.m_pa), 0); + + if (IS_ERR(ipage)) { + err = PTR_ERR(ipage); + goto err_out; + } + + vsrc = kmap_atomic(ipage); + vto = kmap_atomic(page); + memcpy(vto, vsrc + erofs_blkoff(map.m_pa), map.m_plen); + memset(vto + map.m_plen, 0, PAGE_SIZE - map.m_plen); + kunmap_atomic(vto); + kunmap_atomic(vsrc); + flush_dcache_page(page); + + SetPageUptodate(page); + /* TODO: could we unlock the page earlier? */ + unlock_page(ipage); + put_page(ipage); + + /* imply err = 0, see erofs_map_blocks */ + goto has_updated; + } + + /* pa must be block-aligned for raw reading */ + BUG_ON(erofs_blkoff(map.m_pa) != 0); + + /* max # of continuous pages */ + if (nblocks > DIV_ROUND_UP(map.m_plen, PAGE_SIZE)) + nblocks = DIV_ROUND_UP(map.m_plen, PAGE_SIZE); + if (nblocks > BIO_MAX_PAGES) + nblocks = BIO_MAX_PAGES; + + bio = prepare_bio(inode->i_sb, erofs_blknr(map.m_pa), nblocks); + } + + err = bio_add_page(bio, page, PAGE_SIZE, 0); + /* out of the extent or bio is full */ + if (err < PAGE_SIZE) + goto submit_bio_retry; + + *last_block = current_block; + + /* shift in advance in case of it followed by too many gaps */ + if (unlikely(bio->bi_vcnt >= bio->bi_max_vecs)) { + /* err should reassign to 0 after submitting */ + err = 0; + goto submit_bio_out; + } + + return bio; + +err_out: + /* for sync reading, set page error immediately */ + if (!ra) { + SetPageError(page); + ClearPageUptodate(page); + } +has_updated: + unlock_page(page); + + /* if updated manually, continuous pages has a gap */ + if (bio != NULL) +submit_bio_out: + __submit_bio(bio, REQ_OP_READ, 0); + + return unlikely(err) ? ERR_PTR(err) : NULL; +} + +/* + * since we dont have write or truncate flows, so no inode + * locking needs to be held at the moment. + */ +static int erofs_raw_access_readpage(struct file *file, struct page *page) +{ + erofs_off_t last_block; + struct bio *bio; + + bio = erofs_read_raw_page(NULL, page->mapping, + page, &last_block, 1, false); + + if (IS_ERR(bio)) + return PTR_ERR(bio); + + BUG_ON(bio != NULL); /* since we have only one bio -- must be NULL */ + return 0; +} + +static int erofs_raw_access_readpages(struct file *filp, + struct address_space *mapping, + struct list_head *pages, unsigned nr_pages) +{ + erofs_off_t last_block; + struct bio *bio = NULL; + gfp_t gfp = readahead_gfp_mask(mapping); + + for (; nr_pages; --nr_pages) { + struct page *page = list_entry(pages->prev, struct page, lru); + + prefetchw(&page->flags); + list_del(&page->lru); + + if (!add_to_page_cache_lru(page, mapping, page->index, gfp)) { + bio = erofs_read_raw_page(bio, mapping, page, + &last_block, nr_pages, true); + + /* all the page errors are ignored when readahead */ + if (IS_ERR(bio)) { + pr_err("%s, readahead error at page %lu of nid %llu\n", + __func__, page->index, + EROFS_V(mapping->host)->nid); + + bio = NULL; + } + } + + /* pages could still be locked */ + put_page(page); + } + BUG_ON(!list_empty(pages)); + + /* the rare case (end in gaps) */ + if (unlikely(bio != NULL)) + __submit_bio(bio, REQ_OP_READ, 0); + return 0; +} + +/* for uncompressed (aligned) files and raw access for other files */ +const struct address_space_operations erofs_raw_access_aops = { + .readpage = erofs_raw_access_readpage, + .readpages = erofs_raw_access_readpages, +}; + From 431339ba90423a038914c6032bfd71f0ba7ef2f2 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:48 +0800 Subject: [PATCH 602/903] staging: erofs: add inode operations This adds core functions to get, read an inode. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 210 ++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 drivers/staging/erofs/inode.c diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c new file mode 100644 index 000000000000..74e65be6b4b5 --- /dev/null +++ b/drivers/staging/erofs/inode.c @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/inode.c + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include "internal.h" + +/* no locking */ +static int read_inode(struct inode *inode, void *data) +{ + struct erofs_vnode *vi = EROFS_V(inode); + struct erofs_inode_v1 *v1 = data; + const unsigned advise = le16_to_cpu(v1->i_advise); + + vi->data_mapping_mode = __inode_data_mapping(advise); + + if (unlikely(vi->data_mapping_mode >= EROFS_INODE_LAYOUT_MAX)) { + errln("unknown data mapping mode %u of nid %llu", + vi->data_mapping_mode, vi->nid); + DBG_BUGON(1); + return -EIO; + } + + if (__inode_version(advise) == EROFS_INODE_LAYOUT_V2) { + struct erofs_inode_v2 *v2 = data; + + vi->inode_isize = sizeof(struct erofs_inode_v2); + vi->xattr_isize = ondisk_xattr_ibody_size(v2->i_xattr_icount); + + vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr); + inode->i_mode = le16_to_cpu(v2->i_mode); + + i_uid_write(inode, le32_to_cpu(v2->i_uid)); + i_gid_write(inode, le32_to_cpu(v2->i_gid)); + set_nlink(inode, le32_to_cpu(v2->i_nlink)); + + /* ns timestamp */ + inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = + le64_to_cpu(v2->i_ctime); + inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = + le32_to_cpu(v2->i_ctime_nsec); + + inode->i_size = le64_to_cpu(v2->i_size); + } else if (__inode_version(advise) == EROFS_INODE_LAYOUT_V1) { + struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); + + vi->inode_isize = sizeof(struct erofs_inode_v1); + vi->xattr_isize = ondisk_xattr_ibody_size(v1->i_xattr_icount); + + vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr); + inode->i_mode = le16_to_cpu(v1->i_mode); + + i_uid_write(inode, le16_to_cpu(v1->i_uid)); + i_gid_write(inode, le16_to_cpu(v1->i_gid)); + set_nlink(inode, le16_to_cpu(v1->i_nlink)); + + /* use build time to derive all file time */ + inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = + sbi->build_time; + inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = + sbi->build_time_nsec; + + inode->i_size = le32_to_cpu(v1->i_size); + } else { + errln("unsupported on-disk inode version %u of nid %llu", + __inode_version(advise), vi->nid); + DBG_BUGON(1); + return -EIO; + } + + /* measure inode.i_blocks as the generic filesystem */ + inode->i_blocks = ((inode->i_size - 1) >> 9) + 1; + return 0; +} + +/* + * try_lock can be required since locking order is: + * file data(fs_inode) + * meta(bd_inode) + * but the majority of the callers is "iget", + * in that case we are pretty sure no deadlock since + * no data operations exist. However I tend to + * try_lock since it takes no much overhead and + * will success immediately. + */ +static int fill_inline_data(struct inode *inode, void *data, unsigned m_pofs) +{ + struct erofs_vnode *vi = EROFS_V(inode); + int mode = vi->data_mapping_mode; + + DBG_BUGON(mode >= EROFS_INODE_LAYOUT_MAX); + + /* should be inode inline C */ + if (mode != EROFS_INODE_LAYOUT_INLINE) + return 0; + + /* fast symlink (following ext4) */ + if (S_ISLNK(inode->i_mode) && inode->i_size < PAGE_SIZE) { + char *lnk = kmalloc(inode->i_size + 1, GFP_KERNEL); + + if (unlikely(lnk == NULL)) + return -ENOMEM; + + m_pofs += vi->inode_isize + vi->xattr_isize; + BUG_ON(m_pofs + inode->i_size > PAGE_SIZE); + + /* get in-page inline data */ + memcpy(lnk, data + m_pofs, inode->i_size); + lnk[inode->i_size] = '\0'; + + inode->i_link = lnk; + set_inode_fast_symlink(inode); + } + return -EAGAIN; +} + +static int fill_inode(struct inode *inode, int isdir) +{ + struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); + struct erofs_vnode *vi = EROFS_V(inode); + struct page *page; + void *data; + int err; + erofs_blk_t blkaddr; + unsigned ofs; + + blkaddr = erofs_blknr(iloc(sbi, vi->nid)); + ofs = erofs_blkoff(iloc(sbi, vi->nid)); + + debugln("%s, reading inode nid %llu at %u of blkaddr %u", + __func__, vi->nid, ofs, blkaddr); + + page = erofs_get_meta_page(inode->i_sb, blkaddr, isdir); + + if (IS_ERR(page)) { + errln("failed to get inode (nid: %llu) page, err %ld", + vi->nid, PTR_ERR(page)); + return PTR_ERR(page); + } + + BUG_ON(!PageUptodate(page)); + data = page_address(page); + + err = read_inode(inode, data + ofs); + if (!err) { + /* setup the new inode */ + if (S_ISREG(inode->i_mode)) { + inode->i_fop = &generic_ro_fops; + } else if (S_ISDIR(inode->i_mode)) { + inode->i_op = + &erofs_dir_iops; + inode->i_fop = &erofs_dir_fops; + } else if (S_ISLNK(inode->i_mode)) { + /* by default, page_get_link is used for symlink */ + inode->i_op = + &page_symlink_inode_operations; + inode_nohighmem(inode); + } else { + err = -EIO; + goto out_unlock; + } + + if (is_inode_layout_compression(inode)) { + err = -ENOTSUPP; + goto out_unlock; + } + + inode->i_mapping->a_ops = &erofs_raw_access_aops; + + /* fill last page if inline data is available */ + fill_inline_data(inode, data, ofs); + } + +out_unlock: + unlock_page(page); + put_page(page); + return err; +} + +struct inode *erofs_iget(struct super_block *sb, + erofs_nid_t nid, bool isdir) +{ + struct inode *inode = iget_locked(sb, nid); + + if (unlikely(inode == NULL)) + return ERR_PTR(-ENOMEM); + + if (inode->i_state & I_NEW) { + int err; + struct erofs_vnode *vi = EROFS_V(inode); + vi->nid = nid; + + err = fill_inode(inode, isdir); + if (likely(!err)) + unlock_new_inode(inode); + else { + iget_failed(inode); + inode = ERR_PTR(err); + } + } + return inode; +} + From 3aa8ec716e52c02360457fa018296629b4d0becf Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:49 +0800 Subject: [PATCH 603/903] staging: erofs: add directory operations This adds functions for directory, mainly readdir. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/dir.c | 145 ++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 drivers/staging/erofs/dir.c diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c new file mode 100644 index 000000000000..be6ae3b1bdbe --- /dev/null +++ b/drivers/staging/erofs/dir.c @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/dir.c + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include "internal.h" + +static const unsigned char erofs_filetype_table[EROFS_FT_MAX] = { + [EROFS_FT_UNKNOWN] = DT_UNKNOWN, + [EROFS_FT_REG_FILE] = DT_REG, + [EROFS_FT_DIR] = DT_DIR, + [EROFS_FT_CHRDEV] = DT_CHR, + [EROFS_FT_BLKDEV] = DT_BLK, + [EROFS_FT_FIFO] = DT_FIFO, + [EROFS_FT_SOCK] = DT_SOCK, + [EROFS_FT_SYMLINK] = DT_LNK, +}; + +static int erofs_fill_dentries(struct dir_context *ctx, + void *dentry_blk, unsigned *ofs, + unsigned nameoff, unsigned maxsize) +{ + struct erofs_dirent *de = dentry_blk; + const struct erofs_dirent *end = dentry_blk + nameoff; + + de = dentry_blk + *ofs; + while (de < end) { + const char *de_name; + int de_namelen; + unsigned char d_type; +#ifdef CONFIG_EROFS_FS_DEBUG + unsigned dbg_namelen; + unsigned char dbg_namebuf[EROFS_NAME_LEN]; +#endif + + if (unlikely(de->file_type < EROFS_FT_MAX)) + d_type = erofs_filetype_table[de->file_type]; + else + d_type = DT_UNKNOWN; + + nameoff = le16_to_cpu(de->nameoff); + de_name = (char *)dentry_blk + nameoff; + + de_namelen = unlikely(de + 1 >= end) ? + /* last directory entry */ + strnlen(de_name, maxsize - nameoff) : + le16_to_cpu(de[1].nameoff) - nameoff; + + /* the corrupted directory found */ + BUG_ON(de_namelen < 0); + +#ifdef CONFIG_EROFS_FS_DEBUG + dbg_namelen = min(EROFS_NAME_LEN - 1, de_namelen); + memcpy(dbg_namebuf, de_name, dbg_namelen); + dbg_namebuf[dbg_namelen] = '\0'; + + debugln("%s, found de_name %s de_len %d d_type %d", __func__, + dbg_namebuf, de_namelen, d_type); +#endif + + if (!dir_emit(ctx, de_name, de_namelen, + le64_to_cpu(de->nid), d_type)) + /* stoped by some reason */ + return 1; + ++de; + *ofs += sizeof(struct erofs_dirent); + } + *ofs = maxsize; + return 0; +} + +static int erofs_readdir(struct file *f, struct dir_context *ctx) +{ + struct inode *dir = file_inode(f); + struct address_space *mapping = dir->i_mapping; + const size_t dirsize = i_size_read(dir); + unsigned i = ctx->pos / EROFS_BLKSIZ; + unsigned ofs = ctx->pos % EROFS_BLKSIZ; + int err = 0; + bool initial = true; + + while (ctx->pos < dirsize) { + struct page *dentry_page; + struct erofs_dirent *de; + unsigned nameoff, maxsize; + + dentry_page = read_mapping_page(mapping, i, NULL); + if (IS_ERR(dentry_page)) + continue; + + lock_page(dentry_page); + de = (struct erofs_dirent *)kmap(dentry_page); + + nameoff = le16_to_cpu(de->nameoff); + + if (unlikely(nameoff < sizeof(struct erofs_dirent) || + nameoff >= PAGE_SIZE)) { + errln("%s, invalid de[0].nameoff %u", + __func__, nameoff); + + err = -EIO; + goto skip_this; + } + + maxsize = min_t(unsigned, dirsize - ctx->pos + ofs, PAGE_SIZE); + + /* search dirents at the arbitrary position */ + if (unlikely(initial)) { + initial = false; + + ofs = roundup(ofs, sizeof(struct erofs_dirent)); + if (unlikely(ofs >= nameoff)) + goto skip_this; + } + + err = erofs_fill_dentries(ctx, de, &ofs, nameoff, maxsize); +skip_this: + kunmap(dentry_page); + + unlock_page(dentry_page); + put_page(dentry_page); + + ctx->pos = blknr_to_addr(i) + ofs; + + if (unlikely(err)) + break; + ++i; + ofs = 0; + } + return err < 0 ? err : 0; +} + +const struct file_operations erofs_dir_fops = { + .llseek = generic_file_llseek, + .read = generic_read_dir, + .iterate = erofs_readdir, +}; + From d72d1ce601743deed322ad5b74e960a2fd8ff205 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:50 +0800 Subject: [PATCH 604/903] staging: erofs: add namei functions This commit adds functions that transfer names to inodes. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/namei.c | 243 ++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 drivers/staging/erofs/namei.c diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c new file mode 100644 index 000000000000..39db643bc722 --- /dev/null +++ b/drivers/staging/erofs/namei.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/namei.c + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include "internal.h" + +/* based on the value of qn->len is accurate */ +static inline int dirnamecmp(struct qstr *qn, + struct qstr *qd, unsigned *matched) +{ + unsigned i = *matched, len = min(qn->len, qd->len); +loop: + if (unlikely(i >= len)) { + *matched = i; + if (qn->len < qd->len) { + /* + * actually (qn->len == qd->len) + * when qd->name[i] == '\0' + */ + return qd->name[i] == '\0' ? 0 : -1; + } + return (qn->len > qd->len); + } + + if (qn->name[i] != qd->name[i]) { + *matched = i; + return qn->name[i] > qd->name[i] ? 1 : -1; + } + + ++i; + goto loop; +} + +static struct erofs_dirent *find_target_dirent( + struct qstr *name, + u8 *data, int maxsize) +{ + unsigned ndirents, head, back; + unsigned startprfx, endprfx; + struct erofs_dirent *const de = (struct erofs_dirent *)data; + + /* make sure that maxsize is valid */ + BUG_ON(maxsize < sizeof(struct erofs_dirent)); + + ndirents = le16_to_cpu(de->nameoff) / sizeof(*de); + + /* corrupted dir (may be unnecessary...) */ + BUG_ON(!ndirents); + + head = 0; + back = ndirents - 1; + startprfx = endprfx = 0; + + while (head <= back) { + unsigned mid = head + (back - head) / 2; + unsigned nameoff = le16_to_cpu(de[mid].nameoff); + unsigned matched = min(startprfx, endprfx); + + struct qstr dname = QSTR_INIT(data + nameoff, + unlikely(mid >= ndirents - 1) ? + maxsize - nameoff : + le16_to_cpu(de[mid + 1].nameoff) - nameoff); + + /* string comparison without already matched prefix */ + int ret = dirnamecmp(name, &dname, &matched); + + if (unlikely(!ret)) + return de + mid; + else if (ret > 0) { + head = mid + 1; + startprfx = matched; + } else if (unlikely(mid < 1)) /* fix "mid" overflow */ + break; + else { + back = mid - 1; + endprfx = matched; + } + } + + return ERR_PTR(-ENOENT); +} + +static struct page *find_target_block_classic( + struct inode *dir, + struct qstr *name, int *_diff) +{ + unsigned startprfx, endprfx; + unsigned head, back; + struct address_space *const mapping = dir->i_mapping; + struct page *candidate = ERR_PTR(-ENOENT); + + startprfx = endprfx = 0; + head = 0; + back = inode_datablocks(dir) - 1; + + while (head <= back) { + unsigned mid = head + (back - head) / 2; + struct page *page = read_mapping_page(mapping, mid, NULL); + + if (IS_ERR(page)) { +exact_out: + if (!IS_ERR(candidate)) /* valid candidate */ + put_page(candidate); + return page; + } else { + int diff; + unsigned ndirents, matched; + struct qstr dname; + struct erofs_dirent *de = kmap_atomic(page); + unsigned nameoff = le16_to_cpu(de->nameoff); + + ndirents = nameoff / sizeof(*de); + + /* corrupted dir (should have one entry at least) */ + BUG_ON(!ndirents || nameoff > PAGE_SIZE); + + matched = min(startprfx, endprfx); + + dname.name = (u8 *)de + nameoff; + dname.len = ndirents == 1 ? + /* since the rest of the last page is 0 */ + EROFS_BLKSIZ - nameoff + : le16_to_cpu(de[1].nameoff) - nameoff; + + /* string comparison without already matched prefix */ + diff = dirnamecmp(name, &dname, &matched); + kunmap_atomic(de); + + if (unlikely(!diff)) { + *_diff = 0; + goto exact_out; + } else if (diff > 0) { + head = mid + 1; + startprfx = matched; + + if (likely(!IS_ERR(candidate))) + put_page(candidate); + candidate = page; + } else { + put_page(page); + + if (unlikely(mid < 1)) /* fix "mid" overflow */ + break; + + back = mid - 1; + endprfx = matched; + } + } + } + *_diff = 1; + return candidate; +} + +int erofs_namei(struct inode *dir, + struct qstr *name, + erofs_nid_t *nid, unsigned *d_type) +{ + int diff; + struct page *page; + u8 *data; + struct erofs_dirent *de; + + if (unlikely(!dir->i_size)) + return -ENOENT; + + diff = 1; + page = find_target_block_classic(dir, name, &diff); + + if (unlikely(IS_ERR(page))) + return PTR_ERR(page); + + data = kmap_atomic(page); + /* the target page has been mapped */ + de = likely(diff) ? + /* since the rest of the last page is 0 */ + find_target_dirent(name, data, EROFS_BLKSIZ) : + (struct erofs_dirent *)data; + + if (likely(!IS_ERR(de))) { + *nid = le64_to_cpu(de->nid); + *d_type = de->file_type; + } + + kunmap_atomic(data); + put_page(page); + + return IS_ERR(de) ? PTR_ERR(de) : 0; +} + +/* NOTE: i_mutex is already held by vfs */ +static struct dentry *erofs_lookup(struct inode *dir, + struct dentry *dentry, unsigned int flags) +{ + int err; + erofs_nid_t nid; + unsigned d_type; + struct inode *inode; + + DBG_BUGON(!d_really_is_negative(dentry)); + /* dentry must be unhashed in lookup, no need to worry about */ + DBG_BUGON(!d_unhashed(dentry)); + + /* file name exceeds fs limit */ + if (unlikely(dentry->d_name.len > EROFS_NAME_LEN)) + return ERR_PTR(-ENAMETOOLONG); + + /* false uninitialized warnings on gcc 4.8.x */ + err = erofs_namei(dir, &dentry->d_name, &nid, &d_type); + + if (err == -ENOENT) { + /* negative dentry */ + inode = NULL; + goto negative_out; + } else if (unlikely(err)) + return ERR_PTR(err); + + debugln("%s, %s (nid %llu) found, d_type %u", __func__, + dentry->d_name.name, nid, d_type); + + inode = erofs_iget(dir->i_sb, nid, d_type == EROFS_FT_DIR); + if (IS_ERR(inode)) + return ERR_CAST(inode); + +negative_out: + return d_splice_alias(inode, dentry); +} + +const struct inode_operations erofs_dir_iops = { + .lookup = erofs_lookup, +}; + +const struct inode_operations erofs_dir_xattr_iops = { + .lookup = erofs_lookup, +}; + From fd68c6a20fcfac78b70465ec2e858403dc200056 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:51 +0800 Subject: [PATCH 605/903] staging: erofs: update Kconfig and Makefile This commit adds Makefile and Kconfig for erofs, and updates Makefile and Kconfig files in the fs directory. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 ++ drivers/staging/Makefile | 1 + drivers/staging/erofs/Kconfig | 36 ++++++++++++++++++++++++++++++++++ drivers/staging/erofs/Makefile | 11 +++++++++++ 4 files changed, 50 insertions(+) create mode 100644 drivers/staging/erofs/Kconfig create mode 100644 drivers/staging/erofs/Makefile diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 17fd9b455ec6..2bce6473318d 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/gasket/Kconfig" source "drivers/staging/axis-fifo/Kconfig" +source "drivers/staging/erofs/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 231698f2da7d..8474712908c2 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -54,3 +54,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-eth/ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/ +obj-$(CONFIG_EROFS_FS) += erofs/ diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig new file mode 100644 index 000000000000..077430f1243a --- /dev/null +++ b/drivers/staging/erofs/Kconfig @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: GPL-2.0 + +config EROFS_FS + tristate "EROFS filesystem support" + depends on BLOCK + help + EROFS(Enhanced Read-Only File System) is a lightweight + read-only file system with modern designs (eg. page-sized + blocks, inline xattrs/data, etc.) for scenarios which need + high-performance read-only requirements, eg. firmwares in + mobile phone or LIVECDs. + + It also provides VLE compression support, focusing on + random read improvements, keeping relatively lower + compression ratios, which is useful for high-performance + devices with limited memory and ROM space. + + If unsure, say N. + +config EROFS_FS_DEBUG + bool "EROFS debugging feature" + depends on EROFS_FS + help + Print EROFS debugging messages and enable more BUG_ONs + which check the filesystem consistency aggressively. + + For daily use, say N. + +config EROFS_FS_USE_VM_MAP_RAM + bool "EROFS VM_MAP_RAM Support" + depends on EROFS_FS + help + use vm_map_ram/vm_unmap_ram instead of vmap/vunmap. + + If you don't know what these are, say N. + diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile new file mode 100644 index 000000000000..31e909e02314 --- /dev/null +++ b/drivers/staging/erofs/Makefile @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 + +EROFS_VERSION = "1.0pre1" + +ccflags-y += -Wall -DEROFS_VERSION=\"$(EROFS_VERSION)\" + +obj-$(CONFIG_EROFS_FS) += erofs.o +# staging requirement: to be self-contained in its own directory +ccflags-y += -I$(src)/include +erofs-objs := super.o inode.o data.o namei.o dir.o + From b17500a0fdbae10a8ce274dd523106f16d114339 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:52 +0800 Subject: [PATCH 606/903] staging: erofs: introduce xattr & acl support This implements xattr and acl functionalities. Inline and shared xattrs are introduced for flexibility. Specifically, if the same xattr occurs for many times in a large number of inodes or the value of a xattr is so large that it isn't suitable to be inlined, a shared xattr kept in the xattr meta will be used instead. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Kconfig | 37 ++ drivers/staging/erofs/Makefile | 1 + drivers/staging/erofs/inode.c | 33 +- drivers/staging/erofs/internal.h | 22 ++ drivers/staging/erofs/namei.c | 4 + drivers/staging/erofs/super.c | 67 ++++ drivers/staging/erofs/xattr.c | 579 +++++++++++++++++++++++++++++++ drivers/staging/erofs/xattr.h | 93 +++++ 8 files changed, 835 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/erofs/xattr.c create mode 100644 drivers/staging/erofs/xattr.h diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index 077430f1243a..1a5ec1bb5cda 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig @@ -26,6 +26,43 @@ config EROFS_FS_DEBUG For daily use, say N. +config EROFS_FS_XATTR + bool "EROFS extended attributes" + depends on EROFS_FS + default y + help + Extended attributes are name:value pairs associated with inodes by + the kernel or by users (see the attr(5) manual page, or visit + for details). + + If unsure, say N. + +config EROFS_FS_POSIX_ACL + bool "EROFS Access Control Lists" + depends on EROFS_FS_XATTR + select FS_POSIX_ACL + default y + help + Posix Access Control Lists (ACLs) support permissions for users and + groups beyond the owner/group/world scheme. + + To learn more about Access Control Lists, visit the POSIX ACLs for + Linux website . + + If you don't know what Access Control Lists are, say N. + +config EROFS_FS_SECURITY + bool "EROFS Security Labels" + depends on EROFS_FS_XATTR + help + Security labels provide an access control facility to support Linux + Security Models (LSMs) accepted by AppArmor, SELinux, Smack and TOMOYO + Linux. This option enables an extended attribute handler for file + security labels in the erofs filesystem, so that it requires enabling + the extended attribute support in advance. + + If you are not using a security module, say N. + config EROFS_FS_USE_VM_MAP_RAM bool "EROFS VM_MAP_RAM Support" depends on EROFS_FS diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index 31e909e02314..977b7e05a312 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -8,4 +8,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o # staging requirement: to be self-contained in its own directory ccflags-y += -I$(src)/include erofs-objs := super.o inode.o data.o namei.o dir.o +erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 74e65be6b4b5..15ed91963e79 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -10,7 +10,7 @@ * License. See the file COPYING in the main directory of the Linux * distribution for more details. */ -#include "internal.h" +#include "xattr.h" /* no locking */ static int read_inode(struct inode *inode, void *data) @@ -152,15 +152,26 @@ static int fill_inode(struct inode *inode, int isdir) if (!err) { /* setup the new inode */ if (S_ISREG(inode->i_mode)) { +#ifdef CONFIG_EROFS_FS_XATTR + if (vi->xattr_isize) + inode->i_op = &erofs_generic_xattr_iops; +#endif inode->i_fop = &generic_ro_fops; } else if (S_ISDIR(inode->i_mode)) { inode->i_op = +#ifdef CONFIG_EROFS_FS_XATTR + vi->xattr_isize ? &erofs_dir_xattr_iops : +#endif &erofs_dir_iops; inode->i_fop = &erofs_dir_fops; } else if (S_ISLNK(inode->i_mode)) { /* by default, page_get_link is used for symlink */ inode->i_op = +#ifdef CONFIG_EROFS_FS_XATTR + &erofs_symlink_xattr_iops, +#else &page_symlink_inode_operations; +#endif inode_nohighmem(inode); } else { err = -EIO; @@ -208,3 +219,23 @@ struct inode *erofs_iget(struct super_block *sb, return inode; } +#ifdef CONFIG_EROFS_FS_XATTR +const struct inode_operations erofs_generic_xattr_iops = { + .listxattr = erofs_listxattr, +}; +#endif + +#ifdef CONFIG_EROFS_FS_XATTR +const struct inode_operations erofs_symlink_xattr_iops = { + .get_link = page_get_link, + .listxattr = erofs_listxattr, +}; +#endif + +#ifdef CONFIG_EROFS_FS_XATTR +const struct inode_operations erofs_fast_symlink_xattr_iops = { + .get_link = simple_get_link, + .listxattr = erofs_listxattr, +}; +#endif + diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index d0992d2239c2..8a8caf0c1efc 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -50,6 +50,9 @@ typedef u64 erofs_nid_t; struct erofs_sb_info { u32 blocks; u32 meta_blkaddr; +#ifdef CONFIG_EROFS_FS_XATTR + u32 xattr_blkaddr; +#endif /* inode slot unit size in bit shift */ unsigned char islotbits; @@ -72,6 +75,10 @@ struct erofs_sb_info { #define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) #define EROFS_I_SB(inode) ((struct erofs_sb_info *)(inode)->i_sb->s_fs_info) +/* Mount flags set via mount options or defaults */ +#define EROFS_MOUNT_XATTR_USER 0x00000010 +#define EROFS_MOUNT_POSIX_ACL 0x00000020 + #define clear_opt(sbi, option) ((sbi)->mount_opt &= ~EROFS_MOUNT_##option) #define set_opt(sbi, option) ((sbi)->mount_opt |= EROFS_MOUNT_##option) #define test_opt(sbi, option) ((sbi)->mount_opt & EROFS_MOUNT_##option) @@ -237,17 +244,32 @@ int erofs_namei(struct inode *dir, struct qstr *name, erofs_nid_t *nid, unsigned *d_type); /* xattr.c */ +#ifdef CONFIG_EROFS_FS_XATTR extern const struct xattr_handler *erofs_xattr_handlers[]; +#endif /* symlink */ +#ifdef CONFIG_EROFS_FS_XATTR +extern const struct inode_operations erofs_symlink_xattr_iops; +extern const struct inode_operations erofs_fast_symlink_xattr_iops; +#endif + static inline void set_inode_fast_symlink(struct inode *inode) { +#ifdef CONFIG_EROFS_FS_XATTR + inode->i_op = &erofs_fast_symlink_xattr_iops; +#else inode->i_op = &simple_symlink_inode_operations; +#endif } static inline bool is_inode_fast_symlink(struct inode *inode) { +#ifdef CONFIG_EROFS_FS_XATTR + return inode->i_op == &erofs_fast_symlink_xattr_iops; +#else return inode->i_op == &simple_symlink_inode_operations; +#endif } static inline void *erofs_vmap(struct page **pages, unsigned int count) diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c index 39db643bc722..989876b15063 100644 --- a/drivers/staging/erofs/namei.c +++ b/drivers/staging/erofs/namei.c @@ -11,6 +11,7 @@ * distribution for more details. */ #include "internal.h" +#include "xattr.h" /* based on the value of qn->len is accurate */ static inline int dirnamecmp(struct qstr *qn, @@ -239,5 +240,8 @@ const struct inode_operations erofs_dir_iops = { const struct inode_operations erofs_dir_xattr_iops = { .lookup = erofs_lookup, +#ifdef CONFIG_EROFS_FS_XATTR + .listxattr = erofs_listxattr, +#endif }; diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 98ae03df30f3..4a8a2664c80b 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "internal.h" static struct kmem_cache *erofs_inode_cachep __read_mostly; @@ -107,6 +108,9 @@ static int superblock_read(struct super_block *sb) sbi->blocks = le32_to_cpu(layout->blocks); sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr); +#ifdef CONFIG_EROFS_FS_XATTR + sbi->xattr_blkaddr = le32_to_cpu(layout->xattr_blkaddr); +#endif sbi->islotbits = ffs(sizeof(struct erofs_inode_v1)) - 1; sbi->root_nid = le16_to_cpu(layout->root_nid); @@ -127,13 +131,28 @@ out: static void default_options(struct erofs_sb_info *sbi) { +#ifdef CONFIG_EROFS_FS_XATTR + set_opt(sbi, XATTR_USER); +#endif + +#ifdef CONFIG_EROFS_FS_POSIX_ACL + set_opt(sbi, POSIX_ACL); +#endif } enum { + Opt_user_xattr, + Opt_nouser_xattr, + Opt_acl, + Opt_noacl, Opt_err }; static match_table_t erofs_tokens = { + {Opt_user_xattr, "user_xattr"}, + {Opt_nouser_xattr, "nouser_xattr"}, + {Opt_acl, "acl"}, + {Opt_noacl, "noacl"}, {Opt_err, NULL} }; @@ -155,6 +174,36 @@ static int parse_options(struct super_block *sb, char *options) token = match_token(p, erofs_tokens, args); switch (token) { +#ifdef CONFIG_EROFS_FS_XATTR + case Opt_user_xattr: + set_opt(EROFS_SB(sb), XATTR_USER); + break; + case Opt_nouser_xattr: + clear_opt(EROFS_SB(sb), XATTR_USER); + break; +#else + case Opt_user_xattr: + infoln("user_xattr options not supported"); + break; + case Opt_nouser_xattr: + infoln("nouser_xattr options not supported"); + break; +#endif +#ifdef CONFIG_EROFS_FS_POSIX_ACL + case Opt_acl: + set_opt(EROFS_SB(sb), POSIX_ACL); + break; + case Opt_noacl: + clear_opt(EROFS_SB(sb), POSIX_ACL); + break; +#else + case Opt_acl: + infoln("acl options not supported"); + break; + case Opt_noacl: + infoln("noacl options not supported"); + break; +#endif default: errln("Unrecognized mount option \"%s\" " "or missing value", p); @@ -197,6 +246,10 @@ static int erofs_read_super(struct super_block *sb, sb->s_op = &erofs_sops; +#ifdef CONFIG_EROFS_FS_XATTR + sb->s_xattr = erofs_xattr_handlers; +#endif + /* set erofs default mount options */ default_options(sbi); @@ -386,6 +439,20 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf) static int erofs_show_options(struct seq_file *seq, struct dentry *root) { + struct erofs_sb_info *sbi __maybe_unused = EROFS_SB(root->d_sb); + +#ifdef CONFIG_EROFS_FS_XATTR + if (test_opt(sbi, XATTR_USER)) + seq_puts(seq, ",user_xattr"); + else + seq_puts(seq, ",nouser_xattr"); +#endif +#ifdef CONFIG_EROFS_FS_POSIX_ACL + if (test_opt(sbi, POSIX_ACL)) + seq_puts(seq, ",acl"); + else + seq_puts(seq, ",noacl"); +#endif return 0; } diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c new file mode 100644 index 000000000000..b74b314a2e3a --- /dev/null +++ b/drivers/staging/erofs/xattr.c @@ -0,0 +1,579 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/xattr.c + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include +#include "xattr.h" + +struct xattr_iter { + struct super_block *sb; + struct page *page; + void *kaddr; + + erofs_blk_t blkaddr; + unsigned ofs; +}; + +static inline void xattr_iter_end(struct xattr_iter *it, bool atomic) +{ + /* only init_inode_xattrs use non-atomic once */ + if (unlikely(!atomic)) + kunmap(it->page); + else + kunmap_atomic(it->kaddr); + unlock_page(it->page); + put_page(it->page); +} + +static void init_inode_xattrs(struct inode *inode) +{ + struct xattr_iter it; + unsigned i; + struct erofs_xattr_ibody_header *ih; + struct erofs_sb_info *sbi; + struct erofs_vnode *vi; + bool atomic_map; + + if (likely(inode_has_inited_xattr(inode))) + return; + + vi = EROFS_V(inode); + BUG_ON(!vi->xattr_isize); + + sbi = EROFS_I_SB(inode); + it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize); + it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize); + + it.page = erofs_get_inline_page(inode, it.blkaddr); + BUG_ON(IS_ERR(it.page)); + + /* read in shared xattr array (non-atomic, see kmalloc below) */ + it.kaddr = kmap(it.page); + atomic_map = false; + + ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs); + + vi->xattr_shared_count = ih->h_shared_count; + vi->xattr_shared_xattrs = (unsigned *)kmalloc_array( + vi->xattr_shared_count, sizeof(unsigned), + GFP_KERNEL | __GFP_NOFAIL); + + /* let's skip ibody header */ + it.ofs += sizeof(struct erofs_xattr_ibody_header); + + for (i = 0; i < vi->xattr_shared_count; ++i) { + if (unlikely(it.ofs >= EROFS_BLKSIZ)) { + /* cannot be unaligned */ + BUG_ON(it.ofs != EROFS_BLKSIZ); + xattr_iter_end(&it, atomic_map); + + it.page = erofs_get_meta_page(inode->i_sb, + ++it.blkaddr, S_ISDIR(inode->i_mode)); + BUG_ON(IS_ERR(it.page)); + + it.kaddr = kmap_atomic(it.page); + atomic_map = true; + it.ofs = 0; + } + vi->xattr_shared_xattrs[i] = + le32_to_cpu(*(__le32 *)(it.kaddr + it.ofs)); + it.ofs += sizeof(__le32); + } + xattr_iter_end(&it, atomic_map); + + inode_set_inited_xattr(inode); +} + +struct xattr_iter_handlers { + int (*entry)(struct xattr_iter *, struct erofs_xattr_entry *); + int (*name)(struct xattr_iter *, unsigned, char *, unsigned); + int (*alloc_buffer)(struct xattr_iter *, unsigned); + void (*value)(struct xattr_iter *, unsigned, char *, unsigned); +}; + +static void xattr_iter_fixup(struct xattr_iter *it) +{ + if (unlikely(it->ofs >= EROFS_BLKSIZ)) { + xattr_iter_end(it, true); + + it->blkaddr += erofs_blknr(it->ofs); + it->page = erofs_get_meta_page(it->sb, it->blkaddr, false); + BUG_ON(IS_ERR(it->page)); + + it->kaddr = kmap_atomic(it->page); + it->ofs = erofs_blkoff(it->ofs); + } +} + +static int inline_xattr_iter_begin(struct xattr_iter *it, + struct inode *inode) +{ + struct erofs_vnode *const vi = EROFS_V(inode); + struct erofs_sb_info *const sbi = EROFS_SB(inode->i_sb); + unsigned xattr_header_sz, inline_xattr_ofs; + + xattr_header_sz = inlinexattr_header_size(inode); + if (unlikely(xattr_header_sz >= vi->xattr_isize)) { + BUG_ON(xattr_header_sz > vi->xattr_isize); + return -ENOATTR; + } + + inline_xattr_ofs = vi->inode_isize + xattr_header_sz; + + it->blkaddr = erofs_blknr(iloc(sbi, vi->nid) + inline_xattr_ofs); + it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs); + + it->page = erofs_get_inline_page(inode, it->blkaddr); + BUG_ON(IS_ERR(it->page)); + it->kaddr = kmap_atomic(it->page); + + return vi->xattr_isize - xattr_header_sz; +} + +static int xattr_foreach(struct xattr_iter *it, + struct xattr_iter_handlers *op, unsigned *tlimit) +{ + struct erofs_xattr_entry entry; + unsigned value_sz, processed, slice; + int err; + + /* 0. fixup blkaddr, ofs, ipage */ + xattr_iter_fixup(it); + + /* + * 1. read xattr entry to the memory, + * since we do EROFS_XATTR_ALIGN + * therefore entry should be in the page + */ + entry = *(struct erofs_xattr_entry *)(it->kaddr + it->ofs); + if (tlimit != NULL) { + unsigned entry_sz = EROFS_XATTR_ENTRY_SIZE(&entry); + + BUG_ON(*tlimit < entry_sz); + *tlimit -= entry_sz; + } + + it->ofs += sizeof(struct erofs_xattr_entry); + value_sz = le16_to_cpu(entry.e_value_size); + + /* handle entry */ + err = op->entry(it, &entry); + if (err) { + it->ofs += entry.e_name_len + value_sz; + goto out; + } + + /* 2. handle xattr name (ofs will finally be at the end of name) */ + processed = 0; + + while (processed < entry.e_name_len) { + if (it->ofs >= EROFS_BLKSIZ) { + BUG_ON(it->ofs > EROFS_BLKSIZ); + + xattr_iter_fixup(it); + it->ofs = 0; + } + + slice = min_t(unsigned, PAGE_SIZE - it->ofs, + entry.e_name_len - processed); + + /* handle name */ + err = op->name(it, processed, it->kaddr + it->ofs, slice); + if (err) { + it->ofs += entry.e_name_len - processed + value_sz; + goto out; + } + + it->ofs += slice; + processed += slice; + } + + /* 3. handle xattr value */ + processed = 0; + + if (op->alloc_buffer != NULL) { + err = op->alloc_buffer(it, value_sz); + if (err) { + it->ofs += value_sz; + goto out; + } + } + + while (processed < value_sz) { + if (it->ofs >= EROFS_BLKSIZ) { + BUG_ON(it->ofs > EROFS_BLKSIZ); + xattr_iter_fixup(it); + it->ofs = 0; + } + + slice = min_t(unsigned, PAGE_SIZE - it->ofs, + value_sz - processed); + op->value(it, processed, it->kaddr + it->ofs, slice); + it->ofs += slice; + processed += slice; + } + +out: + /* we assume that ofs is aligned with 4 bytes */ + it->ofs = EROFS_XATTR_ALIGN(it->ofs); + return err; +} + +struct getxattr_iter { + struct xattr_iter it; + + char *buffer; + int buffer_size, index; + struct qstr name; +}; + +static int xattr_entrymatch(struct xattr_iter *_it, + struct erofs_xattr_entry *entry) +{ + struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); + + return (it->index != entry->e_name_index || + it->name.len != entry->e_name_len) ? -ENOATTR : 0; +} + +static int xattr_namematch(struct xattr_iter *_it, + unsigned processed, char *buf, unsigned len) +{ + struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); + + return memcmp(buf, it->name.name + processed, len) ? -ENOATTR : 0; +} + +static int xattr_checkbuffer(struct xattr_iter *_it, + unsigned value_sz) +{ + struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); + int err = it->buffer_size < value_sz ? -ERANGE : 0; + + it->buffer_size = value_sz; + return it->buffer == NULL ? 1 : err; +} + +static void xattr_copyvalue(struct xattr_iter *_it, + unsigned processed, char *buf, unsigned len) +{ + struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); + + memcpy(it->buffer + processed, buf, len); +} + +static struct xattr_iter_handlers find_xattr_handlers = { + .entry = xattr_entrymatch, + .name = xattr_namematch, + .alloc_buffer = xattr_checkbuffer, + .value = xattr_copyvalue +}; + +static int inline_getxattr(struct inode *inode, struct getxattr_iter *it) +{ + int ret; + unsigned remaining; + + ret = inline_xattr_iter_begin(&it->it, inode); + if (ret < 0) + return ret; + + remaining = ret; + while (remaining) { + if ((ret = xattr_foreach(&it->it, + &find_xattr_handlers, &remaining)) >= 0) + break; + } + xattr_iter_end(&it->it, true); + + return ret < 0 ? ret : it->buffer_size; +} + +static int shared_getxattr(struct inode *inode, struct getxattr_iter *it) +{ + struct erofs_vnode *const vi = EROFS_V(inode); + struct erofs_sb_info *const sbi = EROFS_SB(inode->i_sb); + unsigned i; + int ret = -ENOATTR; + + for (i = 0; i < vi->xattr_shared_count; ++i) { + erofs_blk_t blkaddr = + xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]); + + it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]); + + if (!i || blkaddr != it->it.blkaddr) { + if (i) + xattr_iter_end(&it->it, true); + + it->it.page = erofs_get_meta_page(inode->i_sb, + blkaddr, false); + BUG_ON(IS_ERR(it->it.page)); + it->it.kaddr = kmap_atomic(it->it.page); + it->it.blkaddr = blkaddr; + } + + if ((ret = xattr_foreach(&it->it, + &find_xattr_handlers, NULL)) >= 0) + break; + } + if (vi->xattr_shared_count) + xattr_iter_end(&it->it, true); + + return ret < 0 ? ret : it->buffer_size; +} + +static bool erofs_xattr_user_list(struct dentry *dentry) +{ + return test_opt(EROFS_SB(dentry->d_sb), XATTR_USER); +} + +static bool erofs_xattr_trusted_list(struct dentry *dentry) +{ + return capable(CAP_SYS_ADMIN); +} + +int erofs_getxattr(struct inode *inode, int index, + const char *name, + void *buffer, size_t buffer_size) +{ + int ret; + struct getxattr_iter it; + + if (unlikely(name == NULL)) + return -EINVAL; + + init_inode_xattrs(inode); + + it.index = index; + + it.name.len = strlen(name); + if (it.name.len > EROFS_NAME_LEN) + return -ERANGE; + it.name.name = name; + + it.buffer = buffer; + it.buffer_size = buffer_size; + + it.it.sb = inode->i_sb; + ret = inline_getxattr(inode, &it); + if (ret == -ENOATTR) + ret = shared_getxattr(inode, &it); + return ret; +} + +static int erofs_xattr_generic_get(const struct xattr_handler *handler, + struct dentry *unused, struct inode *inode, + const char *name, void *buffer, size_t size) +{ + struct erofs_vnode *const vi = EROFS_V(inode); + struct erofs_sb_info *const sbi = EROFS_I_SB(inode); + + switch (handler->flags) { + case EROFS_XATTR_INDEX_USER: + if (!test_opt(sbi, XATTR_USER)) + return -EOPNOTSUPP; + break; + case EROFS_XATTR_INDEX_TRUSTED: + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + break; + case EROFS_XATTR_INDEX_SECURITY: + break; + default: + return -EINVAL; + } + + if (!vi->xattr_isize) + return -ENOATTR; + + return erofs_getxattr(inode, handler->flags, name, buffer, size); +} + +const struct xattr_handler erofs_xattr_user_handler = { + .prefix = XATTR_USER_PREFIX, + .flags = EROFS_XATTR_INDEX_USER, + .list = erofs_xattr_user_list, + .get = erofs_xattr_generic_get, +}; + +const struct xattr_handler erofs_xattr_trusted_handler = { + .prefix = XATTR_TRUSTED_PREFIX, + .flags = EROFS_XATTR_INDEX_TRUSTED, + .list = erofs_xattr_trusted_list, + .get = erofs_xattr_generic_get, +}; + +#ifdef CONFIG_EROFS_FS_SECURITY +const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { + .prefix = XATTR_SECURITY_PREFIX, + .flags = EROFS_XATTR_INDEX_SECURITY, + .get = erofs_xattr_generic_get, +}; +#endif + +#ifdef CONFIG_EROFS_FS_XATTR +const struct xattr_handler *erofs_xattr_handlers[] = { + &erofs_xattr_user_handler, +#ifdef CONFIG_EROFS_FS_POSIX_ACL + &posix_acl_access_xattr_handler, + &posix_acl_default_xattr_handler, +#endif + &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + &erofs_xattr_security_handler, +#endif + NULL, +}; +#endif + +struct listxattr_iter { + struct xattr_iter it; + + struct dentry *dentry; + char *buffer; + int buffer_size, buffer_ofs; +}; + +static int xattr_entrylist(struct xattr_iter *_it, + struct erofs_xattr_entry *entry) +{ + struct listxattr_iter *it = + container_of(_it, struct listxattr_iter, it); + unsigned prefix_len; + const char *prefix; + + const struct xattr_handler *h = + erofs_xattr_handler(entry->e_name_index); + + if (h == NULL || (h->list != NULL && !h->list(it->dentry))) + return 1; + + /* Note that at least one of 'prefix' and 'name' should be non-NULL */ + prefix = h->prefix != NULL ? h->prefix : h->name; + prefix_len = strlen(prefix); + + if (it->buffer == NULL) { + it->buffer_ofs += prefix_len + entry->e_name_len + 1; + return 1; + } + + if (it->buffer_ofs + prefix_len + + entry->e_name_len + 1 > it->buffer_size) + return -ERANGE; + + memcpy(it->buffer + it->buffer_ofs, prefix, prefix_len); + it->buffer_ofs += prefix_len; + return 0; +} + +static int xattr_namelist(struct xattr_iter *_it, + unsigned processed, char *buf, unsigned len) +{ + struct listxattr_iter *it = + container_of(_it, struct listxattr_iter, it); + + memcpy(it->buffer + it->buffer_ofs, buf, len); + it->buffer_ofs += len; + return 0; +} + +static int xattr_skipvalue(struct xattr_iter *_it, + unsigned value_sz) +{ + struct listxattr_iter *it = + container_of(_it, struct listxattr_iter, it); + + it->buffer[it->buffer_ofs++] = '\0'; + return 1; +} + +static struct xattr_iter_handlers list_xattr_handlers = { + .entry = xattr_entrylist, + .name = xattr_namelist, + .alloc_buffer = xattr_skipvalue, + .value = NULL +}; + +static int inline_listxattr(struct listxattr_iter *it) +{ + int ret; + unsigned remaining; + + ret = inline_xattr_iter_begin(&it->it, d_inode(it->dentry)); + if (ret < 0) + return ret; + + remaining = ret; + while (remaining) { + if ((ret = xattr_foreach(&it->it, + &list_xattr_handlers, &remaining)) < 0) + break; + } + xattr_iter_end(&it->it, true); + return ret < 0 ? ret : it->buffer_ofs; +} + +static int shared_listxattr(struct listxattr_iter *it) +{ + struct inode *const inode = d_inode(it->dentry); + struct erofs_vnode *const vi = EROFS_V(inode); + struct erofs_sb_info *const sbi = EROFS_I_SB(inode); + unsigned i; + int ret = 0; + + for (i = 0; i < vi->xattr_shared_count; ++i) { + erofs_blk_t blkaddr = + xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]); + + it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]); + if (!i || blkaddr != it->it.blkaddr) { + if (i) + xattr_iter_end(&it->it, true); + + it->it.page = erofs_get_meta_page(inode->i_sb, + blkaddr, false); + BUG_ON(IS_ERR(it->it.page)); + it->it.kaddr = kmap_atomic(it->it.page); + it->it.blkaddr = blkaddr; + } + + if ((ret = xattr_foreach(&it->it, + &list_xattr_handlers, NULL)) < 0) + break; + } + if (vi->xattr_shared_count) + xattr_iter_end(&it->it, true); + + return ret < 0 ? ret : it->buffer_ofs; +} + +ssize_t erofs_listxattr(struct dentry *dentry, + char *buffer, size_t buffer_size) +{ + int ret; + struct listxattr_iter it; + + init_inode_xattrs(d_inode(dentry)); + + it.dentry = dentry; + it.buffer = buffer; + it.buffer_size = buffer_size; + it.buffer_ofs = 0; + + it.it.sb = dentry->d_sb; + + ret = inline_listxattr(&it); + if (ret < 0 && ret != -ENOATTR) + return ret; + return shared_listxattr(&it); +} + diff --git a/drivers/staging/erofs/xattr.h b/drivers/staging/erofs/xattr.h new file mode 100644 index 000000000000..0c7379282fc5 --- /dev/null +++ b/drivers/staging/erofs/xattr.h @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * linux/drivers/staging/erofs/xattr.h + * + * Copyright (C) 2017-2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#ifndef __EROFS_XATTR_H +#define __EROFS_XATTR_H + +#include "internal.h" +#include +#include + +/* Attribute not found */ +#define ENOATTR ENODATA + +static inline unsigned inlinexattr_header_size(struct inode *inode) +{ + return sizeof(struct erofs_xattr_ibody_header) + + sizeof(u32) * EROFS_V(inode)->xattr_shared_count; +} + +static inline erofs_blk_t +xattrblock_addr(struct erofs_sb_info *sbi, unsigned xattr_id) +{ +#ifdef CONFIG_EROFS_FS_XATTR + return sbi->xattr_blkaddr + + xattr_id * sizeof(__u32) / EROFS_BLKSIZ; +#else + return 0; +#endif +} + +static inline unsigned +xattrblock_offset(struct erofs_sb_info *sbi, unsigned xattr_id) +{ + return (xattr_id * sizeof(__u32)) % EROFS_BLKSIZ; +} + +extern const struct xattr_handler erofs_xattr_user_handler; +extern const struct xattr_handler erofs_xattr_trusted_handler; +#ifdef CONFIG_EROFS_FS_SECURITY +extern const struct xattr_handler erofs_xattr_security_handler; +#endif + +static inline const struct xattr_handler *erofs_xattr_handler(unsigned index) +{ +static const struct xattr_handler *xattr_handler_map[] = { + [EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler, +#ifdef CONFIG_EROFS_FS_POSIX_ACL + [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, + [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] = + &posix_acl_default_xattr_handler, +#endif + [EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + [EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler, +#endif +}; + return index && index < ARRAY_SIZE(xattr_handler_map) ? + xattr_handler_map[index] : NULL; +} + +#ifdef CONFIG_EROFS_FS_XATTR + +extern const struct inode_operations erofs_generic_xattr_iops; +extern const struct inode_operations erofs_dir_xattr_iops; + +int erofs_getxattr(struct inode *, int, const char *, void *, size_t); +ssize_t erofs_listxattr(struct dentry *, char *, size_t); +#else +static int __maybe_unused erofs_getxattr(struct inode *inode, int index, + const char *name, + void *buffer, size_t buffer_size) +{ + return -ENOTSUPP; +} + +static ssize_t __maybe_unused erofs_listxattr(struct dentry *dentry, + char *buffer, size_t buffer_size) +{ + return -ENOTSUPP; +} +#endif + +#endif + From d5beb31b6b1c0a3f7b30611c6d4b888f8d4137dd Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Thu, 26 Jul 2018 20:21:53 +0800 Subject: [PATCH 607/903] staging: erofs: support special inode This patch adds to support special inode, such as block dev, char, socket, pipe inode. Reviewed-by: Gao Xiang Signed-off-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 36 ++++++++++++++++++++++++++++++-- drivers/staging/erofs/internal.h | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 15ed91963e79..c01181153d90 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -34,8 +34,18 @@ static int read_inode(struct inode *inode, void *data) vi->inode_isize = sizeof(struct erofs_inode_v2); vi->xattr_isize = ondisk_xattr_ibody_size(v2->i_xattr_icount); - vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr); inode->i_mode = le16_to_cpu(v2->i_mode); + if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || + S_ISLNK(inode->i_mode)) { + vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr); + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { + inode->i_rdev = + new_decode_dev(le32_to_cpu(v2->i_u.rdev)); + } else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { + inode->i_rdev = 0; + } else { + return -EIO; + } i_uid_write(inode, le32_to_cpu(v2->i_uid)); i_gid_write(inode, le32_to_cpu(v2->i_gid)); @@ -54,8 +64,18 @@ static int read_inode(struct inode *inode, void *data) vi->inode_isize = sizeof(struct erofs_inode_v1); vi->xattr_isize = ondisk_xattr_ibody_size(v1->i_xattr_icount); - vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr); inode->i_mode = le16_to_cpu(v1->i_mode); + if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || + S_ISLNK(inode->i_mode)) { + vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr); + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { + inode->i_rdev = + new_decode_dev(le32_to_cpu(v1->i_u.rdev)); + } else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { + inode->i_rdev = 0; + } else { + return -EIO; + } i_uid_write(inode, le16_to_cpu(v1->i_uid)); i_gid_write(inode, le16_to_cpu(v1->i_gid)); @@ -173,6 +193,12 @@ static int fill_inode(struct inode *inode, int isdir) &page_symlink_inode_operations; #endif inode_nohighmem(inode); + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { +#ifdef CONFIG_EROFS_FS_XATTR + inode->i_op = &erofs_special_inode_operations; +#endif + init_special_inode(inode, inode->i_mode, inode->i_rdev); } else { err = -EIO; goto out_unlock; @@ -232,6 +258,12 @@ const struct inode_operations erofs_symlink_xattr_iops = { }; #endif +const struct inode_operations erofs_special_inode_operations = { +#ifdef CONFIG_EROFS_FS_XATTR + .listxattr = erofs_listxattr, +#endif +}; + #ifdef CONFIG_EROFS_FS_XATTR const struct inode_operations erofs_fast_symlink_xattr_iops = { .get_link = simple_get_link, diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 8a8caf0c1efc..5862705c5cae 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -252,6 +252,7 @@ extern const struct xattr_handler *erofs_xattr_handlers[]; #ifdef CONFIG_EROFS_FS_XATTR extern const struct inode_operations erofs_symlink_xattr_iops; extern const struct inode_operations erofs_fast_symlink_xattr_iops; +extern const struct inode_operations erofs_special_inode_operations; #endif static inline void set_inode_fast_symlink(struct inode *inode) From 9c07b3b39dc7720a9427e5561cc730fa28b92cc2 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Thu, 26 Jul 2018 20:21:54 +0800 Subject: [PATCH 608/903] staging: erofs: introduce error injection infrastructure This patch introduces error injection infrastructure, with it, we can inject error in any kernel exported common functions which erofs used, so that it can force erofs running into error paths, it turns out that tests can cover real rare paths more easily to find bugs. Reviewed-by: Gao Xiang Signed-off-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Kconfig | 6 ++++ drivers/staging/erofs/inode.c | 3 +- drivers/staging/erofs/internal.h | 57 ++++++++++++++++++++++++++++++++ drivers/staging/erofs/super.c | 38 +++++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index 1a5ec1bb5cda..edda055b3c64 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig @@ -71,3 +71,9 @@ config EROFS_FS_USE_VM_MAP_RAM If you don't know what these are, say N. +config EROFS_FAULT_INJECTION + bool "EROFS fault injection facility" + depends on EROFS_FS + help + Test EROFS to inject faults such as ENOMEM, EIO, and so on. + If unsure, say N. diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index c01181153d90..a6d3e129708e 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -113,6 +113,7 @@ static int read_inode(struct inode *inode, void *data) static int fill_inline_data(struct inode *inode, void *data, unsigned m_pofs) { struct erofs_vnode *vi = EROFS_V(inode); + struct erofs_sb_info *sbi = EROFS_I_SB(inode); int mode = vi->data_mapping_mode; DBG_BUGON(mode >= EROFS_INODE_LAYOUT_MAX); @@ -123,7 +124,7 @@ static int fill_inline_data(struct inode *inode, void *data, unsigned m_pofs) /* fast symlink (following ext4) */ if (S_ISLNK(inode->i_mode) && inode->i_size < PAGE_SIZE) { - char *lnk = kmalloc(inode->i_size + 1, GFP_KERNEL); + char *lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL); if (unlikely(lnk == NULL)) return -ENOMEM; diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 5862705c5cae..ca224866282f 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -42,6 +42,22 @@ #define DBG_BUGON(...) ((void)0) #endif +#ifdef CONFIG_EROFS_FAULT_INJECTION +enum { + FAULT_KMALLOC, + FAULT_MAX, +}; + +extern char *erofs_fault_name[FAULT_MAX]; +#define IS_FAULT_SET(fi, type) ((fi)->inject_type & (1 << (type))) + +struct erofs_fault_info { + atomic_t inject_ops; + unsigned int inject_rate; + unsigned int inject_type; +}; +#endif + /* EROFS_SUPER_MAGIC_V1 to represent the whole file system */ #define EROFS_SUPER_MAGIC EROFS_SUPER_MAGIC_V1 @@ -70,14 +86,55 @@ struct erofs_sb_info { char *dev_name; unsigned int mount_opt; + +#ifdef CONFIG_EROFS_FAULT_INJECTION + struct erofs_fault_info fault_info; /* For fault injection */ +#endif }; +#ifdef CONFIG_EROFS_FAULT_INJECTION +#define erofs_show_injection_info(type) \ + infoln("inject %s in %s of %pS", erofs_fault_name[type], \ + __func__, __builtin_return_address(0)) + +static inline bool time_to_inject(struct erofs_sb_info *sbi, int type) +{ + struct erofs_fault_info *ffi = &sbi->fault_info; + + if (!ffi->inject_rate) + return false; + + if (!IS_FAULT_SET(ffi, type)) + return false; + + atomic_inc(&ffi->inject_ops); + if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) { + atomic_set(&ffi->inject_ops, 0); + return true; + } + return false; +} +#endif + +static inline void *erofs_kmalloc(struct erofs_sb_info *sbi, + size_t size, gfp_t flags) +{ +#ifdef CONFIG_EROFS_FAULT_INJECTION + if (time_to_inject(sbi, FAULT_KMALLOC)) { + erofs_show_injection_info(FAULT_KMALLOC); + return NULL; + } +#endif + return kmalloc(size, flags); +} + #define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) #define EROFS_I_SB(inode) ((struct erofs_sb_info *)(inode)->i_sb->s_fs_info) /* Mount flags set via mount options or defaults */ #define EROFS_MOUNT_XATTR_USER 0x00000010 #define EROFS_MOUNT_POSIX_ACL 0x00000020 +#define EROFS_MOUNT_FAULT_INJECTION 0x00000040 #define clear_opt(sbi, option) ((sbi)->mount_opt &= ~EROFS_MOUNT_##option) #define set_opt(sbi, option) ((sbi)->mount_opt |= EROFS_MOUNT_##option) diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 4a8a2664c80b..701425fed049 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -129,6 +129,26 @@ out: return ret; } +#ifdef CONFIG_EROFS_FAULT_INJECTION +char *erofs_fault_name[FAULT_MAX] = { + [FAULT_KMALLOC] = "kmalloc", +}; + +static void erofs_build_fault_attr(struct erofs_sb_info *sbi, + unsigned int rate) +{ + struct erofs_fault_info *ffi = &sbi->fault_info; + + if (rate) { + atomic_set(&ffi->inject_ops, 0); + ffi->inject_rate = rate; + ffi->inject_type = (1 << FAULT_MAX) - 1; + } else { + memset(ffi, 0, sizeof(struct erofs_fault_info)); + } +} +#endif + static void default_options(struct erofs_sb_info *sbi) { #ifdef CONFIG_EROFS_FS_XATTR @@ -145,6 +165,7 @@ enum { Opt_nouser_xattr, Opt_acl, Opt_noacl, + Opt_fault_injection, Opt_err }; @@ -153,6 +174,7 @@ static match_table_t erofs_tokens = { {Opt_nouser_xattr, "nouser_xattr"}, {Opt_acl, "acl"}, {Opt_noacl, "noacl"}, + {Opt_fault_injection, "fault_injection=%u"}, {Opt_err, NULL} }; @@ -160,6 +182,7 @@ static int parse_options(struct super_block *sb, char *options) { substring_t args[MAX_OPT_ARGS]; char *p; + int arg = 0; if (!options) return 0; @@ -204,6 +227,16 @@ static int parse_options(struct super_block *sb, char *options) infoln("noacl options not supported"); break; #endif + case Opt_fault_injection: + if (args->from && match_int(args, &arg)) + return -EINVAL; +#ifdef CONFIG_EROFS_FAULT_INJECTION + erofs_build_fault_attr(EROFS_SB(sb), arg); + set_opt(EROFS_SB(sb), FAULT_INJECTION); +#else + infoln("FAULT_INJECTION was not selected"); +#endif + break; default: errln("Unrecognized mount option \"%s\" " "or missing value", p); @@ -452,6 +485,11 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root) seq_puts(seq, ",acl"); else seq_puts(seq, ",noacl"); +#endif +#ifdef CONFIG_EROFS_FAULT_INJECTION + if (test_opt(sbi, FAULT_INJECTION)) + seq_printf(seq, ",fault_injection=%u", + sbi->fault_info.inject_rate); #endif return 0; } From 13f06f48f7bf8ebfa443e9496d382fa3d20b9ff3 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Thu, 26 Jul 2018 20:21:55 +0800 Subject: [PATCH 609/903] staging: erofs: support tracepoint Add basic tracepoints for ->readpage{,s}, ->lookup, ->destroy_inode, fill_inode and map_blocks. Reviewed-by: Gao Xiang Signed-off-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/data.c | 13 +- .../erofs/include/trace/events/erofs.h | 240 ++++++++++++++++++ drivers/staging/erofs/inode.c | 4 + drivers/staging/erofs/namei.c | 4 + drivers/staging/erofs/super.c | 3 + 5 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 drivers/staging/erofs/include/trace/events/erofs.h diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 4ddb5c086b44..47d1787e99ef 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -13,6 +13,8 @@ #include "internal.h" #include +#include + static inline void read_endio(struct bio *bio) { int i; @@ -113,6 +115,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode, u64 offset = map->m_la; struct erofs_vnode *vi = EROFS_V(inode); + trace_erofs_map_blocks_flatmode_enter(inode, map, flags); BUG_ON(is_inode_layout_compression(inode)); nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE); @@ -150,8 +153,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode, out: map->m_llen = map->m_plen; - debugln("%s, m_la 0x%llx m_pa %llx m_len %llu", - __func__, map->m_la, map->m_pa, map->m_plen); + trace_erofs_map_blocks_flatmode_exit(inode, map, flags, 0); return 0; } @@ -305,6 +307,8 @@ static int erofs_raw_access_readpage(struct file *file, struct page *page) erofs_off_t last_block; struct bio *bio; + trace_erofs_readpage(page, true); + bio = erofs_read_raw_page(NULL, page->mapping, page, &last_block, 1, false); @@ -322,9 +326,12 @@ static int erofs_raw_access_readpages(struct file *filp, erofs_off_t last_block; struct bio *bio = NULL; gfp_t gfp = readahead_gfp_mask(mapping); + struct page *page = list_last_entry(pages, struct page, lru); + + trace_erofs_readpages(mapping->host, page, nr_pages, true); for (; nr_pages; --nr_pages) { - struct page *page = list_entry(pages->prev, struct page, lru); + page = list_entry(pages->prev, struct page, lru); prefetchw(&page->flags); list_del(&page->lru); diff --git a/drivers/staging/erofs/include/trace/events/erofs.h b/drivers/staging/erofs/include/trace/events/erofs.h new file mode 100644 index 000000000000..5aead93a762f --- /dev/null +++ b/drivers/staging/erofs/include/trace/events/erofs.h @@ -0,0 +1,240 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM erofs + +#if !defined(_TRACE_EROFS_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_EROFS_H + +#include + +#define show_dev(dev) MAJOR(dev), MINOR(dev) +#define show_dev_nid(entry) show_dev(entry->dev), entry->nid + +#define show_file_type(type) \ + __print_symbolic(type, \ + { 0, "FILE" }, \ + { 1, "DIR" }) + +#define show_map_flags(flags) __print_flags(flags, "|", \ + { EROFS_GET_BLOCKS_RAW, "RAW" }) + +#define show_mflags(flags) __print_flags(flags, "", \ + { EROFS_MAP_MAPPED, "M" }, \ + { EROFS_MAP_META, "I" }, \ + { EROFS_MAP_ZIPPED, "Z" }) + +TRACE_EVENT(erofs_lookup, + + TP_PROTO(struct inode *dir, struct dentry *dentry, unsigned int flags), + + TP_ARGS(dir, dentry, flags), + + TP_STRUCT__entry( + __field(dev_t, dev ) + __field(erofs_nid_t, nid ) + __field(const char *, name ) + __field(unsigned int, flags ) + ), + + TP_fast_assign( + __entry->dev = dir->i_sb->s_dev; + __entry->nid = EROFS_V(dir)->nid; + __entry->name = dentry->d_name.name; + __entry->flags = flags; + ), + + TP_printk("dev = (%d,%d), pnid = %llu, name:%s, flags:%x", + show_dev_nid(__entry), + __entry->name, + __entry->flags) +); + +TRACE_EVENT(erofs_fill_inode, + TP_PROTO(struct inode *inode, int isdir), + TP_ARGS(inode, isdir), + + TP_STRUCT__entry( + __field(dev_t, dev ) + __field(erofs_nid_t, nid ) + __field(erofs_blk_t, blkaddr ) + __field(unsigned int, ofs ) + __field(int, isdir ) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->nid = EROFS_V(inode)->nid; + __entry->blkaddr = erofs_blknr(iloc(EROFS_I_SB(inode), __entry->nid)); + __entry->ofs = erofs_blkoff(iloc(EROFS_I_SB(inode), __entry->nid)); + __entry->isdir = isdir; + ), + + TP_printk("dev = (%d,%d), nid = %llu, blkaddr %u ofs %u, isdir %d", + show_dev_nid(__entry), + __entry->blkaddr, __entry->ofs, + __entry->isdir) +); + +TRACE_EVENT(erofs_readpage, + + TP_PROTO(struct page *page, bool raw), + + TP_ARGS(page, raw), + + TP_STRUCT__entry( + __field(dev_t, dev ) + __field(erofs_nid_t, nid ) + __field(int, dir ) + __field(pgoff_t, index ) + __field(int, uptodate) + __field(bool, raw ) + ), + + TP_fast_assign( + __entry->dev = page->mapping->host->i_sb->s_dev; + __entry->nid = EROFS_V(page->mapping->host)->nid; + __entry->dir = S_ISDIR(page->mapping->host->i_mode); + __entry->index = page->index; + __entry->uptodate = PageUptodate(page); + __entry->raw = raw; + ), + + TP_printk("dev = (%d,%d), nid = %llu, %s, index = %lu, uptodate = %d " + "raw = %d", + show_dev_nid(__entry), + show_file_type(__entry->dir), + (unsigned long)__entry->index, + __entry->uptodate, + __entry->raw) +); + +TRACE_EVENT(erofs_readpages, + + TP_PROTO(struct inode *inode, struct page *page, unsigned int nrpage, + bool raw), + + TP_ARGS(inode, page, nrpage, raw), + + TP_STRUCT__entry( + __field(dev_t, dev ) + __field(erofs_nid_t, nid ) + __field(pgoff_t, start ) + __field(unsigned int, nrpage ) + __field(bool, raw ) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->nid = EROFS_V(inode)->nid; + __entry->start = page->index; + __entry->nrpage = nrpage; + __entry->raw = raw; + ), + + TP_printk("dev = (%d,%d), nid = %llu, start = %lu nrpage = %u raw = %d", + show_dev_nid(__entry), + (unsigned long)__entry->start, + __entry->nrpage, + __entry->raw) +); + +DECLARE_EVENT_CLASS(erofs__map_blocks_enter, + TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, + unsigned int flags), + + TP_ARGS(inode, map, flags), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field( erofs_nid_t, nid ) + __field( erofs_off_t, la ) + __field( u64, llen ) + __field( unsigned int, flags ) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->nid = EROFS_V(inode)->nid; + __entry->la = map->m_la; + __entry->llen = map->m_llen; + __entry->flags = flags; + ), + + TP_printk("dev = (%d,%d), nid = %llu, la %llu llen %llu flags %s", + show_dev_nid(__entry), + __entry->la, __entry->llen, show_map_flags(__entry->flags)) +); + +DEFINE_EVENT(erofs__map_blocks_enter, erofs_map_blocks_flatmode_enter, + TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, + unsigned flags), + + TP_ARGS(inode, map, flags) +); + +DECLARE_EVENT_CLASS(erofs__map_blocks_exit, + TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, + unsigned int flags, int ret), + + TP_ARGS(inode, map, flags, ret), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field( erofs_nid_t, nid ) + __field( unsigned int, flags ) + __field( erofs_off_t, la ) + __field( erofs_off_t, pa ) + __field( u64, llen ) + __field( u64, plen ) + __field( unsigned int, mflags ) + __field( int, ret ) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->nid = EROFS_V(inode)->nid; + __entry->flags = flags; + __entry->la = map->m_la; + __entry->pa = map->m_pa; + __entry->llen = map->m_llen; + __entry->plen = map->m_plen; + __entry->mflags = map->m_flags; + __entry->ret = ret; + ), + + TP_printk("dev = (%d,%d), nid = %llu, flags %s " + "la %llu pa %llu llen %llu plen %llu mflags %s ret %d", + show_dev_nid(__entry), show_map_flags(__entry->flags), + __entry->la, __entry->pa, __entry->llen, __entry->plen, + show_mflags(__entry->mflags), __entry->ret) +); + +DEFINE_EVENT(erofs__map_blocks_exit, erofs_map_blocks_flatmode_exit, + TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, + unsigned flags, int ret), + + TP_ARGS(inode, map, flags, ret) +); + +TRACE_EVENT(erofs_destroy_inode, + TP_PROTO(struct inode *inode), + + TP_ARGS(inode), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field( erofs_nid_t, nid ) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->nid = EROFS_V(inode)->nid; + ), + + TP_printk("dev = (%d,%d), nid = %llu", show_dev_nid(__entry)) +); + +#endif /* _TRACE_EROFS_H */ + + /* This part must be outside protection */ +#include diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index a6d3e129708e..613c9771bd14 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -12,6 +12,8 @@ */ #include "xattr.h" +#include + /* no locking */ static int read_inode(struct inode *inode, void *data) { @@ -152,6 +154,8 @@ static int fill_inode(struct inode *inode, int isdir) erofs_blk_t blkaddr; unsigned ofs; + trace_erofs_fill_inode(inode, isdir); + blkaddr = erofs_blknr(iloc(sbi, vi->nid)); ofs = erofs_blkoff(iloc(sbi, vi->nid)); diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c index 989876b15063..d2a0da3b1e44 100644 --- a/drivers/staging/erofs/namei.c +++ b/drivers/staging/erofs/namei.c @@ -13,6 +13,8 @@ #include "internal.h" #include "xattr.h" +#include + /* based on the value of qn->len is accurate */ static inline int dirnamecmp(struct qstr *qn, struct qstr *qd, unsigned *matched) @@ -209,6 +211,8 @@ static struct dentry *erofs_lookup(struct inode *dir, /* dentry must be unhashed in lookup, no need to worry about */ DBG_BUGON(!d_unhashed(dentry)); + trace_erofs_lookup(dir, dentry, flags); + /* file name exceeds fs limit */ if (unlikely(dentry->d_name.len > EROFS_NAME_LEN)) return ERR_PTR(-ENAMETOOLONG); diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 701425fed049..054375d6ecce 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -17,6 +17,9 @@ #include #include "internal.h" +#define CREATE_TRACE_POINTS +#include + static struct kmem_cache *erofs_inode_cachep __read_mostly; static void init_once(void *ptr) From b8b58b3280b376d55f4e90f8d28904deb2dc1d5c Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:56 +0800 Subject: [PATCH 610/903] staging: erofs: : introduce tagged pointer Currently kernel has scattered tagged pointer usages hacked by hand in plain code, without a unique and portable functionset to highlight the tagged pointer itself and wrap these hacked code in order to clean up all over meaningless magic masks. Therefore, this patch introduces simple generic methods to fold tags into a pointer integer. It currently supports the last n bits of the pointer for tags, which can be selected by users. In addition, it will also be used for the upcoming EROFS filesystem, which heavily uses tagged pointer approach for high performance and reducing extra memory allocation. Link: https://en.wikipedia.org/wiki/Tagged_pointer Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/include/linux/tagptr.h | 110 +++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 drivers/staging/erofs/include/linux/tagptr.h diff --git a/drivers/staging/erofs/include/linux/tagptr.h b/drivers/staging/erofs/include/linux/tagptr.h new file mode 100644 index 000000000000..ccd106dbd48e --- /dev/null +++ b/drivers/staging/erofs/include/linux/tagptr.h @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Tagged pointer implementation + * + * Copyright (C) 2018 Gao Xiang + */ +#ifndef _LINUX_TAGPTR_H +#define _LINUX_TAGPTR_H + +#include +#include + +/* + * the name of tagged pointer types are tagptr{1, 2, 3...}_t + * avoid directly using the internal structs __tagptr{1, 2, 3...} + */ +#define __MAKE_TAGPTR(n) \ +typedef struct __tagptr##n { \ + uintptr_t v; \ +} tagptr##n##_t; + +__MAKE_TAGPTR(1) +__MAKE_TAGPTR(2) +__MAKE_TAGPTR(3) +__MAKE_TAGPTR(4) + +#undef __MAKE_TAGPTR + +extern void __compiletime_error("bad tagptr tags") + __bad_tagptr_tags(void); + +extern void __compiletime_error("bad tagptr type") + __bad_tagptr_type(void); + +/* fix the broken usage of "#define tagptr2_t tagptr3_t" by users */ +#define __tagptr_mask_1(ptr, n) \ + __builtin_types_compatible_p(typeof(ptr), struct __tagptr##n) ? \ + (1UL << (n)) - 1 : + +#define __tagptr_mask(ptr) (\ + __tagptr_mask_1(ptr, 1) ( \ + __tagptr_mask_1(ptr, 2) ( \ + __tagptr_mask_1(ptr, 3) ( \ + __tagptr_mask_1(ptr, 4) ( \ + __bad_tagptr_type(), 0))))) + +/* generate a tagged pointer from a raw value */ +#define tagptr_init(type, val) \ + ((typeof(type)){ .v = (uintptr_t)(val) }) + +/* + * directly cast a tagged pointer to the native pointer type, which + * could be used for backward compatibility of existing code. + */ +#define tagptr_cast_ptr(tptr) ((void *)(tptr).v) + +/* encode tagged pointers */ +#define tagptr_fold(type, ptr, _tags) ({ \ + const typeof(_tags) tags = (_tags); \ + if (__builtin_constant_p(tags) && (tags & ~__tagptr_mask(type))) \ + __bad_tagptr_tags(); \ +tagptr_init(type, (uintptr_t)(ptr) | tags); }) + +/* decode tagged pointers */ +#define tagptr_unfold_ptr(tptr) \ + ((void *)((tptr).v & ~__tagptr_mask(tptr))) + +#define tagptr_unfold_tags(tptr) \ + ((tptr).v & __tagptr_mask(tptr)) + +/* operations for the tagger pointer */ +#define tagptr_eq(_tptr1, _tptr2) ({ \ + typeof(_tptr1) tptr1 = (_tptr1); \ + typeof(_tptr2) tptr2 = (_tptr2); \ + (void)(&tptr1 == &tptr2); \ +(tptr1).v == (tptr2).v; }) + +/* lock-free CAS operation */ +#define tagptr_cmpxchg(_ptptr, _o, _n) ({ \ + typeof(_ptptr) ptptr = (_ptptr); \ + typeof(_o) o = (_o); \ + typeof(_n) n = (_n); \ + (void)(&o == &n); \ + (void)(&o == ptptr); \ +tagptr_init(o, cmpxchg(&ptptr->v, o.v, n.v)); }) + +/* wrap WRITE_ONCE if atomic update is needed */ +#define tagptr_replace_tags(_ptptr, tags) ({ \ + typeof(_ptptr) ptptr = (_ptptr); \ + *ptptr = tagptr_fold(*ptptr, tagptr_unfold_ptr(*ptptr), tags); \ +*ptptr; }) + +#define tagptr_set_tags(_ptptr, _tags) ({ \ + typeof(_ptptr) ptptr = (_ptptr); \ + const typeof(_tags) tags = (_tags); \ + if (__builtin_constant_p(tags) && (tags & ~__tagptr_mask(*ptptr))) \ + __bad_tagptr_tags(); \ + ptptr->v |= tags; \ +*ptptr; }) + +#define tagptr_clear_tags(_ptptr, _tags) ({ \ + typeof(_ptptr) ptptr = (_ptptr); \ + const typeof(_tags) tags = (_tags); \ + if (__builtin_constant_p(tags) && (tags & ~__tagptr_mask(*ptptr))) \ + __bad_tagptr_tags(); \ + ptptr->v &= ~tags; \ +*ptptr; }) + +#endif + From 5eb20ec3e52496dfd0a2cf6a817993dd01ab2067 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:57 +0800 Subject: [PATCH 611/903] staging: erofs: introduce pagevec for unzip subsystem For each compressed cluster, there is a straight-forward way of allocating a fixed or variable-sized (for VLE) array to record the corresponding file pages for its decompression if we decide to decompress these pages asynchronously (eg. read-ahead case), however it could take much extra on-heap memory compared with traditional uncompressed filesystems. This patch introduces a pagevec solution to reuse some allocated file page in the time-sharing approach storing parts of the array itself in order to minimize the extra memory overhead, thus only a constant and small-sized array used for booting the whole array itself up will be needed. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_pagevec.h | 172 ++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 drivers/staging/erofs/unzip_pagevec.h diff --git a/drivers/staging/erofs/unzip_pagevec.h b/drivers/staging/erofs/unzip_pagevec.h new file mode 100644 index 000000000000..0956615b86f7 --- /dev/null +++ b/drivers/staging/erofs/unzip_pagevec.h @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * linux/drivers/staging/erofs/unzip_pagevec.h + * + * Copyright (C) 2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#ifndef __EROFS_UNZIP_PAGEVEC_H +#define __EROFS_UNZIP_PAGEVEC_H + +#include + +/* page type in pagevec for unzip subsystem */ +enum z_erofs_page_type { + /* including Z_EROFS_VLE_PAGE_TAIL_EXCLUSIVE */ + Z_EROFS_PAGE_TYPE_EXCLUSIVE, + + Z_EROFS_VLE_PAGE_TYPE_TAIL_SHARED, + + Z_EROFS_VLE_PAGE_TYPE_HEAD, + Z_EROFS_VLE_PAGE_TYPE_MAX +}; + +extern void __compiletime_error("Z_EROFS_PAGE_TYPE_EXCLUSIVE != 0") + __bad_page_type_exclusive(void); + +/* pagevec tagged pointer */ +typedef tagptr2_t erofs_vtptr_t; + +/* pagevec collector */ +struct z_erofs_pagevec_ctor { + struct page *curr, *next; + erofs_vtptr_t *pages; + + unsigned int nr, index; +}; + +static inline void z_erofs_pagevec_ctor_exit(struct z_erofs_pagevec_ctor *ctor, + bool atomic) +{ + if (ctor->curr == NULL) + return; + + if (atomic) + kunmap_atomic(ctor->pages); + else + kunmap(ctor->curr); +} + +static inline struct page * +z_erofs_pagevec_ctor_next_page(struct z_erofs_pagevec_ctor *ctor, + unsigned nr) +{ + unsigned index; + + /* keep away from occupied pages */ + if (ctor->next != NULL) + return ctor->next; + + for (index = 0; index < nr; ++index) { + const erofs_vtptr_t t = ctor->pages[index]; + const unsigned tags = tagptr_unfold_tags(t); + + if (tags == Z_EROFS_PAGE_TYPE_EXCLUSIVE) + return tagptr_unfold_ptr(t); + } + + if (unlikely(nr >= ctor->nr)) + BUG(); + + return NULL; +} + +static inline void +z_erofs_pagevec_ctor_pagedown(struct z_erofs_pagevec_ctor *ctor, + bool atomic) +{ + struct page *next = z_erofs_pagevec_ctor_next_page(ctor, ctor->nr); + + z_erofs_pagevec_ctor_exit(ctor, atomic); + + ctor->curr = next; + ctor->next = NULL; + ctor->pages = atomic ? + kmap_atomic(ctor->curr) : kmap(ctor->curr); + + ctor->nr = PAGE_SIZE / sizeof(struct page *); + ctor->index = 0; +} + +static inline void z_erofs_pagevec_ctor_init(struct z_erofs_pagevec_ctor *ctor, + unsigned nr, + erofs_vtptr_t *pages, unsigned i) +{ + ctor->nr = nr; + ctor->curr = ctor->next = NULL; + ctor->pages = pages; + + if (i >= nr) { + i -= nr; + z_erofs_pagevec_ctor_pagedown(ctor, false); + while (i > ctor->nr) { + i -= ctor->nr; + z_erofs_pagevec_ctor_pagedown(ctor, false); + } + } + + ctor->next = z_erofs_pagevec_ctor_next_page(ctor, i); + ctor->index = i; +} + +static inline bool +z_erofs_pagevec_ctor_enqueue(struct z_erofs_pagevec_ctor *ctor, + struct page *page, + enum z_erofs_page_type type, + bool *occupied) +{ + *occupied = false; + if (unlikely(ctor->next == NULL && type)) + if (ctor->index + 1 == ctor->nr) + return false; + + if (unlikely(ctor->index >= ctor->nr)) + z_erofs_pagevec_ctor_pagedown(ctor, false); + + /* exclusive page type must be 0 */ + if (Z_EROFS_PAGE_TYPE_EXCLUSIVE != (uintptr_t)NULL) + __bad_page_type_exclusive(); + + /* should remind that collector->next never equal to 1, 2 */ + if (type == (uintptr_t)ctor->next) { + ctor->next = page; + *occupied = true; + } + + ctor->pages[ctor->index++] = + tagptr_fold(erofs_vtptr_t, page, type); + return true; +} + +static inline struct page * +z_erofs_pagevec_ctor_dequeue(struct z_erofs_pagevec_ctor *ctor, + enum z_erofs_page_type *type) +{ + erofs_vtptr_t t; + + if (unlikely(ctor->index >= ctor->nr)) { + BUG_ON(ctor->next == NULL); + z_erofs_pagevec_ctor_pagedown(ctor, true); + } + + t = ctor->pages[ctor->index]; + + *type = tagptr_unfold_tags(t); + + /* should remind that collector->next never equal to 1, 2 */ + if (*type == (uintptr_t)ctor->next) + ctor->next = tagptr_unfold_ptr(t); + + ctor->pages[ctor->index++] = + tagptr_fold(erofs_vtptr_t, NULL, 0); + + return tagptr_unfold_ptr(t); +} + +#endif + From 02827e1796b33f1794966f5c3101f8da2dfa9c1d Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:58 +0800 Subject: [PATCH 612/903] staging: erofs: add erofs_map_blocks_iter This patch introduces an iterable L2P mapping operation 'erofs_map_blocks_iter'. Compared with 'erofs_map_blocks', it avoids a number of redundant 'release and regrab' processes if they request the same meta page. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Kconfig | 10 ++ drivers/staging/erofs/Makefile | 1 + drivers/staging/erofs/data.c | 36 ++++- drivers/staging/erofs/internal.h | 12 ++ drivers/staging/erofs/unzip_vle.c | 243 ++++++++++++++++++++++++++++++ 5 files changed, 300 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/erofs/unzip_vle.c diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index edda055b3c64..63bec702da86 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig @@ -77,3 +77,13 @@ config EROFS_FAULT_INJECTION help Test EROFS to inject faults such as ENOMEM, EIO, and so on. If unsure, say N. + +config EROFS_FS_ZIP + bool "EROFS Data Compresssion Support" + depends on EROFS_FS + help + Currently we support VLE Compression only. + Play at your own risk. + + If you don't want to use compression feature, say N. + diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index 977b7e05a312..8558c761a74b 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -9,4 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o ccflags-y += -I$(src)/include erofs-objs := super.o inode.o data.o namei.o dir.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o +erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 47d1787e99ef..163bfe6eaa69 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -157,12 +157,44 @@ out: return 0; } +#ifdef CONFIG_EROFS_FS_ZIP +extern int z_erofs_map_blocks_iter(struct inode *, + struct erofs_map_blocks *, struct page **, int); +#endif + +int erofs_map_blocks_iter(struct inode *inode, + struct erofs_map_blocks *map, + struct page **mpage_ret, int flags) +{ + /* by default, reading raw data never use erofs_map_blocks_iter */ + if (unlikely(!is_inode_layout_compression(inode))) { + if (*mpage_ret != NULL) + put_page(*mpage_ret); + *mpage_ret = NULL; + + return erofs_map_blocks(inode, map, flags); + } + +#ifdef CONFIG_EROFS_FS_ZIP + return z_erofs_map_blocks_iter(inode, map, mpage_ret, flags); +#else + /* data compression is not available */ + return -ENOTSUPP; +#endif +} + int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map, int flags) { - if (unlikely(is_inode_layout_compression(inode))) - return -ENOTSUPP; + if (unlikely(is_inode_layout_compression(inode))) { + struct page *mpage = NULL; + int err; + err = erofs_map_blocks_iter(inode, map, &mpage, flags); + if (mpage != NULL) + put_page(mpage); + return err; + } return erofs_map_blocks_flatmode(inode, map, flags); } diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index ca224866282f..bea5ec458707 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -72,6 +72,10 @@ struct erofs_sb_info { /* inode slot unit size in bit shift */ unsigned char islotbits; +#ifdef CONFIG_EROFS_FS_ZIP + /* cluster size in bit shift */ + unsigned char clusterbits; +#endif u32 build_time_nsec; u64 build_time; @@ -284,6 +288,14 @@ struct erofs_map_blocks { extern struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr, bool prio); extern int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int); +extern int erofs_map_blocks_iter(struct inode *, struct erofs_map_blocks *, + struct page **, int); + +struct erofs_map_blocks_iter { + struct erofs_map_blocks map; + struct page *mpage; +}; + static inline struct page *erofs_get_inline_page(struct inode *inode, erofs_blk_t blkaddr) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c new file mode 100644 index 000000000000..329cbe47f599 --- /dev/null +++ b/drivers/staging/erofs/unzip_vle.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/unzip_vle.c + * + * Copyright (C) 2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include "internal.h" + +#define __vle_cluster_advise(x, bit, bits) \ + ((le16_to_cpu(x) >> (bit)) & ((1 << (bits)) - 1)) + +#define __vle_cluster_type(advise) __vle_cluster_advise(advise, \ + Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT, Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS) + +enum { + Z_EROFS_VLE_CLUSTER_TYPE_PLAIN, + Z_EROFS_VLE_CLUSTER_TYPE_HEAD, + Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD, + Z_EROFS_VLE_CLUSTER_TYPE_RESERVED, + Z_EROFS_VLE_CLUSTER_TYPE_MAX +}; + +#define vle_cluster_type(di) \ + __vle_cluster_type((di)->di_advise) + +static inline unsigned +vle_compressed_index_clusterofs(unsigned clustersize, + struct z_erofs_vle_decompressed_index *di) +{ + debugln("%s, vle=%pK, advise=%x (type %u), clusterofs=%x blkaddr=%x", + __func__, di, di->di_advise, vle_cluster_type(di), + di->di_clusterofs, di->di_u.blkaddr); + + switch (vle_cluster_type(di)) { + case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: + break; + case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: + return di->di_clusterofs; + default: + BUG_ON(1); + } + return clustersize; +} + +static inline erofs_blk_t +vle_extent_blkaddr(struct inode *inode, pgoff_t index) +{ + struct erofs_sb_info *sbi = EROFS_I_SB(inode); + struct erofs_vnode *vi = EROFS_V(inode); + + unsigned ofs = Z_EROFS_VLE_EXTENT_ALIGN(vi->inode_isize + + vi->xattr_isize) + sizeof(struct erofs_extent_header) + + index * sizeof(struct z_erofs_vle_decompressed_index); + + return erofs_blknr(iloc(sbi, vi->nid) + ofs); +} + +static inline unsigned int +vle_extent_blkoff(struct inode *inode, pgoff_t index) +{ + struct erofs_sb_info *sbi = EROFS_I_SB(inode); + struct erofs_vnode *vi = EROFS_V(inode); + + unsigned ofs = Z_EROFS_VLE_EXTENT_ALIGN(vi->inode_isize + + vi->xattr_isize) + sizeof(struct erofs_extent_header) + + index * sizeof(struct z_erofs_vle_decompressed_index); + + return erofs_blkoff(iloc(sbi, vi->nid) + ofs); +} + +/* + * Variable-sized Logical Extent (Fixed Physical Cluster) Compression Mode + * --- + * VLE compression mode attempts to compress a number of logical data into + * a physical cluster with a fixed size. + * VLE compression mode uses "struct z_erofs_vle_decompressed_index". + */ +static erofs_off_t vle_get_logical_extent_head( + struct inode *inode, + struct page **page_iter, + void **kaddr_iter, + unsigned lcn, /* logical cluster number */ + erofs_blk_t *pcn, + unsigned *flags) +{ + /* for extent meta */ + struct page *page = *page_iter; + erofs_blk_t blkaddr = vle_extent_blkaddr(inode, lcn); + struct z_erofs_vle_decompressed_index *di; + unsigned long long ofs; + const unsigned int clusterbits = EROFS_SB(inode->i_sb)->clusterbits; + const unsigned int clustersize = 1 << clusterbits; + + if (page->index != blkaddr) { + kunmap_atomic(*kaddr_iter); + unlock_page(page); + put_page(page); + + *page_iter = page = erofs_get_meta_page(inode->i_sb, + blkaddr, false); + *kaddr_iter = kmap_atomic(page); + } + + di = *kaddr_iter + vle_extent_blkoff(inode, lcn); + switch (vle_cluster_type(di)) { + case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: + BUG_ON(!di->di_u.delta[0]); + BUG_ON(lcn < di->di_u.delta[0]); + + ofs = vle_get_logical_extent_head(inode, + page_iter, kaddr_iter, + lcn - di->di_u.delta[0], pcn, flags); + break; + case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: + *flags ^= EROFS_MAP_ZIPPED; + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: + /* clustersize should be a power of two */ + ofs = ((unsigned long long)lcn << clusterbits) + + (le16_to_cpu(di->di_clusterofs) & (clustersize - 1)); + *pcn = le32_to_cpu(di->di_u.blkaddr); + break; + default: + BUG_ON(1); + } + return ofs; +} + +int z_erofs_map_blocks_iter(struct inode *inode, + struct erofs_map_blocks *map, + struct page **mpage_ret, int flags) +{ + /* logicial extent (start, end) offset */ + unsigned long long ofs, end; + struct z_erofs_vle_decompressed_index *di; + erofs_blk_t e_blkaddr, pcn; + unsigned lcn, logical_cluster_ofs; + u32 ofs_rem; + struct page *mpage = *mpage_ret; + void *kaddr; + bool initial; + const unsigned int clusterbits = EROFS_SB(inode->i_sb)->clusterbits; + const unsigned int clustersize = 1 << clusterbits; + + /* if both m_(l,p)len are 0, regularize l_lblk, l_lofs, etc... */ + initial = !map->m_llen; + + /* when trying to read beyond EOF, leave it unmapped */ + if (unlikely(map->m_la >= inode->i_size)) { + BUG_ON(!initial); + map->m_llen = map->m_la + 1 - inode->i_size; + map->m_la = inode->i_size - 1; + map->m_flags = 0; + goto out; + } + + debugln("%s, m_la %llu m_llen %llu --- start", __func__, + map->m_la, map->m_llen); + + ofs = map->m_la + map->m_llen; + + /* clustersize should be power of two */ + lcn = ofs >> clusterbits; + ofs_rem = ofs & (clustersize - 1); + + e_blkaddr = vle_extent_blkaddr(inode, lcn); + + if (mpage == NULL || mpage->index != e_blkaddr) { + if (mpage != NULL) + put_page(mpage); + + mpage = erofs_get_meta_page(inode->i_sb, e_blkaddr, false); + *mpage_ret = mpage; + } else { + lock_page(mpage); + DBG_BUGON(!PageUptodate(mpage)); + } + + kaddr = kmap_atomic(mpage); + di = kaddr + vle_extent_blkoff(inode, lcn); + + debugln("%s, lcn %u e_blkaddr %u e_blkoff %u", __func__, lcn, + e_blkaddr, vle_extent_blkoff(inode, lcn)); + + logical_cluster_ofs = vle_compressed_index_clusterofs(clustersize, di); + if (!initial) { + /* [walking mode] 'map' has been already initialized */ + map->m_llen += logical_cluster_ofs; + goto unmap_out; + } + + /* by default, compressed */ + map->m_flags |= EROFS_MAP_ZIPPED; + + end = (u64)(lcn + 1) * clustersize; + + switch (vle_cluster_type(di)) { + case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: + if (ofs_rem >= logical_cluster_ofs) + map->m_flags ^= EROFS_MAP_ZIPPED; + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: + if (ofs_rem == logical_cluster_ofs) { + pcn = le32_to_cpu(di->di_u.blkaddr); + goto exact_hitted; + } + + if (ofs_rem > logical_cluster_ofs) { + ofs = lcn * clustersize | logical_cluster_ofs; + pcn = le32_to_cpu(di->di_u.blkaddr); + break; + } + + BUG_ON(!lcn); /* logical cluster number >= 1 */ + end = (lcn-- * clustersize) | logical_cluster_ofs; + case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: + /* get the correspoinding first chunk */ + ofs = vle_get_logical_extent_head(inode, mpage_ret, + &kaddr, lcn, &pcn, &map->m_flags); + mpage = *mpage_ret; + } + + map->m_la = ofs; +exact_hitted: + map->m_llen = end - ofs; + map->m_plen = clustersize; + map->m_pa = blknr_to_addr(pcn); + map->m_flags |= EROFS_MAP_MAPPED; +unmap_out: + kunmap_atomic(kaddr); + unlock_page(mpage); +out: + debugln("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o", + __func__, map->m_la, map->m_pa, + map->m_llen, map->m_plen, map->m_flags); + return 0; +} + From b29e64d8798018c3e82a426ec34b39b825ac68dc Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:21:59 +0800 Subject: [PATCH 613/903] staging: erofs: add erofs_allocpage This patch introduces an temporary _on-stack_ page pool to reuse the freed page directly as much as it can for better performance and release all pages at a time, it also slightly reduces the possibility of the potential memory allocation failure. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Makefile | 2 +- drivers/staging/erofs/internal.h | 7 +++++++ drivers/staging/erofs/utils.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/erofs/utils.c diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index 8558c761a74b..490fa6cced08 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -7,7 +7,7 @@ ccflags-y += -Wall -DEROFS_VERSION=\"$(EROFS_VERSION)\" obj-$(CONFIG_EROFS_FS) += erofs.o # staging requirement: to be self-contained in its own directory ccflags-y += -I$(src)/include -erofs-objs := super.o inode.o data.o namei.o dir.o +erofs-objs := super.o inode.o data.o namei.o dir.o utils.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index bea5ec458707..210ab6c64df8 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -369,5 +369,12 @@ static inline void erofs_vunmap(const void *mem, unsigned int count) #endif } +/* utils.c */ +extern struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp); + +#ifndef lru_to_page +#define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) +#endif + #endif diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c new file mode 100644 index 000000000000..3dec4f80ed99 --- /dev/null +++ b/drivers/staging/erofs/utils.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/utils.c + * + * Copyright (C) 2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ + +#include "internal.h" + +struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) +{ + struct page *page; + + if (!list_empty(pool)) { + page = lru_to_page(pool); + list_del(&page->lru); + } else { + page = alloc_pages(gfp | __GFP_NOFAIL, 0); + + BUG_ON(page == NULL); + BUG_ON(page->mapping != NULL); + } + return page; +} + From 55441958bb8d1a7b5509f1332ce98b0a733231da Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:00 +0800 Subject: [PATCH 614/903] staging: erofs: globalize prepare_bio and __submit_bio The unzip subsystem also uses these functions, let's export them to internal.h. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/data.c | 34 +++++++++----------------------- drivers/staging/erofs/internal.h | 33 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 163bfe6eaa69..ac263a180253 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -38,26 +38,6 @@ static inline void read_endio(struct bio *bio) bio_put(bio); } -static void __submit_bio(struct bio *bio, unsigned op, unsigned op_flags) -{ - bio_set_op_attrs(bio, op, op_flags); - submit_bio(bio); -} - -static struct bio *prepare_bio(struct super_block *sb, - erofs_blk_t blkaddr, unsigned nr_pages) -{ - struct bio *bio = bio_alloc(GFP_NOIO | __GFP_NOFAIL, nr_pages); - - BUG_ON(bio == NULL); - - bio->bi_end_io = read_endio; - bio_set_dev(bio, sb->s_bdev); - bio->bi_iter.bi_sector = blkaddr << LOG_SECTORS_PER_BLOCK; - - return bio; -} - /* prio -- true is used for dir */ struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr, bool prio) @@ -80,7 +60,7 @@ repeat: struct bio *bio; int err; - bio = prepare_bio(sb, blkaddr, 1); + bio = prepare_bio(sb, blkaddr, 1, read_endio); err = bio_add_page(bio, page, PAGE_SIZE, 0); BUG_ON(err != PAGE_SIZE); @@ -236,6 +216,8 @@ submit_bio_retry: struct erofs_map_blocks map = { .m_la = blknr_to_addr(current_block), }; + erofs_blk_t blknr; + unsigned blkoff; err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW); if (unlikely(err)) @@ -253,6 +235,9 @@ submit_bio_retry: /* for RAW access mode, m_plen must be equal to m_llen */ BUG_ON(map.m_plen != map.m_llen); + blknr = erofs_blknr(map.m_pa); + blkoff = erofs_blkoff(map.m_pa); + /* deal with inline page */ if (map.m_flags & EROFS_MAP_META) { void *vsrc, *vto; @@ -260,8 +245,7 @@ submit_bio_retry: BUG_ON(map.m_plen > PAGE_SIZE); - ipage = erofs_get_meta_page(inode->i_sb, - erofs_blknr(map.m_pa), 0); + ipage = erofs_get_meta_page(inode->i_sb, blknr, 0); if (IS_ERR(ipage)) { err = PTR_ERR(ipage); @@ -270,7 +254,7 @@ submit_bio_retry: vsrc = kmap_atomic(ipage); vto = kmap_atomic(page); - memcpy(vto, vsrc + erofs_blkoff(map.m_pa), map.m_plen); + memcpy(vto, vsrc + blkoff, map.m_plen); memset(vto + map.m_plen, 0, PAGE_SIZE - map.m_plen); kunmap_atomic(vto); kunmap_atomic(vsrc); @@ -294,7 +278,7 @@ submit_bio_retry: if (nblocks > BIO_MAX_PAGES) nblocks = BIO_MAX_PAGES; - bio = prepare_bio(inode->i_sb, erofs_blknr(map.m_pa), nblocks); + bio = prepare_bio(inode->i_sb, blknr, nblocks, read_endio); } err = bio_add_page(bio, page, PAGE_SIZE, 0); diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 210ab6c64df8..6a0f045d63c2 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -285,6 +285,39 @@ struct erofs_map_blocks { #define EROFS_GET_BLOCKS_RAW 0x0001 /* data.c */ +static inline struct bio *prepare_bio( + struct super_block *sb, + erofs_blk_t blkaddr, unsigned nr_pages, + bio_end_io_t endio) +{ + gfp_t gfp = GFP_NOIO; + struct bio *bio = bio_alloc(gfp, nr_pages); + + if (unlikely(bio == NULL) && + (current->flags & PF_MEMALLOC)) { + do { + nr_pages /= 2; + if (unlikely(!nr_pages)) { + bio = bio_alloc(gfp | __GFP_NOFAIL, 1); + BUG_ON(bio == NULL); + break; + } + bio = bio_alloc(gfp, nr_pages); + } while (bio == NULL); + } + + bio->bi_end_io = endio; + bio_set_dev(bio, sb->s_bdev); + bio->bi_iter.bi_sector = blkaddr << LOG_SECTORS_PER_BLOCK; + return bio; +} + +static inline void __submit_bio(struct bio *bio, unsigned op, unsigned op_flags) +{ + bio_set_op_attrs(bio, op, op_flags); + submit_bio(bio); +} + extern struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr, bool prio); extern int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int); From 366c96a3a8681c90d0663f580ebc4dd077df2152 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:01 +0800 Subject: [PATCH 615/903] staging: erofs: introduce a customized LZ4 decompression We have to reduce the memory cost as much as possible, so we don't want to decompress more data beyond the output buffer size, however "LZ4_decompress_safe_partial" doesn't guarantee to stop at the arbitary end position, but stop just after its current LZ4 "sequence" is completed. Link: https://groups.google.com/forum/#!topic/lz4c/_3kkz5N6n00 Therefore, I hacked the LZ4 decompression logic by hand, probably NOT the fastest approach, and hope for better implementation. Signed-off-by: Miao Xie Signed-off-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Makefile | 2 +- drivers/staging/erofs/lz4defs.h | 227 +++++++++++++++++++++++++++ drivers/staging/erofs/unzip_lz4.c | 251 ++++++++++++++++++++++++++++++ 3 files changed, 479 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/erofs/lz4defs.h create mode 100644 drivers/staging/erofs/unzip_lz4.c diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index 490fa6cced08..e4096370b22e 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o ccflags-y += -I$(src)/include erofs-objs := super.o inode.o data.o namei.o dir.o utils.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o -erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o +erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o unzip_lz4.o diff --git a/drivers/staging/erofs/lz4defs.h b/drivers/staging/erofs/lz4defs.h new file mode 100644 index 000000000000..00a0b58a0871 --- /dev/null +++ b/drivers/staging/erofs/lz4defs.h @@ -0,0 +1,227 @@ +#ifndef __LZ4DEFS_H__ +#define __LZ4DEFS_H__ + +/* + * lz4defs.h -- common and architecture specific defines for the kernel usage + + * LZ4 - Fast LZ compression algorithm + * Copyright (C) 2011-2016, Yann Collet. + * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * You can contact the author at : + * - LZ4 homepage : http://www.lz4.org + * - LZ4 source repository : https://github.com/lz4/lz4 + * + * Changed for kernel usage by: + * Sven Schmidt <4sschmid@informatik.uni-hamburg.de> + */ + +#include +#include /* memset, memcpy */ + +#define FORCE_INLINE __always_inline + +/*-************************************ + * Basic Types + **************************************/ +#include + +typedef uint8_t BYTE; +typedef uint16_t U16; +typedef uint32_t U32; +typedef int32_t S32; +typedef uint64_t U64; +typedef uintptr_t uptrval; + +/*-************************************ + * Architecture specifics + **************************************/ +#if defined(CONFIG_64BIT) +#define LZ4_ARCH64 1 +#else +#define LZ4_ARCH64 0 +#endif + +#if defined(__LITTLE_ENDIAN) +#define LZ4_LITTLE_ENDIAN 1 +#else +#define LZ4_LITTLE_ENDIAN 0 +#endif + +/*-************************************ + * Constants + **************************************/ +#define MINMATCH 4 + +#define WILDCOPYLENGTH 8 +#define LASTLITERALS 5 +#define MFLIMIT (WILDCOPYLENGTH + MINMATCH) + +/* Increase this value ==> compression run slower on incompressible data */ +#define LZ4_SKIPTRIGGER 6 + +#define HASH_UNIT sizeof(size_t) + +#define KB (1 << 10) +#define MB (1 << 20) +#define GB (1U << 30) + +#define MAXD_LOG 16 +#define MAX_DISTANCE ((1 << MAXD_LOG) - 1) +#define STEPSIZE sizeof(size_t) + +#define ML_BITS 4 +#define ML_MASK ((1U << ML_BITS) - 1) +#define RUN_BITS (8 - ML_BITS) +#define RUN_MASK ((1U << RUN_BITS) - 1) + +/*-************************************ + * Reading and writing into memory + **************************************/ +static FORCE_INLINE U16 LZ4_read16(const void *ptr) +{ + return get_unaligned((const U16 *)ptr); +} + +static FORCE_INLINE U32 LZ4_read32(const void *ptr) +{ + return get_unaligned((const U32 *)ptr); +} + +static FORCE_INLINE size_t LZ4_read_ARCH(const void *ptr) +{ + return get_unaligned((const size_t *)ptr); +} + +static FORCE_INLINE void LZ4_write16(void *memPtr, U16 value) +{ + put_unaligned(value, (U16 *)memPtr); +} + +static FORCE_INLINE void LZ4_write32(void *memPtr, U32 value) +{ + put_unaligned(value, (U32 *)memPtr); +} + +static FORCE_INLINE U16 LZ4_readLE16(const void *memPtr) +{ + return get_unaligned_le16(memPtr); +} + +static FORCE_INLINE void LZ4_writeLE16(void *memPtr, U16 value) +{ + return put_unaligned_le16(value, memPtr); +} + +static FORCE_INLINE void LZ4_copy8(void *dst, const void *src) +{ +#if LZ4_ARCH64 + U64 a = get_unaligned((const U64 *)src); + + put_unaligned(a, (U64 *)dst); +#else + U32 a = get_unaligned((const U32 *)src); + U32 b = get_unaligned((const U32 *)src + 1); + + put_unaligned(a, (U32 *)dst); + put_unaligned(b, (U32 *)dst + 1); +#endif +} + +/* + * customized variant of memcpy, + * which can overwrite up to 7 bytes beyond dstEnd + */ +static FORCE_INLINE void LZ4_wildCopy(void *dstPtr, + const void *srcPtr, void *dstEnd) +{ + BYTE *d = (BYTE *)dstPtr; + const BYTE *s = (const BYTE *)srcPtr; + BYTE *const e = (BYTE *)dstEnd; + + do { + LZ4_copy8(d, s); + d += 8; + s += 8; + } while (d < e); +} + +static FORCE_INLINE unsigned int LZ4_NbCommonBytes(register size_t val) +{ +#if LZ4_LITTLE_ENDIAN + return __ffs(val) >> 3; +#else + return (BITS_PER_LONG - 1 - __fls(val)) >> 3; +#endif +} + +static FORCE_INLINE unsigned int LZ4_count( + const BYTE *pIn, + const BYTE *pMatch, + const BYTE *pInLimit) +{ + const BYTE *const pStart = pIn; + + while (likely(pIn < pInLimit - (STEPSIZE - 1))) { + size_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn); + + if (!diff) { + pIn += STEPSIZE; + pMatch += STEPSIZE; + continue; + } + + pIn += LZ4_NbCommonBytes(diff); + + return (unsigned int)(pIn - pStart); + } + +#if LZ4_ARCH64 + if ((pIn < (pInLimit - 3)) + && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { + pIn += 4; + pMatch += 4; + } +#endif + + if ((pIn < (pInLimit - 1)) + && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { + pIn += 2; + pMatch += 2; + } + + if ((pIn < pInLimit) && (*pMatch == *pIn)) + pIn++; + + return (unsigned int)(pIn - pStart); +} + +typedef enum { noLimit = 0, limitedOutput = 1 } limitedOutput_directive; +typedef enum { byPtr, byU32, byU16 } tableType_t; + +typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive; +typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive; + +typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive; +typedef enum { full = 0, partial = 1 } earlyEnd_directive; + +#endif diff --git a/drivers/staging/erofs/unzip_lz4.c b/drivers/staging/erofs/unzip_lz4.c new file mode 100644 index 000000000000..b1ea23f66c4e --- /dev/null +++ b/drivers/staging/erofs/unzip_lz4.c @@ -0,0 +1,251 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +/* + * linux/drivers/staging/erofs/unzip_lz4.c + * + * Copyright (C) 2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * Original code taken from 'linux/lib/lz4/lz4_decompress.c' + */ + +/* + * LZ4 - Fast LZ compression algorithm + * Copyright (C) 2011 - 2016, Yann Collet. + * BSD 2 - Clause License (http://www.opensource.org/licenses/bsd - license.php) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * You can contact the author at : + * - LZ4 homepage : http://www.lz4.org + * - LZ4 source repository : https://github.com/lz4/lz4 + * + * Changed for kernel usage by: + * Sven Schmidt <4sschmid@informatik.uni-hamburg.de> + */ +#include "internal.h" +#include +#include "lz4defs.h" + +/* + * no public solution to solve our requirement yet. + * see: + * https://groups.google.com/forum/#!topic/lz4c/_3kkz5N6n00 + */ +static FORCE_INLINE int customized_lz4_decompress_safe_partial( + const void * const source, + void * const dest, + int inputSize, + int outputSize) +{ + /* Local Variables */ + const BYTE *ip = (const BYTE *) source; + const BYTE * const iend = ip + inputSize; + + BYTE *op = (BYTE *) dest; + BYTE * const oend = op + outputSize; + BYTE *cpy; + + static const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; + static const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; + + /* Empty output buffer */ + if (unlikely(outputSize == 0)) + return ((inputSize == 1) && (*ip == 0)) ? 0 : -1; + + /* Main Loop : decode sequences */ + while (1) { + size_t length; + const BYTE *match; + size_t offset; + + /* get literal length */ + unsigned int const token = *ip++; + + length = token>>ML_BITS; + + if (length == RUN_MASK) { + unsigned int s; + + do { + s = *ip++; + length += s; + } while ((ip < iend - RUN_MASK) & (s == 255)); + + if (unlikely((size_t)(op + length) < (size_t)(op))) { + /* overflow detection */ + goto _output_error; + } + if (unlikely((size_t)(ip + length) < (size_t)(ip))) { + /* overflow detection */ + goto _output_error; + } + } + + /* copy literals */ + cpy = op + length; + if ((cpy > oend - WILDCOPYLENGTH) || + (ip + length > iend - (2 + 1 + LASTLITERALS))) { + if (cpy > oend) { + memcpy(op, ip, length = oend - op); + op += length; + break; + } + + if (unlikely(ip + length > iend)) { + /* + * Error : + * read attempt beyond + * end of input buffer + */ + goto _output_error; + } + + memcpy(op, ip, length); + ip += length; + op += length; + + if (ip > iend - 2) + break; + /* Necessarily EOF, due to parsing restrictions */ + /* break; */ + } else { + LZ4_wildCopy(op, ip, cpy); + ip += length; + op = cpy; + } + + /* get offset */ + offset = LZ4_readLE16(ip); + ip += 2; + match = op - offset; + + if (unlikely(match < (const BYTE *)dest)) { + /* Error : offset outside buffers */ + goto _output_error; + } + + /* get matchlength */ + length = token & ML_MASK; + if (length == ML_MASK) { + unsigned int s; + + do { + s = *ip++; + + if (ip > iend - LASTLITERALS) + goto _output_error; + + length += s; + } while (s == 255); + + if (unlikely((size_t)(op + length) < (size_t)op)) { + /* overflow detection */ + goto _output_error; + } + } + + length += MINMATCH; + + /* copy match within block */ + cpy = op + length; + + if (unlikely(cpy >= oend - WILDCOPYLENGTH)) { + if (cpy >= oend) { + while (op < oend) + *op++ = *match++; + break; + } + goto __match; + } + + /* costs ~1%; silence an msan warning when offset == 0 */ + LZ4_write32(op, (U32)offset); + + if (unlikely(offset < 8)) { + const int dec64 = dec64table[offset]; + + op[0] = match[0]; + op[1] = match[1]; + op[2] = match[2]; + op[3] = match[3]; + match += dec32table[offset]; + memcpy(op + 4, match, 4); + match -= dec64; + } else { + LZ4_copy8(op, match); + match += 8; + } + + op += 8; + + if (unlikely(cpy > oend - 12)) { + BYTE * const oCopyLimit = oend - (WILDCOPYLENGTH - 1); + + if (op < oCopyLimit) { + LZ4_wildCopy(op, match, oCopyLimit); + match += oCopyLimit - op; + op = oCopyLimit; + } +__match: + while (op < cpy) + *op++ = *match++; + } else { + LZ4_copy8(op, match); + + if (length > 16) + LZ4_wildCopy(op + 8, match + 8, cpy); + } + + op = cpy; /* correction */ + } + DBG_BUGON((void *)ip - source > inputSize); + DBG_BUGON((void *)op - dest > outputSize); + + /* Nb of output bytes decoded */ + return (int) ((void *)op - dest); + + /* Overflow error detected */ +_output_error: + return -ERANGE; +} + +int z_erofs_unzip_lz4(void *in, void *out, size_t inlen, size_t outlen) +{ + int ret = customized_lz4_decompress_safe_partial(in, + out, inlen, outlen); + + if (ret >= 0) + return ret; + + /* + * LZ4_decompress_safe will return an error code + * (< 0) if decompression failed + */ + errln("%s, failed to decompress, in[%p, %zu] outlen[%p, %zu]", + __func__, in, inlen, out, outlen); + WARN_ON(1); + print_hex_dump(KERN_DEBUG, "raw data [in]: ", DUMP_PREFIX_OFFSET, + 16, 1, in, inlen, true); + print_hex_dump(KERN_DEBUG, "raw data [out]: ", DUMP_PREFIX_OFFSET, + 16, 1, out, outlen, true); + return -EIO; +} + From 0d40d6e399c12c662eda395fe4f0602327d0d01f Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:02 +0800 Subject: [PATCH 616/903] staging: erofs: add a generic z_erofs VLE decompressor Currently, this patch only simply implements LZ4 decompressor due to its development priority. In the future, erofs will support more compression algorithm and format other than LZ4, thus a generic decompressor interface will be needed. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Kconfig | 14 ++ drivers/staging/erofs/Makefile | 2 +- drivers/staging/erofs/internal.h | 5 + drivers/staging/erofs/unzip_vle.h | 35 +++++ drivers/staging/erofs/unzip_vle_lz4.c | 209 ++++++++++++++++++++++++++ 5 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/erofs/unzip_vle.h create mode 100644 drivers/staging/erofs/unzip_vle_lz4.c diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index 63bec702da86..b55ce1cf3bc7 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig @@ -87,3 +87,17 @@ config EROFS_FS_ZIP If you don't want to use compression feature, say N. +config EROFS_FS_CLUSTER_PAGE_LIMIT + int "EROFS Cluster Pages Hard Limit" + depends on EROFS_FS_ZIP + range 1 256 + default "1" + help + Indicates VLE compressed pages hard limit of a + compressed cluster. + + For example, if files of a image are compressed + into 8k-unit, the hard limit should not be less + than 2. Otherwise, the image cannot be mounted + correctly on this kernel. + diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index e4096370b22e..9a766eb7ed75 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o ccflags-y += -I$(src)/include erofs-objs := super.o inode.o data.o namei.o dir.o utils.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o -erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o unzip_lz4.o +erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o unzip_lz4.o unzip_vle_lz4.o diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 6a0f045d63c2..e61d417bbeb3 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -161,6 +161,11 @@ static inline void *erofs_kmalloc(struct erofs_sb_info *sbi, #define ROOT_NID(sb) ((sb)->root_nid) +#ifdef CONFIG_EROFS_FS_ZIP +/* hard limit of pages per compressed cluster */ +#define Z_EROFS_CLUSTER_MAX_PAGES (CONFIG_EROFS_FS_CLUSTER_PAGE_LIMIT) +#endif + typedef u64 erofs_off_t; /* data type for filesystem-wide blocks number */ diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h new file mode 100644 index 000000000000..b34f5bc28d29 --- /dev/null +++ b/drivers/staging/erofs/unzip_vle.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * linux/drivers/staging/erofs/unzip_vle.h + * + * Copyright (C) 2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#ifndef __EROFS_FS_UNZIP_VLE_H +#define __EROFS_FS_UNZIP_VLE_H + +#include "internal.h" + +#define Z_EROFS_VLE_INLINE_PAGEVECS 3 + +/* unzip_vle_lz4.c */ +extern int z_erofs_vle_plain_copy(struct page **compressed_pages, + unsigned clusterpages, struct page **pages, + unsigned nr_pages, unsigned short pageofs); + +extern int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, + unsigned clusterpages, struct page **pages, + unsigned outlen, unsigned short pageofs, + void (*endio)(struct page *)); + +extern int z_erofs_vle_unzip_vmap(struct page **compressed_pages, + unsigned clusterpages, void *vaddr, unsigned llen, + unsigned short pageofs, bool overlapped); + +#endif + diff --git a/drivers/staging/erofs/unzip_vle_lz4.c b/drivers/staging/erofs/unzip_vle_lz4.c new file mode 100644 index 000000000000..f5b665f15be5 --- /dev/null +++ b/drivers/staging/erofs/unzip_vle_lz4.c @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/unzip_vle_lz4.c + * + * Copyright (C) 2018 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ +#include "unzip_vle.h" + +#if Z_EROFS_CLUSTER_MAX_PAGES > Z_EROFS_VLE_INLINE_PAGEVECS +#define EROFS_PERCPU_NR_PAGES Z_EROFS_CLUSTER_MAX_PAGES +#else +#define EROFS_PERCPU_NR_PAGES Z_EROFS_VLE_INLINE_PAGEVECS +#endif + +static struct { + char data[PAGE_SIZE * EROFS_PERCPU_NR_PAGES]; +} erofs_pcpubuf[NR_CPUS]; + +int z_erofs_vle_plain_copy(struct page **compressed_pages, + unsigned clusterpages, + struct page **pages, + unsigned nr_pages, + unsigned short pageofs) +{ + unsigned i, j; + void *src = NULL; + const unsigned righthalf = PAGE_SIZE - pageofs; + char *percpu_data; + bool mirrored[Z_EROFS_CLUSTER_MAX_PAGES] = { 0 }; + + preempt_disable(); + percpu_data = erofs_pcpubuf[smp_processor_id()].data; + + j = 0; + for (i = 0; i < nr_pages; j = i++) { + struct page *page = pages[i]; + void *dst; + + if (page == NULL) { + if (src != NULL) { + if (!mirrored[j]) + kunmap_atomic(src); + src = NULL; + } + continue; + } + + dst = kmap_atomic(page); + + for (; j < clusterpages; ++j) { + if (compressed_pages[j] != page) + continue; + + BUG_ON(mirrored[j]); + memcpy(percpu_data + j * PAGE_SIZE, dst, PAGE_SIZE); + mirrored[j] = true; + break; + } + + if (i) { + if (src == NULL) + src = mirrored[i-1] ? + percpu_data + (i-1) * PAGE_SIZE : + kmap_atomic(compressed_pages[i-1]); + + memcpy(dst, src + righthalf, pageofs); + + if (!mirrored[i-1]) + kunmap_atomic(src); + + if (unlikely(i >= clusterpages)) { + kunmap_atomic(dst); + break; + } + } + + if (!righthalf) + src = NULL; + else { + src = mirrored[i] ? percpu_data + i * PAGE_SIZE : + kmap_atomic(compressed_pages[i]); + + memcpy(dst + pageofs, src, righthalf); + } + + kunmap_atomic(dst); + } + + if (src != NULL && !mirrored[j]) + kunmap_atomic(src); + + preempt_enable(); + return 0; +} + +extern int z_erofs_unzip_lz4(void *in, void *out, size_t inlen, size_t outlen); + +int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, + unsigned clusterpages, + struct page **pages, + unsigned outlen, + unsigned short pageofs, + void (*endio)(struct page *)) +{ + void *vin, *vout; + unsigned nr_pages, i, j; + int ret; + + if (outlen + pageofs > EROFS_PERCPU_NR_PAGES * PAGE_SIZE) + return -ENOTSUPP; + + nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); + + if (clusterpages == 1) + vin = kmap_atomic(compressed_pages[0]); + else + vin = erofs_vmap(compressed_pages, clusterpages); + + preempt_disable(); + vout = erofs_pcpubuf[smp_processor_id()].data; + + ret = z_erofs_unzip_lz4(vin, vout + pageofs, + clusterpages * PAGE_SIZE, outlen); + + if (ret >= 0) { + outlen = ret; + ret = 0; + } + + for (i = 0; i < nr_pages; ++i) { + j = min((unsigned)PAGE_SIZE - pageofs, outlen); + + if (pages[i] != NULL) { + if (ret < 0) + SetPageError(pages[i]); + else if (clusterpages == 1 && pages[i] == compressed_pages[0]) + memcpy(vin + pageofs, vout + pageofs, j); + else { + void *dst = kmap_atomic(pages[i]); + + memcpy(dst + pageofs, vout + pageofs, j); + kunmap_atomic(dst); + } + endio(pages[i]); + } + vout += PAGE_SIZE; + outlen -= j; + pageofs = 0; + } + preempt_enable(); + + if (clusterpages == 1) + kunmap_atomic(vin); + else + erofs_vunmap(vin, clusterpages); + + return ret; +} + +int z_erofs_vle_unzip_vmap(struct page **compressed_pages, + unsigned clusterpages, + void *vout, + unsigned llen, + unsigned short pageofs, + bool overlapped) +{ + void *vin; + unsigned i; + int ret; + + if (overlapped) { + preempt_disable(); + vin = erofs_pcpubuf[smp_processor_id()].data; + + for (i = 0; i < clusterpages; ++i) { + void *t = kmap_atomic(compressed_pages[i]); + + memcpy(vin + PAGE_SIZE *i, t, PAGE_SIZE); + kunmap_atomic(t); + } + } else if (clusterpages == 1) + vin = kmap_atomic(compressed_pages[0]); + else { + vin = erofs_vmap(compressed_pages, clusterpages); + } + + ret = z_erofs_unzip_lz4(vin, vout + pageofs, + clusterpages * PAGE_SIZE, llen); + if (ret > 0) + ret = 0; + + if (!overlapped) { + if (clusterpages == 1) + kunmap_atomic(vin); + else { + erofs_vunmap(vin, clusterpages); + } + } else + preempt_enable(); + + return ret; +} + From 2497ee41295c769dc74cb8bac7e03842bc51d331 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:03 +0800 Subject: [PATCH 617/903] staging: erofs: introduce superblock registration In order to introducing shrinker solution for erofs, let's manage all mounted erofs instances at first. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 6 ++++++ drivers/staging/erofs/super.c | 4 ++++ drivers/staging/erofs/utils.c | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index e61d417bbeb3..18e7b9c2aaa0 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -64,6 +64,9 @@ struct erofs_fault_info { typedef u64 erofs_nid_t; struct erofs_sb_info { + /* list for all registered superblocks, mainly for shrinker */ + struct list_head list; + u32 blocks; u32 meta_blkaddr; #ifdef CONFIG_EROFS_FS_XATTR @@ -410,6 +413,9 @@ static inline void erofs_vunmap(const void *mem, unsigned int count) /* utils.c */ extern struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp); +extern void erofs_register_super(struct super_block *sb); +extern void erofs_unregister_super(struct super_block *sb); + #ifndef lru_to_page #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) #endif diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 054375d6ecce..f455d7135599 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -326,6 +326,8 @@ static int erofs_read_super(struct super_block *sb, snprintf(sbi->dev_name, PATH_MAX, "%s", dev_name); sbi->dev_name[PATH_MAX - 1] = '\0'; + erofs_register_super(sb); + /* * We already have a positive dentry, which was instantiated * by d_make_root. Just need to d_rehash it. @@ -373,6 +375,8 @@ static void erofs_put_super(struct super_block *sb) infoln("unmounted for %s", sbi->dev_name); __putname(sbi->dev_name); + erofs_unregister_super(sb); + kfree(sbi); sb->s_fs_info = NULL; } diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index 3dec4f80ed99..6748def67e74 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -29,3 +29,20 @@ struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) return page; } +static DEFINE_MUTEX(erofs_sb_list_lock); +static LIST_HEAD(erofs_sb_list); + +void erofs_register_super(struct super_block *sb) +{ + mutex_lock(&erofs_sb_list_lock); + list_add(&EROFS_SB(sb)->list, &erofs_sb_list); + mutex_unlock(&erofs_sb_list_lock); +} + +void erofs_unregister_super(struct super_block *sb) +{ + mutex_lock(&erofs_sb_list_lock); + list_del(&EROFS_SB(sb)->list); + mutex_unlock(&erofs_sb_list_lock); +} + From a15813126272e5f81311e5e1330162baa40e5b0a Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:04 +0800 Subject: [PATCH 618/903] staging: erofs: introduce erofs shrinker This patch adds a dedicated shrinker targeting to free unneeded memory consumed by a number of erofs in-memory data structures. Like F2FS and UBIFS, it also adds: - sbi->umount_mutex to avoid races on shrinker and put_super - sbi->shrinker_run_no to not revisit recently scaned objects Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 7 +++ drivers/staging/erofs/super.c | 15 ++++++ drivers/staging/erofs/utils.c | 85 +++++++++++++++++++++++++++++--- 3 files changed, 101 insertions(+), 6 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 18e7b9c2aaa0..42455f01c421 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -66,6 +66,7 @@ typedef u64 erofs_nid_t; struct erofs_sb_info { /* list for all registered superblocks, mainly for shrinker */ struct list_head list; + struct mutex umount_mutex; u32 blocks; u32 meta_blkaddr; @@ -93,6 +94,7 @@ struct erofs_sb_info { char *dev_name; unsigned int mount_opt; + unsigned int shrinker_run_no; #ifdef CONFIG_EROFS_FAULT_INJECTION struct erofs_fault_info fault_info; /* For fault injection */ @@ -416,6 +418,11 @@ extern struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp); extern void erofs_register_super(struct super_block *sb); extern void erofs_unregister_super(struct super_block *sb); +extern unsigned long erofs_shrink_count(struct shrinker *shrink, + struct shrink_control *sc); +extern unsigned long erofs_shrink_scan(struct shrinker *shrink, + struct shrink_control *sc); + #ifndef lru_to_page #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) #endif diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index f455d7135599..ef85884d47fb 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -375,7 +375,9 @@ static void erofs_put_super(struct super_block *sb) infoln("unmounted for %s", sbi->dev_name); __putname(sbi->dev_name); + mutex_lock(&sbi->umount_mutex); erofs_unregister_super(sb); + mutex_unlock(&sbi->umount_mutex); kfree(sbi); sb->s_fs_info = NULL; @@ -415,6 +417,12 @@ static void erofs_kill_sb(struct super_block *sb) kill_block_super(sb); } +static struct shrinker erofs_shrinker_info = { + .scan_objects = erofs_shrink_scan, + .count_objects = erofs_shrink_count, + .seeks = DEFAULT_SEEKS, +}; + static struct file_system_type erofs_fs_type = { .owner = THIS_MODULE, .name = "erofs", @@ -435,6 +443,10 @@ static int __init erofs_module_init(void) if (err) goto icache_err; + err = register_shrinker(&erofs_shrinker_info); + if (err) + goto shrinker_err; + err = register_filesystem(&erofs_fs_type); if (err) goto fs_err; @@ -443,6 +455,8 @@ static int __init erofs_module_init(void) return 0; fs_err: + unregister_shrinker(&erofs_shrinker_info); +shrinker_err: erofs_exit_inode_cache(); icache_err: return err; @@ -451,6 +465,7 @@ icache_err: static void __exit erofs_module_exit(void) { unregister_filesystem(&erofs_fs_type); + unregister_shrinker(&erofs_shrinker_info); erofs_exit_inode_cache(); infoln("successfully finalize erofs"); } diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index 6748def67e74..c1d83cecfec6 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -29,20 +29,93 @@ struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) return page; } -static DEFINE_MUTEX(erofs_sb_list_lock); + +/* protected by 'erofs_sb_list_lock' */ +static unsigned int shrinker_run_no; + +/* protects the mounted 'erofs_sb_list' */ +static DEFINE_SPINLOCK(erofs_sb_list_lock); static LIST_HEAD(erofs_sb_list); +/* global shrink count (for all mounted EROFS instances) */ +static atomic_long_t erofs_global_shrink_cnt; + void erofs_register_super(struct super_block *sb) { - mutex_lock(&erofs_sb_list_lock); - list_add(&EROFS_SB(sb)->list, &erofs_sb_list); - mutex_unlock(&erofs_sb_list_lock); + struct erofs_sb_info *sbi = EROFS_SB(sb); + + mutex_init(&sbi->umount_mutex); + + spin_lock(&erofs_sb_list_lock); + list_add(&sbi->list, &erofs_sb_list); + spin_unlock(&erofs_sb_list_lock); } void erofs_unregister_super(struct super_block *sb) { - mutex_lock(&erofs_sb_list_lock); + spin_lock(&erofs_sb_list_lock); list_del(&EROFS_SB(sb)->list); - mutex_unlock(&erofs_sb_list_lock); + spin_unlock(&erofs_sb_list_lock); +} + +unsigned long erofs_shrink_count(struct shrinker *shrink, + struct shrink_control *sc) +{ + return atomic_long_read(&erofs_global_shrink_cnt); +} + +unsigned long erofs_shrink_scan(struct shrinker *shrink, + struct shrink_control *sc) +{ + struct erofs_sb_info *sbi; + struct list_head *p; + + unsigned long nr = sc->nr_to_scan; + unsigned int run_no; + unsigned long freed = 0; + + spin_lock(&erofs_sb_list_lock); + do + run_no = ++shrinker_run_no; + while (run_no == 0); + + /* Iterate over all mounted superblocks and try to shrink them */ + p = erofs_sb_list.next; + while (p != &erofs_sb_list) { + sbi = list_entry(p, struct erofs_sb_info, list); + + /* + * We move the ones we do to the end of the list, so we stop + * when we see one we have already done. + */ + if (sbi->shrinker_run_no == run_no) + break; + + if (!mutex_trylock(&sbi->umount_mutex)) { + p = p->next; + continue; + } + + spin_unlock(&erofs_sb_list_lock); + sbi->shrinker_run_no = run_no; + + /* add scan handlers here */ + + spin_lock(&erofs_sb_list_lock); + /* Get the next list element before we move this one */ + p = p->next; + + /* + * Move this one to the end of the list to provide some + * fairness. + */ + list_move_tail(&sbi->list, &erofs_sb_list); + mutex_unlock(&sbi->umount_mutex); + + if (freed >= nr) + break; + } + spin_unlock(&erofs_sb_list_lock); + return freed; } From e7e9a307be9d75ecc3bf20b362af88140dfb4304 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:05 +0800 Subject: [PATCH 619/903] staging: erofs: introduce workstation for decompression This patch introduces another concept used by the unzip subsystem called 'workstation'. It can be seen as a sparse array that stores pointers pointed to data structures related to the corresponding physical blocks. All lookup cases are protected by RCU read lock. Besides, reference count and spin_lock are also introduced to manage its lifetime and serialize all update operations. 'workstation' is currently implemented on the in-kernel radix tree approach for backward compatibility. With the evolution of linux kernel, it could be migrated into XArray implementation in the future. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 93 ++++++++++++++++++++++++++++++++ drivers/staging/erofs/super.c | 9 ++++ drivers/staging/erofs/utils.c | 81 ++++++++++++++++++++++++++-- 3 files changed, 180 insertions(+), 3 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 42455f01c421..b07cd7aa0a09 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -79,6 +79,9 @@ struct erofs_sb_info { #ifdef CONFIG_EROFS_FS_ZIP /* cluster size in bit shift */ unsigned char clusterbits; + + /* the dedicated workstation for compression */ + struct radix_tree_root workstn_tree; #endif u32 build_time_nsec; @@ -149,6 +152,96 @@ static inline void *erofs_kmalloc(struct erofs_sb_info *sbi, #define set_opt(sbi, option) ((sbi)->mount_opt |= EROFS_MOUNT_##option) #define test_opt(sbi, option) ((sbi)->mount_opt & EROFS_MOUNT_##option) +#ifdef CONFIG_EROFS_FS_ZIP +#define erofs_workstn_lock(sbi) xa_lock(&(sbi)->workstn_tree) +#define erofs_workstn_unlock(sbi) xa_unlock(&(sbi)->workstn_tree) + +/* basic unit of the workstation of a super_block */ +struct erofs_workgroup { + /* the workgroup index in the workstation */ + pgoff_t index; + + /* overall workgroup reference count */ + atomic_t refcount; +}; + +#define EROFS_LOCKED_MAGIC (INT_MIN | 0xE0F510CCL) + +static inline bool erofs_workgroup_try_to_freeze( + struct erofs_workgroup *grp, int v) +{ +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) + if (v != atomic_cmpxchg(&grp->refcount, + v, EROFS_LOCKED_MAGIC)) + return false; + preempt_disable(); +#else + preempt_disable(); + if (atomic_read(&grp->refcount) != v) { + preempt_enable(); + return false; + } +#endif + return true; +} + +static inline void erofs_workgroup_unfreeze( + struct erofs_workgroup *grp, int v) +{ +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) + atomic_set(&grp->refcount, v); +#endif + preempt_enable(); +} + +static inline bool erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt) +{ + const int locked = (int)EROFS_LOCKED_MAGIC; + int o; + +repeat: + o = atomic_read(&grp->refcount); + + /* spin if it is temporarily locked at the reclaim path */ + if (unlikely(o == locked)) { +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) + do + cpu_relax(); + while (atomic_read(&grp->refcount) == locked); +#endif + goto repeat; + } + + if (unlikely(o <= 0)) + return -1; + + if (unlikely(atomic_cmpxchg(&grp->refcount, o, o + 1) != o)) + goto repeat; + + *ocnt = o; + return 0; +} + +#define __erofs_workgroup_get(grp) atomic_inc(&(grp)->refcount) + +extern int erofs_workgroup_put(struct erofs_workgroup *grp); + +extern struct erofs_workgroup *erofs_find_workgroup( + struct super_block *sb, pgoff_t index, bool *tag); + +extern int erofs_register_workgroup(struct super_block *sb, + struct erofs_workgroup *grp, bool tag); + +extern unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi, + unsigned long nr_shrink, bool cleanup); + +static inline void erofs_workstation_cleanup_all(struct super_block *sb) +{ + erofs_shrink_workstation(EROFS_SB(sb), ~0UL, true); +} + +#endif + /* we strictly follow PAGE_SIZE and no buffer head yet */ #define LOG_BLOCK_SIZE PAGE_SHIFT diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index ef85884d47fb..e155a2b0d43e 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -296,6 +296,10 @@ static int erofs_read_super(struct super_block *sb, if (!silent) infoln("root inode @ nid %llu", ROOT_NID(sbi)); +#ifdef CONFIG_EROFS_FS_ZIP + INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC); +#endif + /* get the root inode */ inode = erofs_iget(sb, ROOT_NID(sbi), true); if (IS_ERR(inode)) { @@ -376,6 +380,11 @@ static void erofs_put_super(struct super_block *sb) __putname(sbi->dev_name); mutex_lock(&sbi->umount_mutex); + +#ifdef CONFIG_EROFS_FS_ZIP + erofs_workstation_cleanup_all(sb); +#endif + erofs_unregister_super(sb); mutex_unlock(&sbi->umount_mutex); diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index c1d83cecfec6..0d4eae2f79a8 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -29,6 +29,83 @@ struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) return page; } +/* global shrink count (for all mounted EROFS instances) */ +static atomic_long_t erofs_global_shrink_cnt; + +#ifdef CONFIG_EROFS_FS_ZIP + +/* radix_tree and the future XArray both don't use tagptr_t yet */ +struct erofs_workgroup *erofs_find_workgroup( + struct super_block *sb, pgoff_t index, bool *tag) +{ + struct erofs_sb_info *sbi = EROFS_SB(sb); + struct erofs_workgroup *grp; + int oldcount; + +repeat: + rcu_read_lock(); + grp = radix_tree_lookup(&sbi->workstn_tree, index); + if (grp != NULL) { + *tag = radix_tree_exceptional_entry(grp); + grp = (void *)((unsigned long)grp & + ~RADIX_TREE_EXCEPTIONAL_ENTRY); + + if (erofs_workgroup_get(grp, &oldcount)) { + /* prefer to relax rcu read side */ + rcu_read_unlock(); + goto repeat; + } + + /* decrease refcount added by erofs_workgroup_put */ + if (unlikely(oldcount == 1)) + atomic_long_dec(&erofs_global_shrink_cnt); + BUG_ON(index != grp->index); + } + rcu_read_unlock(); + return grp; +} + +int erofs_register_workgroup(struct super_block *sb, + struct erofs_workgroup *grp, + bool tag) +{ + struct erofs_sb_info *sbi; + int err; + + /* grp->refcount should not < 1 */ + BUG_ON(!atomic_read(&grp->refcount)); + + err = radix_tree_preload(GFP_NOFS); + if (err) + return err; + + sbi = EROFS_SB(sb); + erofs_workstn_lock(sbi); + + if (tag) + grp = (void *)((unsigned long)grp | + 1UL << RADIX_TREE_EXCEPTIONAL_SHIFT); + + err = radix_tree_insert(&sbi->workstn_tree, + grp->index, grp); + + if (!err) { + __erofs_workgroup_get(grp); + } + + erofs_workstn_unlock(sbi); + radix_tree_preload_end(); + return err; +} + +unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi, + unsigned long nr_shrink, + bool cleanup) +{ + return 0; +} + +#endif /* protected by 'erofs_sb_list_lock' */ static unsigned int shrinker_run_no; @@ -37,9 +114,6 @@ static unsigned int shrinker_run_no; static DEFINE_SPINLOCK(erofs_sb_list_lock); static LIST_HEAD(erofs_sb_list); -/* global shrink count (for all mounted EROFS instances) */ -static atomic_long_t erofs_global_shrink_cnt; - void erofs_register_super(struct super_block *sb) { struct erofs_sb_info *sbi = EROFS_SB(sb); @@ -112,6 +186,7 @@ unsigned long erofs_shrink_scan(struct shrinker *shrink, list_move_tail(&sbi->list, &erofs_sb_list); mutex_unlock(&sbi->umount_mutex); + freed += erofs_shrink_workstation(sbi, nr, false); if (freed >= nr) break; } From 3883a79abd02272222a214a5f84395d41eecdc84 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:06 +0800 Subject: [PATCH 620/903] staging: erofs: introduce VLE decompression support This patch introduces the basic in-place VLE decompression implementation for the erofs file system. Compared with fixed-sized input compression, it implements what we call 'the variable-length extent compression' which specifies the same output size for each compression block to make the full use of IO bandwidth (which means almost all data from block device can be directly used for decomp- ression), improve the real (rather than just via data caching, which costs more memory) random read and keep the relatively lower compression ratios (it saves more storage space than fixed-sized input compression which is also configured with the same input block size), as illustrated below: |--- variable-length extent ---|------ VLE ------|--- VLE ---| /> clusterofs /> clusterofs /> clusterofs /> clusterofs ++---|-------++-----------++---------|-++-----------++-|---------++-| ...|| | || || | || || | || | ... original data ++---|-------++-----------++---------|-++-----------++-|---------++-| ++->cluster<-++->cluster<-++->cluster<-++->cluster<-++->cluster<-++ size size size size size \ / / / \ / / / \ / / / ++-----------++-----------++-----------++ ... || || || || ... compressed clusters ++-----------++-----------++-----------++ ++->cluster<-++->cluster<-++->cluster<-++ size size size The main point of 'in-place' refers to the decompression mode: Instead of allocating independent compressed pages and data structures, it reuses the allocated file cache pages at most to store its compressed data and the corresponding pagevec in a time-sharing approach by default, which will be useful for low memory scenario. In the end, unlike the other filesystems with (de)compression support using a relatively large compression block size, which reads and decompresses >= 128KB at once, and gains a more good-looking random read (In fact it collects small random reads into large sequential reads and caches all decompressed data in memory, but it is unacceptable especially for embedded devices with limited memory, and it is not the real random read), we select a universal small-sized 4KB compressed cluster, which is the smallest page size for most architectures, and all compressed clusters can be read and decompressed independently, which ensures random read number for all use cases. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 5 + drivers/staging/erofs/internal.h | 6 + drivers/staging/erofs/super.c | 25 + drivers/staging/erofs/unzip_vle.c | 1119 ++++++++++++++++++++++++++++- drivers/staging/erofs/unzip_vle.h | 204 ++++++ drivers/staging/erofs/utils.c | 61 +- 6 files changed, 1418 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 613c9771bd14..fbf6ff25cd1b 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -210,7 +210,12 @@ static int fill_inode(struct inode *inode, int isdir) } if (is_inode_layout_compression(inode)) { +#ifdef CONFIG_EROFS_FS_ZIP + inode->i_mapping->a_ops = + &z_erofs_vle_normalaccess_aops; +#else err = -ENOTSUPP; +#endif goto out_unlock; } diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index b07cd7aa0a09..3adec7d95d3e 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -262,6 +262,9 @@ static inline void erofs_workstation_cleanup_all(struct super_block *sb) #ifdef CONFIG_EROFS_FS_ZIP /* hard limit of pages per compressed cluster */ #define Z_EROFS_CLUSTER_MAX_PAGES (CONFIG_EROFS_FS_CLUSTER_PAGE_LIMIT) + +/* page count of a compressed cluster */ +#define erofs_clusterpages(sbi) ((1 << (sbi)->clusterbits) / PAGE_SIZE) #endif typedef u64 erofs_off_t; @@ -340,6 +343,9 @@ extern const struct inode_operations erofs_dir_iops; extern const struct file_operations erofs_dir_fops; extern const struct address_space_operations erofs_raw_access_aops; +#ifdef CONFIG_EROFS_FS_ZIP +extern const struct address_space_operations z_erofs_vle_normalaccess_aops; +#endif /* * Logical to physical block mapping, used by erofs_map_blocks() diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index e155a2b0d43e..2bd433ab4c49 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -115,6 +115,13 @@ static int superblock_read(struct super_block *sb) sbi->xattr_blkaddr = le32_to_cpu(layout->xattr_blkaddr); #endif sbi->islotbits = ffs(sizeof(struct erofs_inode_v1)) - 1; +#ifdef CONFIG_EROFS_FS_ZIP + sbi->clusterbits = 12; + + if (1 << (sbi->clusterbits - 12) > Z_EROFS_CLUSTER_MAX_PAGES) + errln("clusterbits %u is not supported on this kernel", + sbi->clusterbits); +#endif sbi->root_nid = le16_to_cpu(layout->root_nid); sbi->inos = le64_to_cpu(layout->inos); @@ -441,6 +448,11 @@ static struct file_system_type erofs_fs_type = { }; MODULE_ALIAS_FS("erofs"); +#ifdef CONFIG_EROFS_FS_ZIP +extern int z_erofs_init_zip_subsystem(void); +extern void z_erofs_exit_zip_subsystem(void); +#endif + static int __init erofs_module_init(void) { int err; @@ -456,6 +468,12 @@ static int __init erofs_module_init(void) if (err) goto shrinker_err; +#ifdef CONFIG_EROFS_FS_ZIP + err = z_erofs_init_zip_subsystem(); + if (err) + goto zip_err; +#endif + err = register_filesystem(&erofs_fs_type); if (err) goto fs_err; @@ -464,6 +482,10 @@ static int __init erofs_module_init(void) return 0; fs_err: +#ifdef CONFIG_EROFS_FS_ZIP + z_erofs_exit_zip_subsystem(); +zip_err: +#endif unregister_shrinker(&erofs_shrinker_info); shrinker_err: erofs_exit_inode_cache(); @@ -474,6 +496,9 @@ icache_err: static void __exit erofs_module_exit(void) { unregister_filesystem(&erofs_fs_type); +#ifdef CONFIG_EROFS_FS_ZIP + z_erofs_exit_zip_subsystem(); +#endif unregister_shrinker(&erofs_shrinker_info); erofs_exit_inode_cache(); infoln("successfully finalize erofs"); diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 329cbe47f599..f0ead60a8fee 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -10,7 +10,1124 @@ * License. See the file COPYING in the main directory of the Linux * distribution for more details. */ -#include "internal.h" +#include "unzip_vle.h" +#include + +static struct workqueue_struct *z_erofs_workqueue __read_mostly; +static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly; + +void z_erofs_exit_zip_subsystem(void) +{ + BUG_ON(z_erofs_workqueue == NULL); + BUG_ON(z_erofs_workgroup_cachep == NULL); + + destroy_workqueue(z_erofs_workqueue); + kmem_cache_destroy(z_erofs_workgroup_cachep); +} + +static inline int init_unzip_workqueue(void) +{ + const unsigned onlinecpus = num_possible_cpus(); + + /* + * we don't need too many threads, limiting threads + * could improve scheduling performance. + */ + z_erofs_workqueue = alloc_workqueue("erofs_unzipd", + WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, + onlinecpus + onlinecpus / 4); + + return z_erofs_workqueue != NULL ? 0 : -ENOMEM; +} + +int z_erofs_init_zip_subsystem(void) +{ + z_erofs_workgroup_cachep = + kmem_cache_create("erofs_compress", + Z_EROFS_WORKGROUP_SIZE, 0, + SLAB_RECLAIM_ACCOUNT, NULL); + + if (z_erofs_workgroup_cachep != NULL) { + if (!init_unzip_workqueue()) + return 0; + + kmem_cache_destroy(z_erofs_workgroup_cachep); + } + return -ENOMEM; +} + +enum z_erofs_vle_work_role { + Z_EROFS_VLE_WORK_SECONDARY, + Z_EROFS_VLE_WORK_PRIMARY, + /* + * The current work has at least been linked with the following + * processed chained works, which means if the processing page + * is the tail partial page of the work, the current work can + * safely use the whole page, as illustrated below: + * +--------------+-------------------------------------------+ + * | tail page | head page (of the previous work) | + * +--------------+-------------------------------------------+ + * /\ which belongs to the current work + * [ (*) this page can be used for the current work itself. ] + */ + Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED, + Z_EROFS_VLE_WORK_MAX +}; + +struct z_erofs_vle_work_builder { + enum z_erofs_vle_work_role role; + /* + * 'hosted = false' means that the current workgroup doesn't belong to + * the owned chained workgroups. In the other words, it is none of our + * business to submit this workgroup. + */ + bool hosted; + + struct z_erofs_vle_workgroup *grp; + struct z_erofs_vle_work *work; + struct z_erofs_pagevec_ctor vector; + + /* pages used for reading the compressed data */ + struct page **compressed_pages; + unsigned compressed_deficit; +}; + +#define VLE_WORK_BUILDER_INIT() \ + { .work = NULL, .role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED } + +/* page_type must be Z_EROFS_PAGE_TYPE_EXCLUSIVE */ +static inline bool try_to_reuse_as_compressed_page( + struct z_erofs_vle_work_builder *b, + struct page *page) +{ + while (b->compressed_deficit) { + --b->compressed_deficit; + if (NULL == cmpxchg(b->compressed_pages++, NULL, page)) + return true; + } + + return false; +} + +/* callers must be with work->lock held */ +static int z_erofs_vle_work_add_page( + struct z_erofs_vle_work_builder *builder, + struct page *page, + enum z_erofs_page_type type) +{ + int ret; + bool occupied; + + /* give priority for the compressed data storage */ + if (builder->role >= Z_EROFS_VLE_WORK_PRIMARY && + type == Z_EROFS_PAGE_TYPE_EXCLUSIVE && + try_to_reuse_as_compressed_page(builder, page)) + return 0; + + ret = z_erofs_pagevec_ctor_enqueue(&builder->vector, + page, type, &occupied); + builder->work->vcnt += (unsigned)ret; + + return ret ? 0 : -EAGAIN; +} + +static inline bool try_to_claim_workgroup( + struct z_erofs_vle_workgroup *grp, + z_erofs_vle_owned_workgrp_t *owned_head, + bool *hosted) +{ + DBG_BUGON(*hosted == true); + + /* let's claim these following types of workgroup */ +retry: + if (grp->next == Z_EROFS_VLE_WORKGRP_NIL) { + /* type 1, nil workgroup */ + if (Z_EROFS_VLE_WORKGRP_NIL != cmpxchg(&grp->next, + Z_EROFS_VLE_WORKGRP_NIL, *owned_head)) + goto retry; + + *owned_head = grp; + *hosted = true; + } else if (grp->next == Z_EROFS_VLE_WORKGRP_TAIL) { + /* + * type 2, link to the end of a existing open chain, + * be careful that its submission itself is governed + * by the original owned chain. + */ + if (Z_EROFS_VLE_WORKGRP_TAIL != cmpxchg(&grp->next, + Z_EROFS_VLE_WORKGRP_TAIL, *owned_head)) + goto retry; + + *owned_head = Z_EROFS_VLE_WORKGRP_TAIL; + } else + return false; /* :( better luck next time */ + + return true; /* lucky, I am the followee :) */ +} + +static struct z_erofs_vle_work * +z_erofs_vle_work_lookup(struct super_block *sb, + pgoff_t idx, unsigned pageofs, + struct z_erofs_vle_workgroup **grp_ret, + enum z_erofs_vle_work_role *role, + z_erofs_vle_owned_workgrp_t *owned_head, + bool *hosted) +{ + bool tag, primary; + struct erofs_workgroup *egrp; + struct z_erofs_vle_workgroup *grp; + struct z_erofs_vle_work *work; + + egrp = erofs_find_workgroup(sb, idx, &tag); + if (egrp == NULL) { + *grp_ret = NULL; + return NULL; + } + + *grp_ret = grp = container_of(egrp, + struct z_erofs_vle_workgroup, obj); + +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF + work = z_erofs_vle_grab_work(grp, pageofs); + primary = true; +#else + BUG(); +#endif + + DBG_BUGON(work->pageofs != pageofs); + + /* + * lock must be taken first to avoid grp->next == NIL between + * claiming workgroup and adding pages: + * grp->next != NIL + * grp->next = NIL + * mutex_unlock_all + * mutex_lock(&work->lock) + * add all pages to pagevec + * + * [correct locking case 1]: + * mutex_lock(grp->work[a]) + * ... + * mutex_lock(grp->work[b]) mutex_lock(grp->work[c]) + * ... *role = SECONDARY + * add all pages to pagevec + * ... + * mutex_unlock(grp->work[c]) + * mutex_lock(grp->work[c]) + * ... + * grp->next = NIL + * mutex_unlock_all + * + * [correct locking case 2]: + * mutex_lock(grp->work[b]) + * ... + * mutex_lock(grp->work[a]) + * ... + * mutex_lock(grp->work[c]) + * ... + * grp->next = NIL + * mutex_unlock_all + * mutex_lock(grp->work[a]) + * *role = PRIMARY_OWNER + * add all pages to pagevec + * ... + */ + mutex_lock(&work->lock); + + *hosted = false; + if (!primary) + *role = Z_EROFS_VLE_WORK_SECONDARY; + /* claim the workgroup if possible */ + else if (try_to_claim_workgroup(grp, owned_head, hosted)) + *role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED; + else + *role = Z_EROFS_VLE_WORK_PRIMARY; + + return work; +} + +static struct z_erofs_vle_work * +z_erofs_vle_work_register(struct super_block *sb, + struct z_erofs_vle_workgroup **grp_ret, + struct erofs_map_blocks *map, + pgoff_t index, unsigned pageofs, + enum z_erofs_vle_work_role *role, + z_erofs_vle_owned_workgrp_t *owned_head, + bool *hosted) +{ + bool newgrp = false; + struct z_erofs_vle_workgroup *grp = *grp_ret; + struct z_erofs_vle_work *work; + +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF + BUG_ON(grp != NULL); +#else + if (grp != NULL) + goto skip; +#endif + /* no available workgroup, let's allocate one */ + grp = kmem_cache_zalloc(z_erofs_workgroup_cachep, GFP_NOFS); + if (unlikely(grp == NULL)) + return ERR_PTR(-ENOMEM); + + grp->obj.index = index; + grp->llen = map->m_llen; + + z_erofs_vle_set_workgrp_fmt(grp, + (map->m_flags & EROFS_MAP_ZIPPED) ? + Z_EROFS_VLE_WORKGRP_FMT_LZ4 : + Z_EROFS_VLE_WORKGRP_FMT_PLAIN); + atomic_set(&grp->obj.refcount, 1); + + /* new workgrps have been claimed as type 1 */ + WRITE_ONCE(grp->next, *owned_head); + /* primary and followed work for all new workgrps */ + *role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED; + /* it should be submitted by ourselves */ + *hosted = true; + + newgrp = true; +#ifdef CONFIG_EROFS_FS_ZIP_MULTIREF +skip: + /* currently unimplemented */ + BUG(); +#else + work = z_erofs_vle_grab_primary_work(grp); +#endif + work->pageofs = pageofs; + + mutex_init(&work->lock); + + if (newgrp) { + int err = erofs_register_workgroup(sb, &grp->obj, 0); + + if (err) { + kmem_cache_free(z_erofs_workgroup_cachep, grp); + return ERR_PTR(-EAGAIN); + } + } + + *owned_head = *grp_ret = grp; + + mutex_lock(&work->lock); + return work; +} + +static inline void __update_workgrp_llen(struct z_erofs_vle_workgroup *grp, + unsigned int llen) +{ + while (1) { + unsigned int orig_llen = grp->llen; + + if (orig_llen >= llen || orig_llen == + cmpxchg(&grp->llen, orig_llen, llen)) + break; + } +} + +#define builder_is_followed(builder) \ + ((builder)->role >= Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED) + +static int z_erofs_vle_work_iter_begin(struct z_erofs_vle_work_builder *builder, + struct super_block *sb, + struct erofs_map_blocks *map, + z_erofs_vle_owned_workgrp_t *owned_head) +{ + const unsigned clusterpages = erofs_clusterpages(EROFS_SB(sb)); + const erofs_blk_t index = erofs_blknr(map->m_pa); + const unsigned pageofs = map->m_la & ~PAGE_MASK; + struct z_erofs_vle_workgroup *grp; + struct z_erofs_vle_work *work; + + DBG_BUGON(builder->work != NULL); + + /* must be Z_EROFS_WORK_TAIL or the next chained work */ + DBG_BUGON(*owned_head == Z_EROFS_VLE_WORKGRP_NIL); + DBG_BUGON(*owned_head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + + DBG_BUGON(erofs_blkoff(map->m_pa)); + +repeat: + work = z_erofs_vle_work_lookup(sb, index, + pageofs, &grp, &builder->role, owned_head, &builder->hosted); + if (work != NULL) { + __update_workgrp_llen(grp, map->m_llen); + goto got_it; + } + + work = z_erofs_vle_work_register(sb, &grp, map, index, pageofs, + &builder->role, owned_head, &builder->hosted); + + if (unlikely(work == ERR_PTR(-EAGAIN))) + goto repeat; + + if (unlikely(IS_ERR(work))) + return PTR_ERR(work); +got_it: + z_erofs_pagevec_ctor_init(&builder->vector, + Z_EROFS_VLE_INLINE_PAGEVECS, work->pagevec, work->vcnt); + + if (builder->role >= Z_EROFS_VLE_WORK_PRIMARY) { + /* enable possibly in-place decompression */ + builder->compressed_pages = grp->compressed_pages; + builder->compressed_deficit = clusterpages; + } else { + builder->compressed_pages = NULL; + builder->compressed_deficit = 0; + } + + builder->grp = grp; + builder->work = work; + return 0; +} + +/* + * keep in mind that no referenced workgroups will be freed + * only after a RCU grace period, so rcu_read_lock() could + * prevent a workgroup from being freed. + */ +static void z_erofs_rcu_callback(struct rcu_head *head) +{ + struct z_erofs_vle_work *work = container_of(head, + struct z_erofs_vle_work, rcu); + struct z_erofs_vle_workgroup *grp = + z_erofs_vle_work_workgroup(work, true); + + kmem_cache_free(z_erofs_workgroup_cachep, grp); +} + +void erofs_workgroup_free_rcu(struct erofs_workgroup *grp) +{ + struct z_erofs_vle_workgroup *const vgrp = container_of(grp, + struct z_erofs_vle_workgroup, obj); + struct z_erofs_vle_work *const work = &vgrp->work; + + call_rcu(&work->rcu, z_erofs_rcu_callback); +} + +static void __z_erofs_vle_work_release(struct z_erofs_vle_workgroup *grp, + struct z_erofs_vle_work *work __maybe_unused) +{ + erofs_workgroup_put(&grp->obj); +} + +void z_erofs_vle_work_release(struct z_erofs_vle_work *work) +{ + struct z_erofs_vle_workgroup *grp = + z_erofs_vle_work_workgroup(work, true); + + __z_erofs_vle_work_release(grp, work); +} + +static inline bool +z_erofs_vle_work_iter_end(struct z_erofs_vle_work_builder *builder) +{ + struct z_erofs_vle_work *work = builder->work; + + if (work == NULL) + return false; + + z_erofs_pagevec_ctor_exit(&builder->vector, false); + mutex_unlock(&work->lock); + + /* + * if all pending pages are added, don't hold work reference + * any longer if the current work isn't hosted by ourselves. + */ + if (!builder->hosted) + __z_erofs_vle_work_release(builder->grp, work); + + builder->work = NULL; + builder->grp = NULL; + return true; +} + +static inline struct page *__stagingpage_alloc(struct list_head *pagepool, + gfp_t gfp) +{ + struct page *page = erofs_allocpage(pagepool, gfp); + + if (unlikely(page == NULL)) + return NULL; + + page->mapping = Z_EROFS_MAPPING_STAGING; + return page; +} + +struct z_erofs_vle_frontend { + struct inode *const inode; + + struct z_erofs_vle_work_builder builder; + struct erofs_map_blocks_iter m_iter; + + z_erofs_vle_owned_workgrp_t owned_head; + + bool initial; +}; + +#define VLE_FRONTEND_INIT(__i) { \ + .inode = __i, \ + .m_iter = { \ + { .m_llen = 0, .m_plen = 0 }, \ + .mpage = NULL \ + }, \ + .builder = VLE_WORK_BUILDER_INIT(), \ + .owned_head = Z_EROFS_VLE_WORKGRP_TAIL, \ + .initial = true, } + +static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, + struct page *page, + struct list_head *page_pool) +{ + struct super_block *const sb = fe->inode->i_sb; + struct erofs_sb_info *const sbi __maybe_unused = EROFS_SB(sb); + struct erofs_map_blocks_iter *const m = &fe->m_iter; + struct erofs_map_blocks *const map = &m->map; + struct z_erofs_vle_work_builder *const builder = &fe->builder; + const loff_t offset = page_offset(page); + + bool tight = builder_is_followed(builder); + struct z_erofs_vle_work *work = builder->work; + + enum z_erofs_page_type page_type; + unsigned cur, end, spiltted, index; + int err; + + /* register locked file pages as online pages in pack */ + z_erofs_onlinepage_init(page); + + spiltted = 0; + end = PAGE_SIZE; +repeat: + cur = end - 1; + + /* lucky, within the range of the current map_blocks */ + if (offset + cur >= map->m_la && + offset + cur < map->m_la + map->m_llen) + goto hitted; + + /* go ahead the next map_blocks */ + debugln("%s: [out-of-range] pos %llu", __func__, offset + cur); + + if (!z_erofs_vle_work_iter_end(builder)) + fe->initial = false; + + map->m_la = offset + cur; + map->m_llen = 0; + err = erofs_map_blocks_iter(fe->inode, map, &m->mpage, 0); + if (unlikely(err)) + goto err_out; + + /* deal with hole (FIXME! broken now) */ + if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED))) + goto hitted; + + DBG_BUGON(map->m_plen != 1 << sbi->clusterbits); + BUG_ON(erofs_blkoff(map->m_pa)); + + err = z_erofs_vle_work_iter_begin(builder, sb, map, &fe->owned_head); + if (unlikely(err)) + goto err_out; + + tight &= builder_is_followed(builder); + work = builder->work; +hitted: + cur = end - min_t(unsigned, offset + end - map->m_la, end); + if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED))) { + zero_user_segment(page, cur, end); + goto next_part; + } + + /* let's derive page type */ + page_type = cur ? Z_EROFS_VLE_PAGE_TYPE_HEAD : + (!spiltted ? Z_EROFS_PAGE_TYPE_EXCLUSIVE : + (tight ? Z_EROFS_PAGE_TYPE_EXCLUSIVE : + Z_EROFS_VLE_PAGE_TYPE_TAIL_SHARED)); + +retry: + err = z_erofs_vle_work_add_page(builder, page, page_type); + /* should allocate an additional staging page for pagevec */ + if (err == -EAGAIN) { + struct page *const newpage = + __stagingpage_alloc(page_pool, GFP_NOFS); + + err = z_erofs_vle_work_add_page(builder, + newpage, Z_EROFS_PAGE_TYPE_EXCLUSIVE); + if (!err) + goto retry; + } + + if (unlikely(err)) + goto err_out; + + index = page->index - map->m_la / PAGE_SIZE; + + /* FIXME! avoid the last relundant fixup & endio */ + z_erofs_onlinepage_fixup(page, index, true); + ++spiltted; + + /* also update nr_pages and increase queued_pages */ + work->nr_pages = max_t(pgoff_t, work->nr_pages, index + 1); +next_part: + /* can be used for verification */ + map->m_llen = offset + cur - map->m_la; + + if ((end = cur) > 0) + goto repeat; + + /* FIXME! avoid the last relundant fixup & endio */ + z_erofs_onlinepage_endio(page); + + debugln("%s, finish page: %pK spiltted: %u map->m_llen %llu", + __func__, page, spiltted, map->m_llen); + return 0; + +err_out: + /* TODO: the missing error handing cases */ + return err; +} + +static void z_erofs_vle_unzip_kickoff(void *ptr, int bios) +{ + tagptr1_t t = tagptr_init(tagptr1_t, ptr); + struct z_erofs_vle_unzip_io *io = tagptr_unfold_ptr(t); + bool background = tagptr_unfold_tags(t); + + if (atomic_add_return(bios, &io->pending_bios)) + return; + + if (background) + queue_work(z_erofs_workqueue, &io->u.work); + else + wake_up(&io->u.wait); +} + +static inline void z_erofs_vle_read_endio(struct bio *bio) +{ + const blk_status_t err = bio->bi_status; + unsigned i; + struct bio_vec *bvec; + + bio_for_each_segment_all(bvec, bio, i) { + struct page *page = bvec->bv_page; + + DBG_BUGON(PageUptodate(page)); + BUG_ON(page->mapping == NULL); + + if (unlikely(err)) + SetPageError(page); + } + + z_erofs_vle_unzip_kickoff(bio->bi_private, -1); + bio_put(bio); +} + +static struct page *z_pagemap_global[Z_EROFS_VLE_VMAP_GLOBAL_PAGES]; +static DEFINE_MUTEX(z_pagemap_global_lock); + +static int z_erofs_vle_unzip(struct super_block *sb, + struct z_erofs_vle_workgroup *grp, + struct list_head *page_pool) +{ + struct erofs_sb_info *const sbi = EROFS_SB(sb); + const unsigned clusterpages = erofs_clusterpages(sbi); + + struct z_erofs_pagevec_ctor ctor; + unsigned nr_pages; +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF + unsigned sparsemem_pages = 0; +#endif + struct page *pages_onstack[Z_EROFS_VLE_VMAP_ONSTACK_PAGES]; + struct page **pages, **compressed_pages, *page; + unsigned i, llen; + + enum z_erofs_page_type page_type; + bool overlapped; + struct z_erofs_vle_work *work; + void *vout; + int err; + + might_sleep(); +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF + work = z_erofs_vle_grab_primary_work(grp); +#else + BUG(); +#endif + BUG_ON(!READ_ONCE(work->nr_pages)); + + mutex_lock(&work->lock); + nr_pages = work->nr_pages; + + if (likely(nr_pages <= Z_EROFS_VLE_VMAP_ONSTACK_PAGES)) + pages = pages_onstack; + else if (nr_pages <= Z_EROFS_VLE_VMAP_GLOBAL_PAGES && + mutex_trylock(&z_pagemap_global_lock)) + pages = z_pagemap_global; + else { +repeat: + pages = kvmalloc_array(nr_pages, + sizeof(struct page *), GFP_KERNEL); + + /* fallback to global pagemap for the lowmem scenario */ + if (unlikely(pages == NULL)) { + if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES) + goto repeat; + else { + mutex_lock(&z_pagemap_global_lock); + pages = z_pagemap_global; + } + } + } + + for (i = 0; i < nr_pages; ++i) + pages[i] = NULL; + + z_erofs_pagevec_ctor_init(&ctor, + Z_EROFS_VLE_INLINE_PAGEVECS, work->pagevec, 0); + + for (i = 0; i < work->vcnt; ++i) { + unsigned pagenr; + + page = z_erofs_pagevec_ctor_dequeue(&ctor, &page_type); + + /* all pages in pagevec ought to be valid */ + DBG_BUGON(page == NULL); + DBG_BUGON(page->mapping == NULL); + + if (z_erofs_gather_if_stagingpage(page_pool, page)) + continue; + + if (page_type == Z_EROFS_VLE_PAGE_TYPE_HEAD) + pagenr = 0; + else + pagenr = z_erofs_onlinepage_index(page); + + BUG_ON(pagenr >= nr_pages); + +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF + BUG_ON(pages[pagenr] != NULL); + ++sparsemem_pages; +#endif + pages[pagenr] = page; + } + + z_erofs_pagevec_ctor_exit(&ctor, true); + + overlapped = false; + compressed_pages = grp->compressed_pages; + + for (i = 0; i < clusterpages; ++i) { + unsigned pagenr; + + page = compressed_pages[i]; + + /* all compressed pages ought to be valid */ + DBG_BUGON(page == NULL); + DBG_BUGON(page->mapping == NULL); + + if (z_erofs_is_stagingpage(page)) + continue; + + /* only non-head page could be reused as a compressed page */ + pagenr = z_erofs_onlinepage_index(page); + + BUG_ON(pagenr >= nr_pages); +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF + BUG_ON(pages[pagenr] != NULL); + ++sparsemem_pages; +#endif + pages[pagenr] = page; + + overlapped = true; + } + + llen = (nr_pages << PAGE_SHIFT) - work->pageofs; + + if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { + /* FIXME! this should be fixed in the future */ + BUG_ON(grp->llen != llen); + + err = z_erofs_vle_plain_copy(compressed_pages, clusterpages, + pages, nr_pages, work->pageofs); + goto out; + } + + if (llen > grp->llen) + llen = grp->llen; + + err = z_erofs_vle_unzip_fast_percpu(compressed_pages, + clusterpages, pages, llen, work->pageofs, + z_erofs_onlinepage_endio); + if (err != -ENOTSUPP) + goto out_percpu; + +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF + if (sparsemem_pages >= nr_pages) { + BUG_ON(sparsemem_pages > nr_pages); + goto skip_allocpage; + } +#endif + + for (i = 0; i < nr_pages; ++i) { + if (pages[i] != NULL) + continue; + + pages[i] = __stagingpage_alloc(page_pool, GFP_NOFS); + } + +#ifndef CONFIG_EROFS_FS_ZIP_MULTIREF +skip_allocpage: +#endif + vout = erofs_vmap(pages, nr_pages); + + err = z_erofs_vle_unzip_vmap(compressed_pages, + clusterpages, vout, llen, work->pageofs, overlapped); + + erofs_vunmap(vout, nr_pages); + +out: + for (i = 0; i < nr_pages; ++i) { + page = pages[i]; + DBG_BUGON(page->mapping == NULL); + + /* recycle all individual staging pages */ + if (z_erofs_gather_if_stagingpage(page_pool, page)) + continue; + + if (unlikely(err < 0)) + SetPageError(page); + + z_erofs_onlinepage_endio(page); + } + +out_percpu: + for (i = 0; i < clusterpages; ++i) { + page = compressed_pages[i]; + + /* recycle all individual staging pages */ + (void)z_erofs_gather_if_stagingpage(page_pool, page); + + WRITE_ONCE(compressed_pages[i], NULL); + } + + if (pages == z_pagemap_global) + mutex_unlock(&z_pagemap_global_lock); + else if (unlikely(pages != pages_onstack)) + kvfree(pages); + + work->nr_pages = 0; + work->vcnt = 0; + + /* all work locks MUST be taken before the following line */ + + WRITE_ONCE(grp->next, Z_EROFS_VLE_WORKGRP_NIL); + + /* all work locks SHOULD be released right now */ + mutex_unlock(&work->lock); + + z_erofs_vle_work_release(work); + return err; +} + +static void z_erofs_vle_unzip_all(struct super_block *sb, + struct z_erofs_vle_unzip_io *io, + struct list_head *page_pool) +{ + z_erofs_vle_owned_workgrp_t owned = io->head; + + while (owned != Z_EROFS_VLE_WORKGRP_TAIL_CLOSED) { + struct z_erofs_vle_workgroup *grp; + + /* no possible that 'owned' equals Z_EROFS_WORK_TPTR_TAIL */ + DBG_BUGON(owned == Z_EROFS_VLE_WORKGRP_TAIL); + + /* no possible that 'owned' equals NULL */ + DBG_BUGON(owned == Z_EROFS_VLE_WORKGRP_NIL); + + grp = owned; + owned = READ_ONCE(grp->next); + + z_erofs_vle_unzip(sb, grp, page_pool); + }; +} + +static void z_erofs_vle_unzip_wq(struct work_struct *work) +{ + struct z_erofs_vle_unzip_io_sb *iosb = container_of(work, + struct z_erofs_vle_unzip_io_sb, io.u.work); + LIST_HEAD(page_pool); + + BUG_ON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + z_erofs_vle_unzip_all(iosb->sb, &iosb->io, &page_pool); + + put_pages_list(&page_pool); + kvfree(iosb); +} + +static inline struct z_erofs_vle_unzip_io * +prepare_io_handler(struct super_block *sb, + struct z_erofs_vle_unzip_io *io, + bool background) +{ + struct z_erofs_vle_unzip_io_sb *iosb; + + if (!background) { + /* waitqueue available for foreground io */ + BUG_ON(io == NULL); + + init_waitqueue_head(&io->u.wait); + atomic_set(&io->pending_bios, 0); + goto out; + } + + if (io != NULL) + BUG(); + else { + /* allocate extra io descriptor for background io */ + iosb = kvzalloc(sizeof(struct z_erofs_vle_unzip_io_sb), + GFP_KERNEL | __GFP_NOFAIL); + BUG_ON(iosb == NULL); + + io = &iosb->io; + } + + iosb->sb = sb; + INIT_WORK(&io->u.work, z_erofs_vle_unzip_wq); +out: + io->head = Z_EROFS_VLE_WORKGRP_TAIL_CLOSED; + return io; +} + +#define __FSIO_1 0 + +static bool z_erofs_vle_submit_all(struct super_block *sb, + z_erofs_vle_owned_workgrp_t owned_head, + struct list_head *pagepool, + struct z_erofs_vle_unzip_io *fg_io, + bool force_fg) +{ + struct erofs_sb_info *const sbi = EROFS_SB(sb); + const unsigned clusterpages = erofs_clusterpages(sbi); + const gfp_t gfp = GFP_NOFS; + struct z_erofs_vle_unzip_io *ios[1 + __FSIO_1]; + struct bio *bio; + tagptr1_t bi_private; + /* since bio will be NULL, no need to initialize last_index */ + pgoff_t uninitialized_var(last_index); + bool force_submit = false; + unsigned nr_bios; + + if (unlikely(owned_head == Z_EROFS_VLE_WORKGRP_TAIL)) + return false; + + /* + * force_fg == 1, (io, fg_io[0]) no io, (io, fg_io[1]) need submit io + * force_fg == 0, (io, fg_io[0]) no io; (io[1], bg_io) need submit io + */ + if (force_fg) { + ios[__FSIO_1] = prepare_io_handler(sb, fg_io + __FSIO_1, false); + bi_private = tagptr_fold(tagptr1_t, ios[__FSIO_1], 0); + } else { + ios[__FSIO_1] = prepare_io_handler(sb, NULL, true); + bi_private = tagptr_fold(tagptr1_t, ios[__FSIO_1], 1); + } + + nr_bios = 0; + force_submit = false; + bio = NULL; + + /* by default, all need io submission */ + ios[__FSIO_1]->head = owned_head; + + do { + struct z_erofs_vle_workgroup *grp; + struct page **compressed_pages, *oldpage, *page; + pgoff_t first_index; + unsigned i = 0; + int err; + + /* no possible 'owned_head' equals the following */ + DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_NIL); + + grp = owned_head; + + /* close the main owned chain at first */ + owned_head = cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_TAIL, + Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + + first_index = grp->obj.index; + compressed_pages = grp->compressed_pages; + + force_submit |= (first_index != last_index + 1); +repeat: + /* fulfill all compressed pages */ + oldpage = page = READ_ONCE(compressed_pages[i]); + + if (page != NULL) + BUG_ON(PageUptodate(page)); + else { + page = __stagingpage_alloc(pagepool, gfp); + + if (oldpage != cmpxchg(compressed_pages + i, + oldpage, page)) { + list_add(&page->lru, pagepool); + goto repeat; + } + } + + if (bio != NULL && force_submit) { +submit_bio_retry: + __submit_bio(bio, REQ_OP_READ, 0); + bio = NULL; + } + + if (bio == NULL) { + bio = prepare_bio(sb, first_index + i, + BIO_MAX_PAGES, z_erofs_vle_read_endio); + bio->bi_private = tagptr_cast_ptr(bi_private); + + ++nr_bios; + } + + err = bio_add_page(bio, page, PAGE_SIZE, 0); + if (err < PAGE_SIZE) + goto submit_bio_retry; + + force_submit = false; + last_index = first_index + i; + if (++i < clusterpages) + goto repeat; + } while (owned_head != Z_EROFS_VLE_WORKGRP_TAIL); + + if (bio != NULL) + __submit_bio(bio, REQ_OP_READ, 0); + + BUG_ON(!nr_bios); + + z_erofs_vle_unzip_kickoff(tagptr_cast_ptr(bi_private), nr_bios); + return true; +} + +static void z_erofs_submit_and_unzip(struct z_erofs_vle_frontend *f, + struct list_head *pagepool, + bool force_fg) +{ + struct super_block *sb = f->inode->i_sb; + struct z_erofs_vle_unzip_io io[1 + __FSIO_1]; + + if (!z_erofs_vle_submit_all(sb, f->owned_head, pagepool, io, force_fg)) + return; + + if (!force_fg) + return; + + /* wait until all bios are completed */ + wait_event(io[__FSIO_1].u.wait, + !atomic_read(&io[__FSIO_1].pending_bios)); + + /* let's synchronous decompression */ + z_erofs_vle_unzip_all(sb, &io[__FSIO_1], pagepool); +} + +static int z_erofs_vle_normalaccess_readpage(struct file *file, + struct page *page) +{ + struct inode *const inode = page->mapping->host; + struct z_erofs_vle_frontend f = VLE_FRONTEND_INIT(inode); + int err; + LIST_HEAD(pagepool); + + err = z_erofs_do_read_page(&f, page, &pagepool); + (void)z_erofs_vle_work_iter_end(&f.builder); + + if (err) { + errln("%s, failed to read, err [%d]", __func__, err); + goto out; + } + + z_erofs_submit_and_unzip(&f, &pagepool, true); +out: + if (f.m_iter.mpage != NULL) + put_page(f.m_iter.mpage); + + /* clean up the remaining free pages */ + put_pages_list(&pagepool); + return 0; +} + +static inline int __z_erofs_vle_normalaccess_readpages( + struct file *filp, + struct address_space *mapping, + struct list_head *pages, unsigned nr_pages, bool sync) +{ + struct inode *const inode = mapping->host; + + struct z_erofs_vle_frontend f = VLE_FRONTEND_INIT(inode); + gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL); + struct page *head = NULL; + LIST_HEAD(pagepool); + + for (; nr_pages; --nr_pages) { + struct page *page = lru_to_page(pages); + + prefetchw(&page->flags); + list_del(&page->lru); + + if (add_to_page_cache_lru(page, mapping, page->index, gfp)) { + list_add(&page->lru, &pagepool); + continue; + } + + BUG_ON(PagePrivate(page)); + set_page_private(page, (unsigned long)head); + head = page; + } + + while (head != NULL) { + struct page *page = head; + int err; + + /* traversal in reverse order */ + head = (void *)page_private(page); + + err = z_erofs_do_read_page(&f, page, &pagepool); + if (err) { + struct erofs_vnode *vi = EROFS_V(inode); + + errln("%s, readahead error at page %lu of nid %llu", + __func__, page->index, vi->nid); + } + + put_page(page); + } + + (void)z_erofs_vle_work_iter_end(&f.builder); + + z_erofs_submit_and_unzip(&f, &pagepool, sync); + + if (f.m_iter.mpage != NULL) + put_page(f.m_iter.mpage); + + /* clean up the remaining free pages */ + put_pages_list(&pagepool); + return 0; +} + +static int z_erofs_vle_normalaccess_readpages( + struct file *filp, + struct address_space *mapping, + struct list_head *pages, unsigned nr_pages) +{ + return __z_erofs_vle_normalaccess_readpages(filp, + mapping, pages, nr_pages, + nr_pages < 4 /* sync */); +} + +const struct address_space_operations z_erofs_vle_normalaccess_aops = { + .readpage = z_erofs_vle_normalaccess_readpage, + .readpages = z_erofs_vle_normalaccess_readpages, +}; #define __vle_cluster_advise(x, bit, bits) \ ((le16_to_cpu(x) >> (bit)) & ((1 << (bits)) - 1)) diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index b34f5bc28d29..3521dfb31906 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -14,9 +14,213 @@ #define __EROFS_FS_UNZIP_VLE_H #include "internal.h" +#include "unzip_pagevec.h" + +/* + * - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) - + * used for temporary allocated pages (via erofs_allocpage), + * in order to seperate those from NULL mapping (eg. truncated pages) + */ +#define Z_EROFS_MAPPING_STAGING ((void *)0x5A110C8D) + +#define z_erofs_is_stagingpage(page) \ + ((page)->mapping == Z_EROFS_MAPPING_STAGING) + +static inline bool z_erofs_gather_if_stagingpage(struct list_head *page_pool, + struct page *page) +{ + if (z_erofs_is_stagingpage(page)) { + list_add(&page->lru, page_pool); + return true; + } + return false; +} + +/* + * Structure fields follow one of the following exclusion rules. + * + * I: Modifiable by initialization/destruction paths and read-only + * for everyone else. + * + */ #define Z_EROFS_VLE_INLINE_PAGEVECS 3 +struct z_erofs_vle_work { + /* struct z_erofs_vle_work *left, *right; */ + +#ifdef CONFIG_EROFS_FS_ZIP_MULTIREF + struct list_head list; + + atomic_t refcount; +#endif + struct mutex lock; + + /* I: decompression offset in page */ + unsigned short pageofs; + unsigned short nr_pages; + + /* L: queued pages in pagevec[] */ + unsigned vcnt; + + union { + /* L: pagevec */ + erofs_vtptr_t pagevec[Z_EROFS_VLE_INLINE_PAGEVECS]; + struct rcu_head rcu; + }; +}; + +#define Z_EROFS_VLE_WORKGRP_FMT_PLAIN 0 +#define Z_EROFS_VLE_WORKGRP_FMT_LZ4 1 +#define Z_EROFS_VLE_WORKGRP_FMT_MASK 1 + +typedef struct z_erofs_vle_workgroup *z_erofs_vle_owned_workgrp_t; + +struct z_erofs_vle_workgroup { + struct erofs_workgroup obj; + struct z_erofs_vle_work work; + + /* next owned workgroup */ + z_erofs_vle_owned_workgrp_t next; + + /* compressed pages (including multi-usage pages) */ + struct page *compressed_pages[Z_EROFS_CLUSTER_MAX_PAGES]; + unsigned int llen, flags; +}; + +/* let's avoid the valid 32-bit kernel addresses */ + +/* the chained workgroup has't submitted io (still open) */ +#define Z_EROFS_VLE_WORKGRP_TAIL ((void *)0x5F0ECAFE) +/* the chained workgroup has already submitted io */ +#define Z_EROFS_VLE_WORKGRP_TAIL_CLOSED ((void *)0x5F0EDEAD) + +#define Z_EROFS_VLE_WORKGRP_NIL (NULL) + +#define z_erofs_vle_workgrp_fmt(grp) \ + ((grp)->flags & Z_EROFS_VLE_WORKGRP_FMT_MASK) + +static inline void z_erofs_vle_set_workgrp_fmt( + struct z_erofs_vle_workgroup *grp, + unsigned int fmt) +{ + grp->flags = fmt | (grp->flags & ~Z_EROFS_VLE_WORKGRP_FMT_MASK); +} + +#ifdef CONFIG_EROFS_FS_ZIP_MULTIREF +#error multiref decompression is unimplemented yet +#else + +#define z_erofs_vle_grab_primary_work(grp) (&(grp)->work) +#define z_erofs_vle_grab_work(grp, pageofs) (&(grp)->work) +#define z_erofs_vle_work_workgroup(wrk, primary) \ + ((primary) ? container_of(wrk, \ + struct z_erofs_vle_workgroup, work) : \ + ({ BUG(); (void *)NULL; })) + +#endif + +#define Z_EROFS_WORKGROUP_SIZE sizeof(struct z_erofs_vle_workgroup) + +struct z_erofs_vle_unzip_io { + atomic_t pending_bios; + z_erofs_vle_owned_workgrp_t head; + + union { + wait_queue_head_t wait; + struct work_struct work; + } u; +}; + +struct z_erofs_vle_unzip_io_sb { + struct z_erofs_vle_unzip_io io; + struct super_block *sb; +}; + +#define Z_EROFS_ONLINEPAGE_COUNT_BITS 2 +#define Z_EROFS_ONLINEPAGE_COUNT_MASK ((1 << Z_EROFS_ONLINEPAGE_COUNT_BITS) - 1) +#define Z_EROFS_ONLINEPAGE_INDEX_SHIFT (Z_EROFS_ONLINEPAGE_COUNT_BITS) + +/* + * waiters (aka. ongoing_packs): # to unlock the page + * sub-index: 0 - for partial page, >= 1 full page sub-index + */ +typedef atomic_t z_erofs_onlinepage_t; + +/* type punning */ +union z_erofs_onlinepage_converter { + z_erofs_onlinepage_t *o; + unsigned long *v; +}; + +static inline unsigned z_erofs_onlinepage_index(struct page *page) +{ + union z_erofs_onlinepage_converter u; + + BUG_ON(!PagePrivate(page)); + u.v = &page_private(page); + + return atomic_read(u.o) >> Z_EROFS_ONLINEPAGE_INDEX_SHIFT; +} + +static inline void z_erofs_onlinepage_init(struct page *page) +{ + union { + z_erofs_onlinepage_t o; + unsigned long v; + /* keep from being unlocked in advance */ + } u = { .o = ATOMIC_INIT(1) }; + + set_page_private(page, u.v); + smp_wmb(); + SetPagePrivate(page); +} + +static inline void z_erofs_onlinepage_fixup(struct page *page, + uintptr_t index, bool down) +{ + unsigned long *p, o, v, id; +repeat: + p = &page_private(page); + o = READ_ONCE(*p); + + id = o >> Z_EROFS_ONLINEPAGE_INDEX_SHIFT; + if (id) { + if (!index) + return; + + BUG_ON(id != index); + } + + v = (index << Z_EROFS_ONLINEPAGE_INDEX_SHIFT) | + ((o & Z_EROFS_ONLINEPAGE_COUNT_MASK) + (unsigned)down); + if (cmpxchg(p, o, v) != o) + goto repeat; +} + +static inline void z_erofs_onlinepage_endio(struct page *page) +{ + union z_erofs_onlinepage_converter u; + unsigned v; + + BUG_ON(!PagePrivate(page)); + u.v = &page_private(page); + + v = atomic_dec_return(u.o); + if (!(v & Z_EROFS_ONLINEPAGE_COUNT_MASK)) { + ClearPagePrivate(page); + if (!PageError(page)) + SetPageUptodate(page); + unlock_page(page); + } + + debugln("%s, page %p value %x", __func__, page, atomic_read(u.o)); +} + +#define Z_EROFS_VLE_VMAP_ONSTACK_PAGES \ + min(THREAD_SIZE / 8 / sizeof(struct page *), 96UL) +#define Z_EROFS_VLE_VMAP_GLOBAL_PAGES 2048 + /* unzip_vle_lz4.c */ extern int z_erofs_vle_plain_copy(struct page **compressed_pages, unsigned clusterpages, struct page **pages, diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index 0d4eae2f79a8..6530035f8a61 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -12,6 +12,7 @@ */ #include "internal.h" +#include struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) { @@ -98,11 +99,69 @@ int erofs_register_workgroup(struct super_block *sb, return err; } +extern void erofs_workgroup_free_rcu(struct erofs_workgroup *grp); + +int erofs_workgroup_put(struct erofs_workgroup *grp) +{ + int count = atomic_dec_return(&grp->refcount); + + if (count == 1) + atomic_long_inc(&erofs_global_shrink_cnt); + else if (!count) { + atomic_long_dec(&erofs_global_shrink_cnt); + erofs_workgroup_free_rcu(grp); + } + return count; +} + unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi, unsigned long nr_shrink, bool cleanup) { - return 0; + pgoff_t first_index = 0; + void *batch[PAGEVEC_SIZE]; + unsigned freed = 0; + + int i, found; +repeat: + erofs_workstn_lock(sbi); + + found = radix_tree_gang_lookup(&sbi->workstn_tree, + batch, first_index, PAGEVEC_SIZE); + + for (i = 0; i < found; ++i) { + int cnt; + struct erofs_workgroup *grp = (void *) + ((unsigned long)batch[i] & + ~RADIX_TREE_EXCEPTIONAL_ENTRY); + + first_index = grp->index + 1; + + cnt = atomic_read(&grp->refcount); + BUG_ON(cnt <= 0); + + if (cleanup) + BUG_ON(cnt != 1); + + else if (cnt > 1) + continue; + + if (radix_tree_delete(&sbi->workstn_tree, + grp->index) != grp) + continue; + + /* (rarely) grabbed again when freeing */ + erofs_workgroup_put(grp); + + ++freed; + if (unlikely(!--nr_shrink)) + break; + } + erofs_workstn_unlock(sbi); + + if (i && nr_shrink) + goto repeat; + return freed; } #endif From 105d4ad857dcbf3dc1288f339c5b09dafbc8f923 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:07 +0800 Subject: [PATCH 621/903] staging: erofs: introduce cached decompression This patch adds an optional choice which can be enabled by users in order to cache both incomplete ends of compressed clusters as a complement to the in-place decompression in order to boost random read, but it costs more memory than the in-place decompression only. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Kconfig | 38 +++++ drivers/staging/erofs/internal.h | 26 +++ drivers/staging/erofs/super.c | 73 ++++++++ drivers/staging/erofs/unzip_vle.c | 274 ++++++++++++++++++++++++++++++ drivers/staging/erofs/utils.c | 17 +- 5 files changed, 427 insertions(+), 1 deletion(-) diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index b55ce1cf3bc7..663b755bf2fb 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig @@ -101,3 +101,41 @@ config EROFS_FS_CLUSTER_PAGE_LIMIT than 2. Otherwise, the image cannot be mounted correctly on this kernel. +choice + prompt "EROFS VLE Data Decompression mode" + depends on EROFS_FS_ZIP + default EROFS_FS_ZIP_CACHE_BIPOLAR + help + EROFS supports three options for VLE decompression. + "In-place Decompression Only" consumes the minimum memory + with lowest random read. + + "Bipolar Cached Decompression" consumes the maximum memory + with highest random read. + + If unsure, select "Bipolar Cached Decompression" + +config EROFS_FS_ZIP_NO_CACHE + bool "In-place Decompression Only" + help + Read compressed data into page cache and do in-place + decompression directly. + +config EROFS_FS_ZIP_CACHE_UNIPOLAR + bool "Unipolar Cached Decompression" + help + For each request, it caches the last compressed page + for further reading. + It still decompresses in place for the rest compressed pages. + +config EROFS_FS_ZIP_CACHE_BIPOLAR + bool "Bipolar Cached Decompression" + help + For each request, it caches the both end compressed pages + for further reading. + It still decompresses in place for the rest compressed pages. + + Recommended for performance priority. + +endchoice + diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 3adec7d95d3e..669f93ae6920 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -58,6 +58,18 @@ struct erofs_fault_info { }; #endif +#ifdef CONFIG_EROFS_FS_ZIP_CACHE_BIPOLAR +#define EROFS_FS_ZIP_CACHE_LVL (2) +#elif defined(EROFS_FS_ZIP_CACHE_UNIPOLAR) +#define EROFS_FS_ZIP_CACHE_LVL (1) +#else +#define EROFS_FS_ZIP_CACHE_LVL (0) +#endif + +#if (!defined(EROFS_FS_HAS_MANAGED_CACHE) && (EROFS_FS_ZIP_CACHE_LVL > 0)) +#define EROFS_FS_HAS_MANAGED_CACHE +#endif + /* EROFS_SUPER_MAGIC_V1 to represent the whole file system */ #define EROFS_SUPER_MAGIC EROFS_SUPER_MAGIC_V1 @@ -82,6 +94,11 @@ struct erofs_sb_info { /* the dedicated workstation for compression */ struct radix_tree_root workstn_tree; + +#ifdef EROFS_FS_HAS_MANAGED_CACHE + struct inode *managed_cache; +#endif + #endif u32 build_time_nsec; @@ -240,6 +257,15 @@ static inline void erofs_workstation_cleanup_all(struct super_block *sb) erofs_shrink_workstation(EROFS_SB(sb), ~0UL, true); } +#ifdef EROFS_FS_HAS_MANAGED_CACHE +#define EROFS_UNALLOCATED_CACHED_PAGE ((void *)0x5F0EF00D) + +extern int try_to_free_all_cached_pages(struct erofs_sb_info *sbi, + struct erofs_workgroup *egrp); +extern int try_to_free_cached_page(struct address_space *mapping, + struct page *page); +#endif + #endif /* we strictly follow PAGE_SIZE and no buffer head yet */ diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 2bd433ab4c49..97da5c8a8ef3 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -256,6 +256,63 @@ static int parse_options(struct super_block *sb, char *options) return 0; } +#ifdef EROFS_FS_HAS_MANAGED_CACHE + +static const struct address_space_operations managed_cache_aops; + +static int managed_cache_releasepage(struct page *page, gfp_t gfp_mask) +{ + int ret = 1; /* 0 - busy */ + struct address_space *const mapping = page->mapping; + + BUG_ON(!PageLocked(page)); + BUG_ON(mapping->a_ops != &managed_cache_aops); + + if (PagePrivate(page)) + ret = try_to_free_cached_page(mapping, page); + + return ret; +} + +static void managed_cache_invalidatepage(struct page *page, + unsigned int offset, unsigned int length) +{ + const unsigned int stop = length + offset; + + BUG_ON(!PageLocked(page)); + + /* Check for overflow */ + BUG_ON(stop > PAGE_SIZE || stop < length); + + if (offset == 0 && stop == PAGE_SIZE) + while (!managed_cache_releasepage(page, GFP_NOFS)) + cond_resched(); +} + +static const struct address_space_operations managed_cache_aops = { + .releasepage = managed_cache_releasepage, + .invalidatepage = managed_cache_invalidatepage, +}; + +static struct inode *erofs_init_managed_cache(struct super_block *sb) +{ + struct inode *inode = new_inode(sb); + + if (unlikely(inode == NULL)) + return ERR_PTR(-ENOMEM); + + set_nlink(inode, 1); + inode->i_size = OFFSET_MAX; + + inode->i_mapping->a_ops = &managed_cache_aops; + mapping_set_gfp_mask(inode->i_mapping, + GFP_NOFS | __GFP_HIGHMEM | + __GFP_MOVABLE | __GFP_NOFAIL); + return inode; +} + +#endif + static int erofs_read_super(struct super_block *sb, const char *dev_name, void *data, int silent) { @@ -307,6 +364,14 @@ static int erofs_read_super(struct super_block *sb, INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC); #endif +#ifdef EROFS_FS_HAS_MANAGED_CACHE + sbi->managed_cache = erofs_init_managed_cache(sb); + if (IS_ERR(sbi->managed_cache)) { + err = PTR_ERR(sbi->managed_cache); + goto err_init_managed_cache; + } +#endif + /* get the root inode */ inode = erofs_iget(sb, ROOT_NID(sbi), true); if (IS_ERR(inode)) { @@ -361,6 +426,10 @@ err_isdir: if (sb->s_root == NULL) iput(inode); err_iget: +#ifdef EROFS_FS_HAS_MANAGED_CACHE + iput(sbi->managed_cache); +err_init_managed_cache: +#endif err_parseopt: err_sbread: sb->s_fs_info = NULL; @@ -386,6 +455,10 @@ static void erofs_put_super(struct super_block *sb) infoln("unmounted for %s", sbi->dev_name); __putname(sbi->dev_name); +#ifdef EROFS_FS_HAS_MANAGED_CACHE + iput(sbi->managed_cache); +#endif + mutex_lock(&sbi->umount_mutex); #ifdef CONFIG_EROFS_FS_ZIP diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index f0ead60a8fee..7671fe8194ce 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -95,6 +95,111 @@ struct z_erofs_vle_work_builder { #define VLE_WORK_BUILDER_INIT() \ { .work = NULL, .role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED } +#ifdef EROFS_FS_HAS_MANAGED_CACHE + +static bool grab_managed_cache_pages(struct address_space *mapping, + erofs_blk_t start, + struct page **compressed_pages, + int clusterblks, + bool reserve_allocation) +{ + bool noio = true; + unsigned int i; + + /* TODO: optimize by introducing find_get_pages_range */ + for (i = 0; i < clusterblks; ++i) { + struct page *page, *found; + + if (READ_ONCE(compressed_pages[i]) != NULL) + continue; + + page = found = find_get_page(mapping, start + i); + if (found == NULL) { + noio = false; + if (!reserve_allocation) + continue; + page = EROFS_UNALLOCATED_CACHED_PAGE; + } + + if (NULL == cmpxchg(compressed_pages + i, NULL, page)) + continue; + + if (found != NULL) + put_page(found); + } + return noio; +} + +/* called by erofs_shrinker to get rid of all compressed_pages */ +int try_to_free_all_cached_pages(struct erofs_sb_info *sbi, + struct erofs_workgroup *egrp) +{ + struct z_erofs_vle_workgroup *const grp = + container_of(egrp, struct z_erofs_vle_workgroup, obj); + struct address_space *const mapping = sbi->managed_cache->i_mapping; + const int clusterpages = erofs_clusterpages(sbi); + int i; + + /* + * refcount of workgroup is now freezed as 1, + * therefore no need to worry about available decompression users. + */ + for (i = 0; i < clusterpages; ++i) { + struct page *page = grp->compressed_pages[i]; + + if (page == NULL || page->mapping != mapping) + continue; + + /* block other users from reclaiming or migrating the page */ + if (!trylock_page(page)) + return -EBUSY; + + /* barrier is implied in the following 'unlock_page' */ + WRITE_ONCE(grp->compressed_pages[i], NULL); + + set_page_private(page, 0); + ClearPagePrivate(page); + + unlock_page(page); + put_page(page); + } + return 0; +} + +int try_to_free_cached_page(struct address_space *mapping, struct page *page) +{ + struct erofs_sb_info *const sbi = EROFS_SB(mapping->host->i_sb); + const unsigned int clusterpages = erofs_clusterpages(sbi); + + struct z_erofs_vle_workgroup *grp; + int ret = 0; /* 0 - busy */ + + /* prevent the workgroup from being freed */ + rcu_read_lock(); + grp = (void *)page_private(page); + + if (erofs_workgroup_try_to_freeze(&grp->obj, 1)) { + unsigned int i; + + for (i = 0; i < clusterpages; ++i) { + if (grp->compressed_pages[i] == page) { + WRITE_ONCE(grp->compressed_pages[i], NULL); + ret = 1; + break; + } + } + erofs_workgroup_unfreeze(&grp->obj, 1); + } + rcu_read_unlock(); + + if (ret) { + ClearPagePrivate(page); + put_page(page); + } + return ret; +} +#endif + /* page_type must be Z_EROFS_PAGE_TYPE_EXCLUSIVE */ static inline bool try_to_reuse_as_compressed_page( struct z_erofs_vle_work_builder *b, @@ -463,6 +568,9 @@ struct z_erofs_vle_frontend { z_erofs_vle_owned_workgrp_t owned_head; bool initial; +#if (EROFS_FS_ZIP_CACHE_LVL >= 2) + erofs_off_t cachedzone_la; +#endif }; #define VLE_FRONTEND_INIT(__i) { \ @@ -489,6 +597,12 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, bool tight = builder_is_followed(builder); struct z_erofs_vle_work *work = builder->work; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + struct address_space *const mngda = sbi->managed_cache->i_mapping; + struct z_erofs_vle_workgroup *grp; + bool noio_outoforder; +#endif + enum z_erofs_page_type page_type; unsigned cur, end, spiltted, index; int err; @@ -529,6 +643,21 @@ repeat: if (unlikely(err)) goto err_out; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + grp = fe->builder.grp; + + /* let's do out-of-order decompression for noio */ + noio_outoforder = grab_managed_cache_pages(mngda, + erofs_blknr(map->m_pa), + grp->compressed_pages, erofs_blknr(map->m_plen), + /* compressed page caching selection strategy */ + fe->initial | (EROFS_FS_ZIP_CACHE_LVL >= 2 ? + map->m_la < fe->cachedzone_la : 0)); + + if (noio_outoforder && builder_is_followed(builder)) + builder->role = Z_EROFS_VLE_WORK_PRIMARY; +#endif + tight &= builder_is_followed(builder); work = builder->work; hitted: @@ -607,15 +736,39 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) const blk_status_t err = bio->bi_status; unsigned i; struct bio_vec *bvec; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + struct address_space *mngda = NULL; +#endif bio_for_each_segment_all(bvec, bio, i) { struct page *page = bvec->bv_page; + bool cachemngd = false; DBG_BUGON(PageUptodate(page)); BUG_ON(page->mapping == NULL); +#ifdef EROFS_FS_HAS_MANAGED_CACHE + if (unlikely(mngda == NULL && !z_erofs_is_stagingpage(page))) { + struct inode *const inode = page->mapping->host; + struct super_block *const sb = inode->i_sb; + + mngda = EROFS_SB(sb)->managed_cache->i_mapping; + } + + /* + * If mngda has not gotten, it equals NULL, + * however, page->mapping never be NULL if working properly. + */ + cachemngd = (page->mapping == mngda); +#endif + if (unlikely(err)) SetPageError(page); + else if (cachemngd) + SetPageUptodate(page); + + if (cachemngd) + unlock_page(page); } z_erofs_vle_unzip_kickoff(bio->bi_private, -1); @@ -630,6 +783,9 @@ static int z_erofs_vle_unzip(struct super_block *sb, struct list_head *page_pool) { struct erofs_sb_info *const sbi = EROFS_SB(sb); +#ifdef EROFS_FS_HAS_MANAGED_CACHE + struct address_space *const mngda = sbi->managed_cache->i_mapping; +#endif const unsigned clusterpages = erofs_clusterpages(sbi); struct z_erofs_pagevec_ctor ctor; @@ -727,6 +883,13 @@ repeat: if (z_erofs_is_stagingpage(page)) continue; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + else if (page->mapping == mngda) { + BUG_ON(PageLocked(page)); + BUG_ON(!PageUptodate(page)); + continue; + } +#endif /* only non-head page could be reused as a compressed page */ pagenr = z_erofs_onlinepage_index(page); @@ -804,6 +967,10 @@ out_percpu: for (i = 0; i < clusterpages; ++i) { page = compressed_pages[i]; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + if (page->mapping == mngda) + continue; +#endif /* recycle all individual staging pages */ (void)z_erofs_gather_if_stagingpage(page_pool, page); @@ -898,7 +1065,31 @@ out: return io; } +#ifdef EROFS_FS_HAS_MANAGED_CACHE +/* true - unlocked (noio), false - locked (need submit io) */ +static inline bool recover_managed_page(struct z_erofs_vle_workgroup *grp, + struct page *page) +{ + wait_on_page_locked(page); + if (PagePrivate(page) && PageUptodate(page)) + return true; + + lock_page(page); + if (unlikely(!PagePrivate(page))) { + set_page_private(page, (unsigned long)grp); + SetPagePrivate(page); + } + if (unlikely(PageUptodate(page))) { + unlock_page(page); + return true; + } + return false; +} + +#define __FSIO_1 1 +#else #define __FSIO_1 0 +#endif static bool z_erofs_vle_submit_all(struct super_block *sb, z_erofs_vle_owned_workgrp_t owned_head, @@ -909,6 +1100,10 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, struct erofs_sb_info *const sbi = EROFS_SB(sb); const unsigned clusterpages = erofs_clusterpages(sbi); const gfp_t gfp = GFP_NOFS; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + struct address_space *const mngda = sbi->managed_cache->i_mapping; + struct z_erofs_vle_workgroup *lstgrp_noio = NULL, *lstgrp_io = NULL; +#endif struct z_erofs_vle_unzip_io *ios[1 + __FSIO_1]; struct bio *bio; tagptr1_t bi_private; @@ -924,6 +1119,10 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, * force_fg == 1, (io, fg_io[0]) no io, (io, fg_io[1]) need submit io * force_fg == 0, (io, fg_io[0]) no io; (io[1], bg_io) need submit io */ +#ifdef EROFS_FS_HAS_MANAGED_CACHE + ios[0] = prepare_io_handler(sb, fg_io + 0, false); +#endif + if (force_fg) { ios[__FSIO_1] = prepare_io_handler(sb, fg_io + __FSIO_1, false); bi_private = tagptr_fold(tagptr1_t, ios[__FSIO_1], 0); @@ -944,6 +1143,10 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, struct page **compressed_pages, *oldpage, *page; pgoff_t first_index; unsigned i = 0; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + unsigned int noio = 0; + bool cachemngd; +#endif int err; /* no possible 'owned_head' equals the following */ @@ -964,15 +1167,40 @@ repeat: /* fulfill all compressed pages */ oldpage = page = READ_ONCE(compressed_pages[i]); +#ifdef EROFS_FS_HAS_MANAGED_CACHE + cachemngd = false; + + if (page == EROFS_UNALLOCATED_CACHED_PAGE) { + cachemngd = true; + goto do_allocpage; + } else if (page != NULL) { + if (page->mapping != mngda) + BUG_ON(PageUptodate(page)); + else if (recover_managed_page(grp, page)) { + /* page is uptodate, skip io submission */ + force_submit = true; + ++noio; + goto skippage; + } + } else { +do_allocpage: +#else if (page != NULL) BUG_ON(PageUptodate(page)); else { +#endif page = __stagingpage_alloc(pagepool, gfp); if (oldpage != cmpxchg(compressed_pages + i, oldpage, page)) { list_add(&page->lru, pagepool); goto repeat; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + } else if (cachemngd && !add_to_page_cache_lru(page, + mngda, first_index + i, gfp)) { + set_page_private(page, (unsigned long)grp); + SetPagePrivate(page); +#endif } } @@ -996,14 +1224,51 @@ submit_bio_retry: force_submit = false; last_index = first_index + i; +#ifdef EROFS_FS_HAS_MANAGED_CACHE +skippage: +#endif if (++i < clusterpages) goto repeat; + +#ifdef EROFS_FS_HAS_MANAGED_CACHE + if (noio < clusterpages) { + lstgrp_io = grp; + } else { + z_erofs_vle_owned_workgrp_t iogrp_next = + owned_head == Z_EROFS_VLE_WORKGRP_TAIL ? + Z_EROFS_VLE_WORKGRP_TAIL_CLOSED : + owned_head; + + if (lstgrp_io == NULL) + ios[1]->head = iogrp_next; + else + WRITE_ONCE(lstgrp_io->next, iogrp_next); + + if (lstgrp_noio == NULL) + ios[0]->head = grp; + else + WRITE_ONCE(lstgrp_noio->next, grp); + + lstgrp_noio = grp; + } +#endif } while (owned_head != Z_EROFS_VLE_WORKGRP_TAIL); if (bio != NULL) __submit_bio(bio, REQ_OP_READ, 0); +#ifndef EROFS_FS_HAS_MANAGED_CACHE BUG_ON(!nr_bios); +#else + if (lstgrp_noio != NULL) + WRITE_ONCE(lstgrp_noio->next, Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + + if (!force_fg && !nr_bios) { + kvfree(container_of(ios[1], + struct z_erofs_vle_unzip_io_sb, io)); + return true; + } +#endif z_erofs_vle_unzip_kickoff(tagptr_cast_ptr(bi_private), nr_bios); return true; @@ -1019,6 +1284,9 @@ static void z_erofs_submit_and_unzip(struct z_erofs_vle_frontend *f, if (!z_erofs_vle_submit_all(sb, f->owned_head, pagepool, io, force_fg)) return; +#ifdef EROFS_FS_HAS_MANAGED_CACHE + z_erofs_vle_unzip_all(sb, &io[0], pagepool); +#endif if (!force_fg) return; @@ -1038,6 +1306,9 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file, int err; LIST_HEAD(pagepool); +#if (EROFS_FS_ZIP_CACHE_LVL >= 2) + f.cachedzone_la = page->index << PAGE_SHIFT; +#endif err = z_erofs_do_read_page(&f, page, &pagepool); (void)z_erofs_vle_work_iter_end(&f.builder); @@ -1068,6 +1339,9 @@ static inline int __z_erofs_vle_normalaccess_readpages( struct page *head = NULL; LIST_HEAD(pagepool); +#if (EROFS_FS_ZIP_CACHE_LVL >= 2) + f.cachedzone_la = lru_to_page(pages)->index << PAGE_SHIFT; +#endif for (; nr_pages; --nr_pages) { struct page *page = lru_to_page(pages); diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index 6530035f8a61..ee70bb9e1636 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -143,13 +143,28 @@ repeat: if (cleanup) BUG_ON(cnt != 1); +#ifndef EROFS_FS_HAS_MANAGED_CACHE else if (cnt > 1) +#else + if (!erofs_workgroup_try_to_freeze(grp, 1)) +#endif continue; if (radix_tree_delete(&sbi->workstn_tree, - grp->index) != grp) + grp->index) != grp) { +#ifdef EROFS_FS_HAS_MANAGED_CACHE +skip: + erofs_workgroup_unfreeze(grp, 1); +#endif continue; + } +#ifdef EROFS_FS_HAS_MANAGED_CACHE + if (try_to_free_all_cached_pages(sbi, grp)) + goto skip; + + erofs_workgroup_unfreeze(grp, 1); +#endif /* (rarely) grabbed again when freeing */ erofs_workgroup_put(grp); From 27cce7bc2f8154f3a3bebcf7f9923cd22477aef8 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 26 Jul 2018 20:22:08 +0800 Subject: [PATCH 622/903] staging: erofs: add a TODO and update MAINTAINERS for staging This patch adds a TODO to list the things to be done, and the relevant info to MAINTAINERS so we can take all the blame :) Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 7 ++++++ drivers/staging/erofs/TODO | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 drivers/staging/erofs/TODO diff --git a/MAINTAINERS b/MAINTAINERS index b9503cefc42d..119be5179650 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13515,6 +13515,13 @@ M: H Hartley Sweeten S: Odd Fixes F: drivers/staging/comedi/ +STAGING - EROFS FILE SYSTEM +M: Gao Xiang +M: Chao Yu +L: linux-erofs@lists.ozlabs.org +S: Maintained +F: drivers/staging/erofs/ + STAGING - FLARION FT1000 DRIVERS M: Marek Belisko S: Odd Fixes diff --git a/drivers/staging/erofs/TODO b/drivers/staging/erofs/TODO new file mode 100644 index 000000000000..f99ddb842f99 --- /dev/null +++ b/drivers/staging/erofs/TODO @@ -0,0 +1,45 @@ + +EROFS is still working in progress, thus it is not suitable +for all productive uses. play at your own risk :) + +TODO List: + - add the missing error handling code + (mainly existed in xattr and decompression submodules); + + - finalize erofs ondisk format design (which means that + minor on-disk revisions could happen later); + + - documentation and detailed technical analysis; + + - general code review and clean up + (including confusing variable names and code snippets); + + - support larger compressed clustersizes for selection + (currently erofs only works as expected with the page-sized + compressed cluster configuration, usually 4KB); + + - support more lossless data compression algorithms + in addition to LZ4 algorithms in VLE approach; + + - data deduplication and other useful features. + +erofs-mkfs (preview version) binaries for i386 / x86_64 are available at: + + https://github.com/hsiangkao/erofs_mkfs_binary + +It is still in progress opening mkfs source code to public, +in any case an open-source mkfs will be released in the near future. + + +Code, suggestions, etc, are welcome. Please feel free to +ask and send patches, + +To: + linux-erofs mailing list + Gao Xiang + Chao Yu + +Cc: (for linux-kernel upstream patches) + Greg Kroah-Hartman + linux-staging mailing list + From 81edee7ac83c5782859db4053a866fc0c29f982f Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 28 Jul 2018 15:10:32 +0800 Subject: [PATCH 623/903] staging: erofs: fix a compile warning of Z_EROFS_VLE_VMAP_ONSTACK_PAGES There is a type mismatch in the definition of Z_EROFS_VLE_VMAP_ONSTACK_PAGES, let's fix it. Link: https://lists.01.org/pipermail/kbuild-all/2018-July/050707.html Reported-by: kbuild test robot Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index 3521dfb31906..393998500865 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -218,7 +218,7 @@ static inline void z_erofs_onlinepage_endio(struct page *page) } #define Z_EROFS_VLE_VMAP_ONSTACK_PAGES \ - min(THREAD_SIZE / 8 / sizeof(struct page *), 96UL) + min_t(unsigned int, THREAD_SIZE / 8 / sizeof(struct page *), 96U) #define Z_EROFS_VLE_VMAP_GLOBAL_PAGES 2048 /* unzip_vle_lz4.c */ From e7cffa03b34265e17de55d5ef8983c91482643a0 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Fri, 27 Jul 2018 22:21:56 -0700 Subject: [PATCH 624/903] staging: gasket: sysfs: remove check for refcount already zero Remove the check for refcount already zero, which shouldn't be necessary. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index 418b81797e63..2d8647de697c 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -111,8 +111,6 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) } mutex_lock(&mapping->mutex); - if (refcount_read(&mapping->refcount.refcount) == 0) - dev_err(mapping->device, "Refcount is already 0\n"); if (kref_put(&mapping->refcount, release_entry)) { dev_dbg(mapping->device, "Removing Gasket sysfs mapping\n"); /* From f390d08d8b872a0f71db45bc970a238475679fac Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Fri, 27 Jul 2018 22:21:57 -0700 Subject: [PATCH 625/903] staging: gasket: apex: fixup undefined PCI class Apex chips with class 0 (PCI_CLASS_NOT_DEFINED) fixed up to PCI_CLASS_SYSTEM_OTHER to enable PCI resource assignments. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 73fc2683a834..ab466d49608a 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -739,3 +739,10 @@ static ssize_t sysfs_show( gasket_sysfs_put_device_data(device, gasket_dev); return ret; } + +static void apex_pci_fixup_class(struct pci_dev *pdev) +{ + pdev->class = (PCI_CLASS_SYSTEM_OTHER << 8) | pdev->class; +} +DECLARE_PCI_FIXUP_CLASS_HEADER(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID, + PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class); From 14d70229777f17fe3c22deb559821038663bae78 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Fri, 27 Jul 2018 22:21:58 -0700 Subject: [PATCH 626/903] staging: gasket: sysfs: remove unnecessary NULL check on device ptr The device pointer passed into get_mapping() will never be NULL; the check is unnecessary. Reported-by: Greg Kroah-Hartman Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index 2d8647de697c..da972ce0e0db 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -67,11 +67,6 @@ static struct gasket_sysfs_mapping *get_mapping(struct device *device) { int i; - if (!device) { - pr_debug("%s: Received NULL device\n", __func__); - return NULL; - } - for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) { mutex_lock(&dev_mappings[i].mutex); if (dev_mappings[i].device == device) { From 758c579ec631ce5efd8de3d3d35483416ae2cad1 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Fri, 27 Jul 2018 22:21:59 -0700 Subject: [PATCH 627/903] staging: gasket: page table: remove code for "no dma_ops" Remove code with TODOs on it for working around apparent problems previously seen in a qemu environment where dma_ops was not set correctly. There is no user of this in the current code. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 2 +- drivers/staging/gasket/gasket_page_table.c | 58 +++------------------- drivers/staging/gasket/gasket_page_table.h | 3 +- 3 files changed, 8 insertions(+), 55 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index f44805c38159..859a6df9e12d 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -916,7 +916,7 @@ static int gasket_enable_dev( &gasket_dev->bar_data[ driver_desc->page_table_bar_index], &driver_desc->page_table_configs[tbl_idx], - gasket_dev->dev, gasket_dev->pci_dev, true); + gasket_dev->dev, gasket_dev->pci_dev); if (ret) { dev_err(gasket_dev->dev, "Couldn't init page table %d: %d\n", diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 32f1c1e10c7e..722839603f20 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -212,12 +212,6 @@ struct gasket_page_table { * gasket_mmap function, so user_virt belongs in the driver anyhow. */ struct gasket_coherent_page_entry *coherent_pages; - - /* - * Whether the page table uses arch specific dma_ops or - * whether the driver is supplying its own. - */ - bool dma_ops; }; /* Mapping declarations */ @@ -290,7 +284,7 @@ int gasket_page_table_init( struct gasket_page_table **ppg_tbl, const struct gasket_bar_data *bar_data, const struct gasket_page_table_config *page_table_config, - struct device *device, struct pci_dev *pci_dev, bool has_dma_ops) + struct device *device, struct pci_dev *pci_dev) { ulong bytes; struct gasket_page_table *pg_tbl; @@ -353,7 +347,6 @@ int gasket_page_table_init( bar_data->virt_base[page_table_config->extended_reg]); pg_tbl->device = device; pg_tbl->pci_dev = pci_dev; - pg_tbl->dma_ops = has_dma_ops; dev_dbg(device, "Page table initialized successfully\n"); @@ -759,33 +752,6 @@ static int gasket_map_extended_pages( return 0; } -/* - * TODO: dma_map_page() is not plugged properly when running under qemu. i.e. - * dma_ops are not set properly, which causes the kernel to assert. - * - * This temporary hack allows the driver to work on qemu, but need to be fixed: - * - either manually set the dma_ops for the architecture (which incidentally - * can't be done in an out-of-tree module) - or get qemu to fill the device tree - * properly so as linux plug the proper dma_ops or so as the driver can detect - * that it is runnig on qemu - */ -static inline dma_addr_t _no_op_dma_map_page( - struct device *dev, struct page *page, size_t offset, size_t size, - enum dma_data_direction dir) -{ - /* - * struct dma_map_ops *ops = get_dma_ops(dev); - * dma_addr_t addr; - * - * kmemcheck_mark_initialized(page_address(page) + offset, size); - * BUG_ON(!valid_dma_direction(dir)); - * addr = ops->map_page(dev, page, offset, size, dir, NULL); - * debug_dma_map_page(dev, page, offset, size, dir, addr, false); - */ - - return page_to_phys(page); -} - /* * Get and map last level page table buffers. * @pg_tbl: Gasket page table pointer. @@ -856,16 +822,9 @@ static int gasket_perform_mapping( ptes[i].offset = offset; /* Map the page into DMA space. */ - if (pg_tbl->dma_ops) { - /* hook in to kernel map functions */ - ptes[i].dma_addr = dma_map_page(pg_tbl->device, - page, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); - } else { - ptes[i].dma_addr = _no_op_dma_map_page( - pg_tbl->device, page, 0, PAGE_SIZE, - DMA_BIDIRECTIONAL); - } - + ptes[i].dma_addr = + dma_map_page(pg_tbl->device, page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); dev_dbg(pg_tbl->device, "%s i %d pte %p pfn %p -> mapped %llx\n", __func__, i, &ptes[i], @@ -1042,13 +1001,8 @@ static int gasket_alloc_extended_subtable( } /* Map the page into DMA space. */ - if (pg_tbl->dma_ops) { - pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, - PAGE_SIZE, DMA_BIDIRECTIONAL); - } else { - pte->dma_addr = _no_op_dma_map_page(pg_tbl->device, pte->page, - 0, PAGE_SIZE, DMA_BIDIRECTIONAL); - } + pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); /* Wait until the page is mapped. */ mb(); diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index 0e8afdb8c113..765588649365 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h @@ -37,7 +37,6 @@ struct gasket_page_table; * translation table. * @device: Device structure for the underlying device. Only used for logging. * @pci_dev: PCI system descriptor for the underlying device. - * @bool has_dma_ops: Whether the page table uses arch specific dma_ops or * whether the driver will supply its own. * * Description: Allocates and initializes data to track address translation - @@ -51,7 +50,7 @@ int gasket_page_table_init( struct gasket_page_table **ppg_tbl, const struct gasket_bar_data *bar_data, const struct gasket_page_table_config *page_table_config, - struct device *device, struct pci_dev *pci_dev, bool dma_ops); + struct device *device, struct pci_dev *pci_dev); /* * Deallocate and cleanup page table data. From 6d4abf1c0e265d8e99c155b91c1cf44e37793e53 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 27 Jul 2018 07:15:15 +0000 Subject: [PATCH 628/903] staging: axis-fifo: fix return value check in axis_fifo_probe() In case of error, the function device_create() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Fixes: 4a965c5f89de ("staging: add driver for Xilinx AXI-Stream FIFO v4.1 IP core") Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/axis-fifo/axis-fifo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index 2a73302620ec..51a081df5741 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -1006,10 +1006,10 @@ static int axis_fifo_probe(struct platform_device *pdev) /* create driver file */ fifo->device = device_create(axis_fifo_driver_class, NULL, fifo->devt, NULL, device_name); - if (!fifo->device) { + if (IS_ERR(fifo->device)) { dev_err(fifo->dt_device, "couldn't create driver file\n"); - rc = -ENOMEM; + rc = PTR_ERR(fifo->device); goto err_chrdev_region; } dev_set_drvdata(fifo->device, fifo); From 9a5094ca29ea9b1da301b31fd377c0c0c4c23034 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 27 Jul 2018 09:42:45 +0300 Subject: [PATCH 629/903] iio: ad9523: Fix return value for ad952x_store() A sysfs write callback function needs to either return the number of consumed characters or an error. The ad952x_store() function currently returns 0 if the input value was "0", this will signal that no characters have been consumed and the function will be called repeatedly in a loop indefinitely. Fix this by returning number of supplied characters to indicate that the whole input string has been consumed. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Fixes: cd1678f96329 ("iio: frequency: New driver for AD9523 SPI Low Jitter Clock Generator") Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/ad9523.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 37504739c277..059b2fda8cbd 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -518,7 +518,7 @@ static ssize_t ad9523_store(struct device *dev, return ret; if (!state) - return 0; + return len; mutex_lock(&st->lock); switch ((u32)this_attr->address) { From 6431975789fc3c480cb6344256f72d85889df3b2 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 27 Jul 2018 09:41:09 +0300 Subject: [PATCH 630/903] iio: ad9523: support for external signals via gpios The AD9523 supports external signals for power-down mode, resetting the device and sync timing. This change add support for specifying values for these signals via the gpios and initializing them default values. For the reset signal, the GPIO is toggled during probing to re-initialize the device to a known state. Signed-off-by: Michael Hennerich Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/ad9523.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 37504739c277..38a8f73bd8d9 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -268,6 +269,9 @@ struct ad9523_state { struct regulator *reg; struct ad9523_platform_data *pdata; struct iio_chan_spec ad9523_channels[AD9523_NUM_CHAN]; + struct gpio_desc *pwrdown_gpio; + struct gpio_desc *reset_gpio; + struct gpio_desc *sync_gpio; unsigned long vcxo_freq; unsigned long vco_freq; @@ -988,6 +992,32 @@ static int ad9523_probe(struct spi_device *spi) return ret; } + st->pwrdown_gpio = devm_gpiod_get_optional(&spi->dev, "powerdown", + GPIOD_OUT_HIGH); + if (IS_ERR(st->pwrdown_gpio)) { + ret = PTR_ERR(st->pwrdown_gpio); + goto error_disable_reg; + } + + st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(st->reset_gpio)) { + ret = PTR_ERR(st->reset_gpio); + goto error_disable_reg; + } + + if (st->reset_gpio) { + udelay(1); + gpiod_direction_output(st->reset_gpio, 1); + } + + st->sync_gpio = devm_gpiod_get_optional(&spi->dev, "sync", + GPIOD_OUT_HIGH); + if (IS_ERR(st->sync_gpio)) { + ret = PTR_ERR(st->sync_gpio); + goto error_disable_reg; + } + spi_set_drvdata(spi, indio_dev); st->spi = spi; st->pdata = pdata; From 1b3bd8592780c87c5eddabbe98666b086bbaee36 Mon Sep 17 00:00:00 2001 From: Himanshu Jha Date: Thu, 26 Jul 2018 17:05:10 +0530 Subject: [PATCH 631/903] iio: chemical: Add support for Bosch BME680 sensor Bosch BME680 is a 4-in-1 sensor with temperature, pressure, humidity and gas sensing capability. It supports both I2C and SPI communication protocol for effective data communication. The device supports two modes: 1. Sleep mode 2. Forced mode The measurements only takes place when forced mode is triggered and a single TPHG cycle is performed by the sensor. The sensor automatically goes to sleep after afterwards. The device has various calibration constants/parameters programmed into devices' non-volatile memory(NVM) during production and can't be altered by the user. These constants are used in the compensation functions to get the required compensated readings along with the raw data. The compensation functions/algorithms are provided by Bosch Sensortec GmbH via their API[1]. As these don't change during the measurement cycle, therefore we read and store them at the probe. The default configs supplied by Bosch are also set at probe. 0-day tested with build success. GSoC-2018: https://summerofcode.withgoogle.com/projects/#6691473790074880 Mentor: Daniel Baluta [1] https://github.com/BoschSensortec/BME680_driver Datasheet: https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680-DS001-00.pdf Note from Jonathan: The compensation functions are 'interesting' and could do with a tidy up in future. However, they work so we can leave that for another day. Cc: Daniel Baluta Signed-off-by: Himanshu Jha Signed-off-by: Jonathan Cameron --- drivers/iio/chemical/Kconfig | 23 + drivers/iio/chemical/Makefile | 3 + drivers/iio/chemical/bme680.h | 96 +++ drivers/iio/chemical/bme680_core.c | 959 +++++++++++++++++++++++++++++ drivers/iio/chemical/bme680_i2c.c | 85 +++ drivers/iio/chemical/bme680_spi.c | 125 ++++ 6 files changed, 1291 insertions(+) create mode 100644 drivers/iio/chemical/bme680.h create mode 100644 drivers/iio/chemical/bme680_core.c create mode 100644 drivers/iio/chemical/bme680_i2c.c create mode 100644 drivers/iio/chemical/bme680_spi.c diff --git a/drivers/iio/chemical/Kconfig b/drivers/iio/chemical/Kconfig index 5cb5be7612b4..b8e005be4f87 100644 --- a/drivers/iio/chemical/Kconfig +++ b/drivers/iio/chemical/Kconfig @@ -21,6 +21,29 @@ config ATLAS_PH_SENSOR To compile this driver as module, choose M here: the module will be called atlas-ph-sensor. +config BME680 + tristate "Bosch Sensortec BME680 sensor driver" + depends on (I2C || SPI) + select REGMAP + select BME680_I2C if I2C + select BME680_SPI if SPI + help + Say yes here to build support for Bosch Sensortec BME680 sensor with + temperature, pressure, humidity and gas sensing capability. + + This driver can also be built as a module. If so, the module for I2C + would be called bme680_i2c and bme680_spi for SPI support. + +config BME680_I2C + tristate + depends on I2C && BME680 + select REGMAP_I2C + +config BME680_SPI + tristate + depends on SPI && BME680 + select REGMAP_SPI + config CCS811 tristate "AMS CCS811 VOC sensor" depends on I2C diff --git a/drivers/iio/chemical/Makefile b/drivers/iio/chemical/Makefile index a629b29d1e0b..2f4c4ba4d781 100644 --- a/drivers/iio/chemical/Makefile +++ b/drivers/iio/chemical/Makefile @@ -4,6 +4,9 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_ATLAS_PH_SENSOR) += atlas-ph-sensor.o +obj-$(CONFIG_BME680) += bme680_core.o +obj-$(CONFIG_BME680_I2C) += bme680_i2c.o +obj-$(CONFIG_BME680_SPI) += bme680_spi.o obj-$(CONFIG_CCS811) += ccs811.o obj-$(CONFIG_IAQCORE) += ams-iaq-core.o obj-$(CONFIG_VZ89X) += vz89x.o diff --git a/drivers/iio/chemical/bme680.h b/drivers/iio/chemical/bme680.h new file mode 100644 index 000000000000..e049323f209a --- /dev/null +++ b/drivers/iio/chemical/bme680.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef BME680_H_ +#define BME680_H_ + +#define BME680_REG_CHIP_I2C_ID 0xD0 +#define BME680_REG_CHIP_SPI_ID 0x50 +#define BME680_CHIP_ID_VAL 0x61 +#define BME680_REG_SOFT_RESET_I2C 0xE0 +#define BME680_REG_SOFT_RESET_SPI 0x60 +#define BME680_CMD_SOFTRESET 0xB6 +#define BME680_REG_STATUS 0x73 +#define BME680_SPI_MEM_PAGE_BIT BIT(4) +#define BME680_SPI_MEM_PAGE_1_VAL 1 + +#define BME680_REG_TEMP_MSB 0x22 +#define BME680_REG_PRESS_MSB 0x1F +#define BM6880_REG_HUMIDITY_MSB 0x25 +#define BME680_REG_GAS_MSB 0x2A +#define BME680_REG_GAS_R_LSB 0x2B +#define BME680_GAS_STAB_BIT BIT(4) + +#define BME680_REG_CTRL_HUMIDITY 0x72 +#define BME680_OSRS_HUMIDITY_MASK GENMASK(2, 0) + +#define BME680_REG_CTRL_MEAS 0x74 +#define BME680_OSRS_TEMP_MASK GENMASK(7, 5) +#define BME680_OSRS_PRESS_MASK GENMASK(4, 2) +#define BME680_MODE_MASK GENMASK(1, 0) + +#define BME680_MODE_FORCED 1 +#define BME680_MODE_SLEEP 0 + +#define BME680_REG_CONFIG 0x75 +#define BME680_FILTER_MASK GENMASK(4, 2) +#define BME680_FILTER_COEFF_VAL BIT(1) + +/* TEMP/PRESS/HUMID reading skipped */ +#define BME680_MEAS_SKIPPED 0x8000 + +#define BME680_MAX_OVERFLOW_VAL 0x40000000 +#define BME680_HUM_REG_SHIFT_VAL 4 +#define BME680_BIT_H1_DATA_MSK 0x0F + +#define BME680_REG_RES_HEAT_RANGE 0x02 +#define BME680_RHRANGE_MSK 0x30 +#define BME680_REG_RES_HEAT_VAL 0x00 +#define BME680_REG_RANGE_SW_ERR 0x04 +#define BME680_RSERROR_MSK 0xF0 +#define BME680_REG_RES_HEAT_0 0x5A +#define BME680_REG_GAS_WAIT_0 0x64 +#define BME680_GAS_RANGE_MASK 0x0F +#define BME680_ADC_GAS_RES_SHIFT 6 +#define BME680_AMB_TEMP 25 + +#define BME680_REG_CTRL_GAS_1 0x71 +#define BME680_RUN_GAS_MASK BIT(4) +#define BME680_NB_CONV_MASK GENMASK(3, 0) +#define BME680_RUN_GAS_EN_BIT BIT(4) +#define BME680_NB_CONV_0_VAL 0 + +#define BME680_REG_MEAS_STAT_0 0x1D +#define BME680_GAS_MEAS_BIT BIT(6) + +/* Calibration Parameters */ +#define BME680_T2_LSB_REG 0x8A +#define BME680_T3_REG 0x8C +#define BME680_P1_LSB_REG 0x8E +#define BME680_P2_LSB_REG 0x90 +#define BME680_P3_REG 0x92 +#define BME680_P4_LSB_REG 0x94 +#define BME680_P5_LSB_REG 0x96 +#define BME680_P7_REG 0x98 +#define BME680_P6_REG 0x99 +#define BME680_P8_LSB_REG 0x9C +#define BME680_P9_LSB_REG 0x9E +#define BME680_P10_REG 0xA0 +#define BME680_H2_LSB_REG 0xE2 +#define BME680_H2_MSB_REG 0xE1 +#define BME680_H1_MSB_REG 0xE3 +#define BME680_H1_LSB_REG 0xE2 +#define BME680_H3_REG 0xE4 +#define BME680_H4_REG 0xE5 +#define BME680_H5_REG 0xE6 +#define BME680_H6_REG 0xE7 +#define BME680_H7_REG 0xE8 +#define BME680_T1_LSB_REG 0xE9 +#define BME680_GH2_LSB_REG 0xEB +#define BME680_GH1_REG 0xED +#define BME680_GH3_REG 0xEE + +extern const struct regmap_config bme680_regmap_config; + +int bme680_core_probe(struct device *dev, struct regmap *regmap, + const char *name); + +#endif /* BME680_H_ */ diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c new file mode 100644 index 000000000000..7d9bb62baa3f --- /dev/null +++ b/drivers/iio/chemical/bme680_core.c @@ -0,0 +1,959 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Bosch BME680 - Temperature, Pressure, Humidity & Gas Sensor + * + * Copyright (C) 2017 - 2018 Bosch Sensortec GmbH + * Copyright (C) 2018 Himanshu Jha + * + * Datasheet: + * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680-DS001-00.pdf + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bme680.h" + +struct bme680_calib { + u16 par_t1; + s16 par_t2; + s8 par_t3; + u16 par_p1; + s16 par_p2; + s8 par_p3; + s16 par_p4; + s16 par_p5; + s8 par_p6; + s8 par_p7; + s16 par_p8; + s16 par_p9; + u8 par_p10; + u16 par_h1; + u16 par_h2; + s8 par_h3; + s8 par_h4; + s8 par_h5; + s8 par_h6; + s8 par_h7; + s8 par_gh1; + s16 par_gh2; + s8 par_gh3; + u8 res_heat_range; + s8 res_heat_val; + s8 range_sw_err; +}; + +struct bme680_data { + struct regmap *regmap; + struct bme680_calib bme680; + u8 oversampling_temp; + u8 oversampling_press; + u8 oversampling_humid; + u16 heater_dur; + u16 heater_temp; + /* + * Carryover value from temperature conversion, used in pressure + * and humidity compensation calculations. + */ + s32 t_fine; +}; + +const struct regmap_config bme680_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; +EXPORT_SYMBOL(bme680_regmap_config); + +static const struct iio_chan_spec bme680_channels[] = { + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + }, + { + .type = IIO_PRESSURE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + }, + { + .type = IIO_HUMIDITYRELATIVE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + }, + { + .type = IIO_RESISTANCE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + }, +}; + +static const int bme680_oversampling_avail[] = { 1, 2, 4, 8, 16 }; + +static int bme680_read_calib(struct bme680_data *data, + struct bme680_calib *calib) +{ + struct device *dev = regmap_get_device(data->regmap); + unsigned int tmp, tmp_msb, tmp_lsb; + int ret; + __le16 buf; + + /* Temperature related coefficients */ + ret = regmap_bulk_read(data->regmap, BME680_T1_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_T1_LSB_REG\n"); + return ret; + } + calib->par_t1 = le16_to_cpu(buf); + + ret = regmap_bulk_read(data->regmap, BME680_T2_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_T2_LSB_REG\n"); + return ret; + } + calib->par_t2 = le16_to_cpu(buf); + + ret = regmap_read(data->regmap, BME680_T3_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_T3_REG\n"); + return ret; + } + calib->par_t3 = tmp; + + /* Pressure related coefficients */ + ret = regmap_bulk_read(data->regmap, BME680_P1_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P1_LSB_REG\n"); + return ret; + } + calib->par_p1 = le16_to_cpu(buf); + + ret = regmap_bulk_read(data->regmap, BME680_P2_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P2_LSB_REG\n"); + return ret; + } + calib->par_p2 = le16_to_cpu(buf); + + ret = regmap_read(data->regmap, BME680_P3_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P3_REG\n"); + return ret; + } + calib->par_p3 = tmp; + + ret = regmap_bulk_read(data->regmap, BME680_P4_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P4_LSB_REG\n"); + return ret; + } + calib->par_p4 = le16_to_cpu(buf); + + ret = regmap_bulk_read(data->regmap, BME680_P5_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P5_LSB_REG\n"); + return ret; + } + calib->par_p5 = le16_to_cpu(buf); + + ret = regmap_read(data->regmap, BME680_P6_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P6_REG\n"); + return ret; + } + calib->par_p6 = tmp; + + ret = regmap_read(data->regmap, BME680_P7_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P7_REG\n"); + return ret; + } + calib->par_p7 = tmp; + + ret = regmap_bulk_read(data->regmap, BME680_P8_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P8_LSB_REG\n"); + return ret; + } + calib->par_p8 = le16_to_cpu(buf); + + ret = regmap_bulk_read(data->regmap, BME680_P9_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P9_LSB_REG\n"); + return ret; + } + calib->par_p9 = le16_to_cpu(buf); + + ret = regmap_read(data->regmap, BME680_P10_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_P10_REG\n"); + return ret; + } + calib->par_p10 = tmp; + + /* Humidity related coefficients */ + ret = regmap_read(data->regmap, BME680_H1_MSB_REG, &tmp_msb); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H1_MSB_REG\n"); + return ret; + } + + ret = regmap_read(data->regmap, BME680_H1_LSB_REG, &tmp_lsb); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H1_LSB_REG\n"); + return ret; + } + + calib->par_h1 = (tmp_msb << BME680_HUM_REG_SHIFT_VAL) | + (tmp_lsb & BME680_BIT_H1_DATA_MSK); + + ret = regmap_read(data->regmap, BME680_H2_MSB_REG, &tmp_msb); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H2_MSB_REG\n"); + return ret; + } + + ret = regmap_read(data->regmap, BME680_H2_LSB_REG, &tmp_lsb); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H2_LSB_REG\n"); + return ret; + } + + calib->par_h2 = (tmp_msb << BME680_HUM_REG_SHIFT_VAL) | + (tmp_lsb >> BME680_HUM_REG_SHIFT_VAL); + + ret = regmap_read(data->regmap, BME680_H3_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H3_REG\n"); + return ret; + } + calib->par_h3 = tmp; + + ret = regmap_read(data->regmap, BME680_H4_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H4_REG\n"); + return ret; + } + calib->par_h4 = tmp; + + ret = regmap_read(data->regmap, BME680_H5_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H5_REG\n"); + return ret; + } + calib->par_h5 = tmp; + + ret = regmap_read(data->regmap, BME680_H6_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H6_REG\n"); + return ret; + } + calib->par_h6 = tmp; + + ret = regmap_read(data->regmap, BME680_H7_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_H7_REG\n"); + return ret; + } + calib->par_h7 = tmp; + + /* Gas heater related coefficients */ + ret = regmap_read(data->regmap, BME680_GH1_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_GH1_REG\n"); + return ret; + } + calib->par_gh1 = tmp; + + ret = regmap_bulk_read(data->regmap, BME680_GH2_LSB_REG, + (u8 *) &buf, 2); + if (ret < 0) { + dev_err(dev, "failed to read BME680_GH2_LSB_REG\n"); + return ret; + } + calib->par_gh2 = le16_to_cpu(buf); + + ret = regmap_read(data->regmap, BME680_GH3_REG, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read BME680_GH3_REG\n"); + return ret; + } + calib->par_gh3 = tmp; + + /* Other coefficients */ + ret = regmap_read(data->regmap, BME680_REG_RES_HEAT_RANGE, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read resistance heat range\n"); + return ret; + } + calib->res_heat_range = (tmp & BME680_RHRANGE_MSK) / 16; + + ret = regmap_read(data->regmap, BME680_REG_RES_HEAT_VAL, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read resistance heat value\n"); + return ret; + } + calib->res_heat_val = tmp; + + ret = regmap_read(data->regmap, BME680_REG_RANGE_SW_ERR, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read range software error\n"); + return ret; + } + calib->range_sw_err = (tmp & BME680_RSERROR_MSK) / 16; + + return 0; +} + +/* + * Taken from Bosch BME680 API: + * https://github.com/BoschSensortec/BME680_driver/blob/63bb5336/bme680.c#L876 + * + * Returns temperature measurement in DegC, resolutions is 0.01 DegC. Therefore, + * output value of "3233" represents 32.33 DegC. + */ +static s16 bme680_compensate_temp(struct bme680_data *data, + s32 adc_temp) +{ + struct bme680_calib *calib = &data->bme680; + s64 var1, var2, var3; + s16 calc_temp; + + var1 = (adc_temp >> 3) - (calib->par_t1 << 1); + var2 = (var1 * calib->par_t2) >> 11; + var3 = ((var1 >> 1) * (var1 >> 1)) >> 12; + var3 = (var3 * (calib->par_t3 << 4)) >> 14; + data->t_fine = var2 + var3; + calc_temp = (data->t_fine * 5 + 128) >> 8; + + return calc_temp; +} + +/* + * Taken from Bosch BME680 API: + * https://github.com/BoschSensortec/BME680_driver/blob/63bb5336/bme680.c#L896 + * + * Returns pressure measurement in Pa. Output value of "97356" represents + * 97356 Pa = 973.56 hPa. + */ +static u32 bme680_compensate_press(struct bme680_data *data, + u32 adc_press) +{ + struct bme680_calib *calib = &data->bme680; + s32 var1, var2, var3, press_comp; + + var1 = (data->t_fine >> 1) - 64000; + var2 = ((((var1 >> 2) * (var1 >> 2)) >> 11) * calib->par_p6) >> 2; + var2 = var2 + (var1 * calib->par_p5 << 1); + var2 = (var2 >> 2) + (calib->par_p4 << 16); + var1 = (((((var1 >> 2) * (var1 >> 2)) >> 13) * + (calib->par_p3 << 5)) >> 3) + + ((calib->par_p2 * var1) >> 1); + var1 = var1 >> 18; + var1 = ((32768 + var1) * calib->par_p1) >> 15; + press_comp = 1048576 - adc_press; + press_comp = ((press_comp - (var2 >> 12)) * 3125); + + if (press_comp >= BME680_MAX_OVERFLOW_VAL) + press_comp = ((press_comp / (u32)var1) << 1); + else + press_comp = ((press_comp << 1) / (u32)var1); + + var1 = (calib->par_p9 * (((press_comp >> 3) * + (press_comp >> 3)) >> 13)) >> 12; + var2 = ((press_comp >> 2) * calib->par_p8) >> 13; + var3 = ((press_comp >> 8) * (press_comp >> 8) * + (press_comp >> 8) * calib->par_p10) >> 17; + + press_comp += (var1 + var2 + var3 + (calib->par_p7 << 7)) >> 4; + + return press_comp; +} + +/* + * Taken from Bosch BME680 API: + * https://github.com/BoschSensortec/BME680_driver/blob/63bb5336/bme680.c#L937 + * + * Returns humidity measurement in percent, resolution is 0.001 percent. Output + * value of "43215" represents 43.215 %rH. + */ +static u32 bme680_compensate_humid(struct bme680_data *data, + u16 adc_humid) +{ + struct bme680_calib *calib = &data->bme680; + s32 var1, var2, var3, var4, var5, var6, temp_scaled, calc_hum; + + temp_scaled = (data->t_fine * 5 + 128) >> 8; + var1 = (adc_humid - ((s32) ((s32) calib->par_h1 * 16))) - + (((temp_scaled * (s32) calib->par_h3) / 100) >> 1); + var2 = ((s32) calib->par_h2 * + (((temp_scaled * calib->par_h4) / 100) + + (((temp_scaled * ((temp_scaled * calib->par_h5) / 100)) + >> 6) / 100) + (1 << 14))) >> 10; + var3 = var1 * var2; + var4 = calib->par_h6 << 7; + var4 = (var4 + ((temp_scaled * calib->par_h7) / 100)) >> 4; + var5 = ((var3 >> 14) * (var3 >> 14)) >> 10; + var6 = (var4 * var5) >> 1; + calc_hum = (((var3 + var6) >> 10) * 1000) >> 12; + + if (calc_hum > 100000) /* Cap at 100%rH */ + calc_hum = 100000; + else if (calc_hum < 0) + calc_hum = 0; + + return calc_hum; +} + +/* + * Taken from Bosch BME680 API: + * https://github.com/BoschSensortec/BME680_driver/blob/63bb5336/bme680.c#L973 + * + * Returns gas measurement in Ohm. Output value of "82986" represent 82986 ohms. + */ +static u32 bme680_compensate_gas(struct bme680_data *data, u16 gas_res_adc, + u8 gas_range) +{ + struct bme680_calib *calib = &data->bme680; + s64 var1; + u64 var2; + s64 var3; + u32 calc_gas_res; + + /* Look up table for the possible gas range values */ + const u32 lookupTable[16] = {2147483647u, 2147483647u, + 2147483647u, 2147483647u, 2147483647u, + 2126008810u, 2147483647u, 2130303777u, + 2147483647u, 2147483647u, 2143188679u, + 2136746228u, 2147483647u, 2126008810u, + 2147483647u, 2147483647u}; + + var1 = ((1340 + (5 * (s64) calib->range_sw_err)) * + ((s64) lookupTable[gas_range])) >> 16; + var2 = ((gas_res_adc << 15) - 16777216) + var1; + var3 = ((125000 << (15 - gas_range)) * var1) >> 9; + var3 += (var2 >> 1); + calc_gas_res = div64_s64(var3, (s64) var2); + + return calc_gas_res; +} + +/* + * Taken from Bosch BME680 API: + * https://github.com/BoschSensortec/BME680_driver/blob/63bb5336/bme680.c#L1002 + */ +static u8 bme680_calc_heater_res(struct bme680_data *data, u16 temp) +{ + struct bme680_calib *calib = &data->bme680; + s32 var1, var2, var3, var4, var5, heatr_res_x100; + u8 heatr_res; + + if (temp > 400) /* Cap temperature */ + temp = 400; + + var1 = (((s32) BME680_AMB_TEMP * calib->par_gh3) / 1000) * 256; + var2 = (calib->par_gh1 + 784) * (((((calib->par_gh2 + 154009) * + temp * 5) / 100) + + 3276800) / 10); + var3 = var1 + (var2 / 2); + var4 = (var3 / (calib->res_heat_range + 4)); + var5 = 131 * calib->res_heat_val + 65536; + heatr_res_x100 = ((var4 / var5) - 250) * 34; + heatr_res = (heatr_res_x100 + 50) / 100; + + return heatr_res; +} + +/* + * Taken from Bosch BME680 API: + * https://github.com/BoschSensortec/BME680_driver/blob/63bb5336/bme680.c#L1188 + */ +static u8 bme680_calc_heater_dur(u16 dur) +{ + u8 durval, factor = 0; + + if (dur >= 0xfc0) { + durval = 0xff; /* Max duration */ + } else { + while (dur > 0x3F) { + dur = dur / 4; + factor += 1; + } + durval = dur + (factor * 64); + } + + return durval; +} + +static int bme680_set_mode(struct bme680_data *data, bool mode) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + + if (mode) { + ret = regmap_write_bits(data->regmap, BME680_REG_CTRL_MEAS, + BME680_MODE_MASK, BME680_MODE_FORCED); + if (ret < 0) + dev_err(dev, "failed to set forced mode\n"); + + } else { + ret = regmap_write_bits(data->regmap, BME680_REG_CTRL_MEAS, + BME680_MODE_MASK, BME680_MODE_SLEEP); + if (ret < 0) + dev_err(dev, "failed to set sleep mode\n"); + + } + + return ret; +} + +static int bme680_chip_config(struct bme680_data *data) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + u8 osrs = FIELD_PREP(BME680_OSRS_HUMIDITY_MASK, + data->oversampling_humid + 1); + /* + * Highly recommended to set oversampling of humidity before + * temperature/pressure oversampling. + */ + ret = regmap_update_bits(data->regmap, BME680_REG_CTRL_HUMIDITY, + BME680_OSRS_HUMIDITY_MASK, osrs); + if (ret < 0) { + dev_err(dev, "failed to write ctrl_hum register\n"); + return ret; + } + + /* IIR filter settings */ + ret = regmap_update_bits(data->regmap, BME680_REG_CONFIG, + BME680_FILTER_MASK, + BME680_FILTER_COEFF_VAL); + if (ret < 0) { + dev_err(dev, "failed to write config register\n"); + return ret; + } + + osrs = FIELD_PREP(BME680_OSRS_TEMP_MASK, data->oversampling_temp + 1) | + FIELD_PREP(BME680_OSRS_PRESS_MASK, data->oversampling_press + 1); + + ret = regmap_write_bits(data->regmap, BME680_REG_CTRL_MEAS, + BME680_OSRS_TEMP_MASK | + BME680_OSRS_PRESS_MASK, + osrs); + if (ret < 0) + dev_err(dev, "failed to write ctrl_meas register\n"); + + return ret; +} + +static int bme680_gas_config(struct bme680_data *data) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + u8 heatr_res, heatr_dur; + + heatr_res = bme680_calc_heater_res(data, data->heater_temp); + + /* set target heater temperature */ + ret = regmap_write(data->regmap, BME680_REG_RES_HEAT_0, heatr_res); + if (ret < 0) { + dev_err(dev, "failed to write res_heat_0 register\n"); + return ret; + } + + heatr_dur = bme680_calc_heater_dur(data->heater_dur); + + /* set target heating duration */ + ret = regmap_write(data->regmap, BME680_REG_GAS_WAIT_0, heatr_dur); + if (ret < 0) { + dev_err(dev, "failted to write gas_wait_0 register\n"); + return ret; + } + + /* Selecting the runGas and NB conversion settings for the sensor */ + ret = regmap_update_bits(data->regmap, BME680_REG_CTRL_GAS_1, + BME680_RUN_GAS_MASK | BME680_NB_CONV_MASK, + BME680_RUN_GAS_EN_BIT | BME680_NB_CONV_0_VAL); + if (ret < 0) + dev_err(dev, "failed to write ctrl_gas_1 register\n"); + + return ret; +} + +static int bme680_read_temp(struct bme680_data *data, + int *val, int *val2) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + __be32 tmp = 0; + s32 adc_temp; + s16 comp_temp; + + /* set forced mode to trigger measurement */ + ret = bme680_set_mode(data, true); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BME680_REG_TEMP_MSB, + (u8 *) &tmp, 3); + if (ret < 0) { + dev_err(dev, "failed to read temperature\n"); + return ret; + } + + adc_temp = be32_to_cpu(tmp) >> 12; + if (adc_temp == BME680_MEAS_SKIPPED) { + /* reading was skipped */ + dev_err(dev, "reading temperature skipped\n"); + return -EINVAL; + } + comp_temp = bme680_compensate_temp(data, adc_temp); + /* + * val might be NULL if we're called by the read_press/read_humid + * routine which is callled to get t_fine value used in + * compensate_press/compensate_humid to get compensated + * pressure/humidity readings. + */ + if (val && val2) { + *val = comp_temp; + *val2 = 100; + return IIO_VAL_FRACTIONAL; + } + + return ret; +} + +static int bme680_read_press(struct bme680_data *data, + int *val, int *val2) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + __be32 tmp = 0; + s32 adc_press; + + /* Read and compensate temperature to get a reading of t_fine */ + ret = bme680_read_temp(data, NULL, NULL); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BME680_REG_PRESS_MSB, + (u8 *) &tmp, 3); + if (ret < 0) { + dev_err(dev, "failed to read pressure\n"); + return ret; + } + + adc_press = be32_to_cpu(tmp) >> 12; + if (adc_press == BME680_MEAS_SKIPPED) { + /* reading was skipped */ + dev_err(dev, "reading pressure skipped\n"); + return -EINVAL; + } + + *val = bme680_compensate_press(data, adc_press); + *val2 = 100; + return IIO_VAL_FRACTIONAL; +} + +static int bme680_read_humid(struct bme680_data *data, + int *val, int *val2) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + __be16 tmp = 0; + s32 adc_humidity; + u32 comp_humidity; + + /* Read and compensate temperature to get a reading of t_fine */ + ret = bme680_read_temp(data, NULL, NULL); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BM6880_REG_HUMIDITY_MSB, + (u8 *) &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read humidity\n"); + return ret; + } + + adc_humidity = be16_to_cpu(tmp); + if (adc_humidity == BME680_MEAS_SKIPPED) { + /* reading was skipped */ + dev_err(dev, "reading humidity skipped\n"); + return -EINVAL; + } + comp_humidity = bme680_compensate_humid(data, adc_humidity); + + *val = comp_humidity; + *val2 = 1000; + return IIO_VAL_FRACTIONAL; +} + +static int bme680_read_gas(struct bme680_data *data, + int *val) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + __be16 tmp = 0; + unsigned int check; + u16 adc_gas_res; + u8 gas_range; + + /* Set heater settings */ + ret = bme680_gas_config(data); + if (ret < 0) { + dev_err(dev, "failed to set gas config\n"); + return ret; + } + + /* set forced mode to trigger measurement */ + ret = bme680_set_mode(data, true); + if (ret < 0) + return ret; + + ret = regmap_read(data->regmap, BME680_REG_MEAS_STAT_0, &check); + if (check & BME680_GAS_MEAS_BIT) { + dev_err(dev, "gas measurement incomplete\n"); + return -EBUSY; + } + + ret = regmap_read(data->regmap, BME680_REG_GAS_R_LSB, &check); + if (ret < 0) { + dev_err(dev, "failed to read gas_r_lsb register\n"); + return ret; + } + + /* + * occurs if either the gas heating duration was insuffient + * to reach the target heater temperature or the target + * heater temperature was too high for the heater sink to + * reach. + */ + if ((check & BME680_GAS_STAB_BIT) == 0) { + dev_err(dev, "heater failed to reach the target temperature\n"); + return -EINVAL; + } + + ret = regmap_bulk_read(data->regmap, BME680_REG_GAS_MSB, + (u8 *) &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read gas resistance\n"); + return ret; + } + + gas_range = check & BME680_GAS_RANGE_MASK; + adc_gas_res = be16_to_cpu(tmp) >> BME680_ADC_GAS_RES_SHIFT; + + *val = bme680_compensate_gas(data, adc_gas_res, gas_range); + return IIO_VAL_INT; +} + +static int bme680_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct bme680_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + switch (chan->type) { + case IIO_TEMP: + return bme680_read_temp(data, val, val2); + case IIO_PRESSURE: + return bme680_read_press(data, val, val2); + case IIO_HUMIDITYRELATIVE: + return bme680_read_humid(data, val, val2); + case IIO_RESISTANCE: + return bme680_read_gas(data, val); + default: + return -EINVAL; + } + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + switch (chan->type) { + case IIO_TEMP: + *val = 1 << data->oversampling_temp; + return IIO_VAL_INT; + case IIO_PRESSURE: + *val = 1 << data->oversampling_press; + return IIO_VAL_INT; + case IIO_HUMIDITYRELATIVE: + *val = 1 << data->oversampling_humid; + return IIO_VAL_INT; + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static int bme680_write_oversampling_ratio_temp(struct bme680_data *data, + int val) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(bme680_oversampling_avail); i++) { + if (bme680_oversampling_avail[i] == val) { + data->oversampling_temp = ilog2(val); + + return bme680_chip_config(data); + } + } + + return -EINVAL; +} + +static int bme680_write_oversampling_ratio_press(struct bme680_data *data, + int val) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(bme680_oversampling_avail); i++) { + if (bme680_oversampling_avail[i] == val) { + data->oversampling_press = ilog2(val); + + return bme680_chip_config(data); + } + } + + return -EINVAL; +} + +static int bme680_write_oversampling_ratio_humid(struct bme680_data *data, + int val) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(bme680_oversampling_avail); i++) { + if (bme680_oversampling_avail[i] == val) { + data->oversampling_humid = ilog2(val); + + return bme680_chip_config(data); + } + } + + return -EINVAL; +} + +static int bme680_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct bme680_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + switch (chan->type) { + case IIO_TEMP: + return bme680_write_oversampling_ratio_temp(data, val); + case IIO_PRESSURE: + return bme680_write_oversampling_ratio_press(data, val); + case IIO_HUMIDITYRELATIVE: + return bme680_write_oversampling_ratio_humid(data, val); + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static const char bme680_oversampling_ratio_show[] = "1 2 4 8 16"; + +static IIO_CONST_ATTR(oversampling_ratio_available, + bme680_oversampling_ratio_show); + +static struct attribute *bme680_attributes[] = { + &iio_const_attr_oversampling_ratio_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group bme680_attribute_group = { + .attrs = bme680_attributes, +}; + +static const struct iio_info bme680_info = { + .read_raw = &bme680_read_raw, + .write_raw = &bme680_write_raw, + .attrs = &bme680_attribute_group, +}; + +static const char *bme680_match_acpi_device(struct device *dev) +{ + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return NULL; + + return dev_name(dev); +} + +int bme680_core_probe(struct device *dev, struct regmap *regmap, + const char *name) +{ + struct iio_dev *indio_dev; + struct bme680_data *data; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + if (!name && ACPI_HANDLE(dev)) + name = bme680_match_acpi_device(dev); + + data = iio_priv(indio_dev); + dev_set_drvdata(dev, indio_dev); + data->regmap = regmap; + indio_dev->dev.parent = dev; + indio_dev->name = name; + indio_dev->channels = bme680_channels; + indio_dev->num_channels = ARRAY_SIZE(bme680_channels); + indio_dev->info = &bme680_info; + indio_dev->modes = INDIO_DIRECT_MODE; + + /* default values for the sensor */ + data->oversampling_humid = ilog2(2); /* 2X oversampling rate */ + data->oversampling_press = ilog2(4); /* 4X oversampling rate */ + data->oversampling_temp = ilog2(8); /* 8X oversampling rate */ + data->heater_temp = 320; /* degree Celsius */ + data->heater_dur = 150; /* milliseconds */ + + ret = bme680_chip_config(data); + if (ret < 0) { + dev_err(dev, "failed to set chip_config data\n"); + return ret; + } + + ret = bme680_gas_config(data); + if (ret < 0) { + dev_err(dev, "failed to set gas config data\n"); + return ret; + } + + ret = bme680_read_calib(data, &data->bme680); + if (ret < 0) { + dev_err(dev, + "failed to read calibration coefficients at probe\n"); + return ret; + } + + return devm_iio_device_register(dev, indio_dev); +} +EXPORT_SYMBOL_GPL(bme680_core_probe); + +MODULE_AUTHOR("Himanshu Jha "); +MODULE_DESCRIPTION("Bosch BME680 Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/chemical/bme680_i2c.c b/drivers/iio/chemical/bme680_i2c.c new file mode 100644 index 000000000000..06d4be539d2e --- /dev/null +++ b/drivers/iio/chemical/bme680_i2c.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * BME680 - I2C Driver + * + * Copyright (C) 2018 Himanshu Jha + * + * 7-Bit I2C slave address is: + * - 0x76 if SDO is pulled to GND + * - 0x77 if SDO is pulled to VDDIO + * + * Note: SDO pin cannot be left floating otherwise I2C address + * will be undefined. + */ +#include +#include +#include +#include + +#include "bme680.h" + +static int bme680_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct regmap *regmap; + const char *name = NULL; + unsigned int val; + int ret; + + regmap = devm_regmap_init_i2c(client, &bme680_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&client->dev, "Failed to register i2c regmap %d\n", + (int)PTR_ERR(regmap)); + return PTR_ERR(regmap); + } + + ret = regmap_write(regmap, BME680_REG_SOFT_RESET_I2C, + BME680_CMD_SOFTRESET); + if (ret < 0) { + dev_err(&client->dev, "Failed to reset chip\n"); + return ret; + } + + ret = regmap_read(regmap, BME680_REG_CHIP_I2C_ID, &val); + if (ret < 0) { + dev_err(&client->dev, "Error reading I2C chip ID\n"); + return ret; + } + + if (val != BME680_CHIP_ID_VAL) { + dev_err(&client->dev, "Wrong chip ID, got %x expected %x\n", + val, BME680_CHIP_ID_VAL); + return -ENODEV; + } + + if (id) + name = id->name; + + return bme680_core_probe(&client->dev, regmap, name); +} + +static const struct i2c_device_id bme680_i2c_id[] = { + {"bme680", 0}, + {}, +}; +MODULE_DEVICE_TABLE(i2c, bme680_i2c_id); + +static const struct acpi_device_id bme680_acpi_match[] = { + {"BME0680", 0}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, bme680_acpi_match); + +static struct i2c_driver bme680_i2c_driver = { + .driver = { + .name = "bme680_i2c", + .acpi_match_table = ACPI_PTR(bme680_acpi_match), + }, + .probe = bme680_i2c_probe, + .id_table = bme680_i2c_id, +}; +module_i2c_driver(bme680_i2c_driver); + +MODULE_AUTHOR("Himanshu Jha "); +MODULE_DESCRIPTION("BME680 I2C driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/chemical/bme680_spi.c b/drivers/iio/chemical/bme680_spi.c new file mode 100644 index 000000000000..c9fb05e8d0b9 --- /dev/null +++ b/drivers/iio/chemical/bme680_spi.c @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * BME680 - SPI Driver + * + * Copyright (C) 2018 Himanshu Jha + */ +#include +#include +#include +#include + +#include "bme680.h" + +static int bme680_regmap_spi_write(void *context, const void *data, + size_t count) +{ + struct spi_device *spi = context; + u8 buf[2]; + + memcpy(buf, data, 2); + /* + * The SPI register address (= full register address without bit 7) + * and the write command (bit7 = RW = '0') + */ + buf[0] &= ~0x80; + + return spi_write_then_read(spi, buf, 2, NULL, 0); +} + +static int bme680_regmap_spi_read(void *context, const void *reg, + size_t reg_size, void *val, size_t val_size) +{ + struct spi_device *spi = context; + + return spi_write_then_read(spi, reg, reg_size, val, val_size); +} + +static struct regmap_bus bme680_regmap_bus = { + .write = bme680_regmap_spi_write, + .read = bme680_regmap_spi_read, + .reg_format_endian_default = REGMAP_ENDIAN_BIG, + .val_format_endian_default = REGMAP_ENDIAN_BIG, +}; + +static int bme680_spi_probe(struct spi_device *spi) +{ + const struct spi_device_id *id = spi_get_device_id(spi); + struct regmap *regmap; + unsigned int val; + int ret; + + spi->bits_per_word = 8; + ret = spi_setup(spi); + if (ret < 0) { + dev_err(&spi->dev, "spi_setup failed!\n"); + return ret; + } + + regmap = devm_regmap_init(&spi->dev, &bme680_regmap_bus, + &spi->dev, &bme680_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&spi->dev, "Failed to register spi regmap %d\n", + (int)PTR_ERR(regmap)); + return PTR_ERR(regmap); + } + + ret = regmap_write(regmap, BME680_REG_SOFT_RESET_SPI, + BME680_CMD_SOFTRESET); + if (ret < 0) { + dev_err(&spi->dev, "Failed to reset chip\n"); + return ret; + } + + /* after power-on reset, Page 0(0x80-0xFF) of spi_mem_page is active */ + ret = regmap_read(regmap, BME680_REG_CHIP_SPI_ID, &val); + if (ret < 0) { + dev_err(&spi->dev, "Error reading SPI chip ID\n"); + return ret; + } + + if (val != BME680_CHIP_ID_VAL) { + dev_err(&spi->dev, "Wrong chip ID, got %x expected %x\n", + val, BME680_CHIP_ID_VAL); + return -ENODEV; + } + /* + * select Page 1 of spi_mem_page to enable access to + * to registers from address 0x00 to 0x7F. + */ + ret = regmap_write_bits(regmap, BME680_REG_STATUS, + BME680_SPI_MEM_PAGE_BIT, + BME680_SPI_MEM_PAGE_1_VAL); + if (ret < 0) { + dev_err(&spi->dev, "failed to set page 1 of spi_mem_page\n"); + return ret; + } + + return bme680_core_probe(&spi->dev, regmap, id->name); +} + +static const struct spi_device_id bme680_spi_id[] = { + {"bme680", 0}, + {}, +}; +MODULE_DEVICE_TABLE(spi, bme680_spi_id); + +static const struct acpi_device_id bme680_acpi_match[] = { + {"BME0680", 0}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, bme680_acpi_match); + +static struct spi_driver bme680_spi_driver = { + .driver = { + .name = "bme680_spi", + .acpi_match_table = ACPI_PTR(bme680_acpi_match), + }, + .probe = bme680_spi_probe, + .id_table = bme680_spi_id, +}; +module_spi_driver(bme680_spi_driver); + +MODULE_AUTHOR("Himanshu Jha "); +MODULE_DESCRIPTION("Bosch BME680 SPI driver"); +MODULE_LICENSE("GPL v2"); From cebc4585f6ac01c3ea8fa8a8dd22848747f24d05 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Mon, 23 Jul 2018 11:18:38 +0200 Subject: [PATCH 632/903] iio: ad_sigma_delta: use unsigned long for timeout wait_for_completion_timeout returns unsigned long not int so an appropriate variable is declared and the assignment and check fixed up. Signed-off-by: Nicholas Mc Guire Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad_sigma_delta.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index cf1b048b0665..fc9510716ac7 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -209,6 +209,7 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta, unsigned int mode, unsigned int channel) { int ret; + unsigned long timeout; ret = ad_sigma_delta_set_channel(sigma_delta, channel); if (ret) @@ -224,8 +225,8 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta, sigma_delta->irq_dis = false; enable_irq(sigma_delta->spi->irq); - ret = wait_for_completion_timeout(&sigma_delta->completion, 2*HZ); - if (ret == 0) { + timeout = wait_for_completion_timeout(&sigma_delta->completion, 2 * HZ); + if (timeout == 0) { sigma_delta->irq_dis = true; disable_irq_nosync(sigma_delta->spi->irq); ret = -EIO; From 47e541a17ec7d64e19c11f59dfce314a89f1b228 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sun, 29 Jul 2018 13:34:58 +0800 Subject: [PATCH 633/903] staging: erofs: fix compile error without built-in decompression support This patch fixes incorrect code snippets due to spilt code into small patches by mistake. Link: https://lists.01.org/pipermail/kbuild-all/2018-July/050747.html Link: https://lists.01.org/pipermail/kbuild-all/2018-July/050750.html Reported-by: kbuild test robot Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 4 ++-- drivers/staging/erofs/super.c | 2 +- drivers/staging/erofs/unzip_vle.c | 7 ++++--- drivers/staging/erofs/utils.c | 7 ++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 669f93ae6920..367b39fe46e5 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -260,9 +260,9 @@ static inline void erofs_workstation_cleanup_all(struct super_block *sb) #ifdef EROFS_FS_HAS_MANAGED_CACHE #define EROFS_UNALLOCATED_CACHED_PAGE ((void *)0x5F0EF00D) -extern int try_to_free_all_cached_pages(struct erofs_sb_info *sbi, +extern int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi, struct erofs_workgroup *egrp); -extern int try_to_free_cached_page(struct address_space *mapping, +extern int erofs_try_to_free_cached_page(struct address_space *mapping, struct page *page); #endif diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 97da5c8a8ef3..1aec509c805f 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -269,7 +269,7 @@ static int managed_cache_releasepage(struct page *page, gfp_t gfp_mask) BUG_ON(mapping->a_ops != &managed_cache_aops); if (PagePrivate(page)) - ret = try_to_free_cached_page(mapping, page); + ret = erofs_try_to_free_cached_page(mapping, page); return ret; } diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 7671fe8194ce..0e410a228cd4 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -131,8 +131,8 @@ static bool grab_managed_cache_pages(struct address_space *mapping, } /* called by erofs_shrinker to get rid of all compressed_pages */ -int try_to_free_all_cached_pages(struct erofs_sb_info *sbi, - struct erofs_workgroup *egrp) +int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi, + struct erofs_workgroup *egrp) { struct z_erofs_vle_workgroup *const grp = container_of(egrp, struct z_erofs_vle_workgroup, obj); @@ -166,7 +166,8 @@ int try_to_free_all_cached_pages(struct erofs_sb_info *sbi, return 0; } -int try_to_free_cached_page(struct address_space *mapping, struct page *page) +int erofs_try_to_free_cached_page(struct address_space *mapping, + struct page *page) { struct erofs_sb_info *const sbi = EROFS_SB(mapping->host->i_sb); const unsigned int clusterpages = erofs_clusterpages(sbi); diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index ee70bb9e1636..595cf90af9bb 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -160,7 +160,7 @@ skip: } #ifdef EROFS_FS_HAS_MANAGED_CACHE - if (try_to_free_all_cached_pages(sbi, grp)) + if (erofs_try_to_free_all_cached_pages(sbi, grp)) goto skip; erofs_workgroup_unfreeze(grp, 1); @@ -247,7 +247,9 @@ unsigned long erofs_shrink_scan(struct shrinker *shrink, spin_unlock(&erofs_sb_list_lock); sbi->shrinker_run_no = run_no; - /* add scan handlers here */ +#ifdef CONFIG_EROFS_FS_ZIP + freed += erofs_shrink_workstation(sbi, nr, false); +#endif spin_lock(&erofs_sb_list_lock); /* Get the next list element before we move this one */ @@ -260,7 +262,6 @@ unsigned long erofs_shrink_scan(struct shrinker *shrink, list_move_tail(&sbi->list, &erofs_sb_list); mutex_unlock(&sbi->umount_mutex); - freed += erofs_shrink_workstation(sbi, nr, false); if (freed >= nr) break; } From 6caa58413692cf3d62c5cc57800a92166c37423b Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sun, 29 Jul 2018 13:37:57 +0800 Subject: [PATCH 634/903] staging: erofs: fix conditional uninitialized `pcn' in z_erofs_map_blocks_iter This patch adds error handling code for z_erofs_map_blocks_iter to fix the compiler blame. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 0e410a228cd4..bd2d7a8d5085 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1532,13 +1532,14 @@ int z_erofs_map_blocks_iter(struct inode *inode, unsigned long long ofs, end; struct z_erofs_vle_decompressed_index *di; erofs_blk_t e_blkaddr, pcn; - unsigned lcn, logical_cluster_ofs; + unsigned lcn, logical_cluster_ofs, cluster_type; u32 ofs_rem; struct page *mpage = *mpage_ret; void *kaddr; bool initial; const unsigned int clusterbits = EROFS_SB(inode->i_sb)->clusterbits; const unsigned int clustersize = 1 << clusterbits; + int err = 0; /* if both m_(l,p)len are 0, regularize l_lblk, l_lofs, etc... */ initial = !map->m_llen; @@ -1592,7 +1593,9 @@ int z_erofs_map_blocks_iter(struct inode *inode, end = (u64)(lcn + 1) * clustersize; - switch (vle_cluster_type(di)) { + cluster_type = vle_cluster_type(di); + + switch (cluster_type) { case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: if (ofs_rem >= logical_cluster_ofs) map->m_flags ^= EROFS_MAP_ZIPPED; @@ -1608,13 +1611,24 @@ int z_erofs_map_blocks_iter(struct inode *inode, break; } - BUG_ON(!lcn); /* logical cluster number >= 1 */ + /* logical cluster number should be >= 1 */ + if (unlikely(!lcn)) { + errln("invalid logical cluster 0 at nid %llu", + EROFS_V(inode)->nid); + err = -EIO; + goto unmap_out; + } end = (lcn-- * clustersize) | logical_cluster_ofs; case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: /* get the correspoinding first chunk */ ofs = vle_get_logical_extent_head(inode, mpage_ret, &kaddr, lcn, &pcn, &map->m_flags); mpage = *mpage_ret; + default: + errln("unknown cluster type %u at offset %llu of nid %llu", + cluster_type, ofs, EROFS_V(inode)->nid); + err = -EIO; + goto unmap_out; } map->m_la = ofs; @@ -1630,6 +1644,9 @@ out: debugln("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o", __func__, map->m_la, map->m_pa, map->m_llen, map->m_plen, map->m_flags); - return 0; + + /* aggressively BUG_ON iff CONFIG_EROFS_FS_DEBUG is on */ + DBG_BUGON(err < 0); + return err; } From 5b6e80cc9806a5cf78f68df2b6b64812b51d91c9 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sat, 28 Jul 2018 12:33:24 -0700 Subject: [PATCH 635/903] staging: gasket: core: hold reference on device while in use Hold a reference on the struct device while a pointer to that device is in use by gasket. Reported-by: Greg Kroah-Hartman Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 859a6df9e12d..2b484d067c38 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -448,7 +448,7 @@ static int gasket_alloc_dev( gasket_dev->internal_desc = internal_desc; gasket_dev->dev_idx = dev_idx; snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", kobj_name); - gasket_dev->dev = parent; + gasket_dev->dev = get_device(parent); /* gasket_bar_data is uninitialized. */ gasket_dev->num_page_tables = driver_desc->num_page_tables; /* max_page_table_size and *page table are uninit'ed */ @@ -487,7 +487,7 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev) mutex_lock(&internal_desc->mutex); internal_desc->devs[gasket_dev->dev_idx] = NULL; mutex_unlock(&internal_desc->mutex); - + put_device(gasket_dev->dev); kfree(gasket_dev); } From bb8a14a3d8203f3af45f84c6169cc09ef56156a3 Mon Sep 17 00:00:00 2001 From: Dmitriy Cherkasov Date: Sat, 28 Jul 2018 22:55:24 +0000 Subject: [PATCH 636/903] staging: gasket: use NULL instead of 0 for null pointer Fixes sparse warning: Using plain integer as NULL pointer Signed-off-by: Dmitriy Cherkasov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 722839603f20..b9304d221722 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1605,7 +1605,7 @@ nomem: if (gasket_dev->page_table[index]->coherent_pages) { kfree(gasket_dev->page_table[index]->coherent_pages); - gasket_dev->page_table[index]->coherent_pages = 0; + gasket_dev->page_table[index]->coherent_pages = NULL; } gasket_dev->page_table[index]->num_coherent_pages = 0; return -ENOMEM; From 1ebc787ae5181c98060f25157b490cdad92728a7 Mon Sep 17 00:00:00 2001 From: Tomas Novotny Date: Wed, 25 Jul 2018 17:18:18 +0200 Subject: [PATCH 637/903] iio: vcnl4000: make the driver extendable There are similar chips in the vcnl4xxx family. The initialization and communication is a bit different for members of the family, so this patch makes the driver extendable for different chips. There is no functional change. Signed-off-by: Tomas Novotny Signed-off-by: Jonathan Cameron --- drivers/iio/light/vcnl4000.c | 85 ++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index c599a90506ad..32c0b531395f 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -26,8 +26,8 @@ #include #define VCNL4000_DRV_NAME "vcnl4000" -#define VCNL4000_ID 0x01 -#define VCNL4010_ID 0x02 /* for VCNL4020, VCNL4010 */ +#define VCNL4000_PROD_ID 0x01 +#define VCNL4010_PROD_ID 0x02 /* for VCNL4020, VCNL4010 */ #define VCNL4000_COMMAND 0x80 /* Command register */ #define VCNL4000_PROD_REV 0x81 /* Product ID and Revision ID */ @@ -46,17 +46,50 @@ #define VCNL4000_AL_OD BIT(4) /* start on-demand ALS measurement */ #define VCNL4000_PS_OD BIT(3) /* start on-demand proximity measurement */ +enum vcnl4000_device_ids { + VCNL4000, +}; + struct vcnl4000_data { struct i2c_client *client; + enum vcnl4000_device_ids id; + int rev; + int al_scale; + const struct vcnl4000_chip_spec *chip_spec; struct mutex lock; }; +struct vcnl4000_chip_spec { + const char *prod; + int (*init)(struct vcnl4000_data *data); + int (*measure_light)(struct vcnl4000_data *data, int *val); + int (*measure_proximity)(struct vcnl4000_data *data, int *val); +}; + static const struct i2c_device_id vcnl4000_id[] = { - { "vcnl4000", 0 }, + { "vcnl4000", VCNL4000 }, { } }; MODULE_DEVICE_TABLE(i2c, vcnl4000_id); +static int vcnl4000_init(struct vcnl4000_data *data) +{ + int ret, prod_id; + + ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV); + if (ret < 0) + return ret; + + prod_id = ret >> 4; + if (prod_id != VCNL4010_PROD_ID && prod_id != VCNL4000_PROD_ID) + return -ENODEV; + + data->rev = ret & 0xf; + data->al_scale = 250000; + + return 0; +}; + static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask, u8 rdy_mask, u8 data_reg, int *val) { @@ -103,6 +136,29 @@ fail: return ret; } +static int vcnl4000_measure_light(struct vcnl4000_data *data, int *val) +{ + return vcnl4000_measure(data, + VCNL4000_AL_OD, VCNL4000_AL_RDY, + VCNL4000_AL_RESULT_HI, val); +} + +static int vcnl4000_measure_proximity(struct vcnl4000_data *data, int *val) +{ + return vcnl4000_measure(data, + VCNL4000_PS_OD, VCNL4000_PS_RDY, + VCNL4000_PS_RESULT_HI, val); +} + +static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { + [VCNL4000] = { + .prod = "VCNL4000", + .init = vcnl4000_init, + .measure_light = vcnl4000_measure_light, + .measure_proximity = vcnl4000_measure_proximity, + }, +}; + static const struct iio_chan_spec vcnl4000_channels[] = { { .type = IIO_LIGHT, @@ -125,16 +181,12 @@ static int vcnl4000_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: switch (chan->type) { case IIO_LIGHT: - ret = vcnl4000_measure(data, - VCNL4000_AL_OD, VCNL4000_AL_RDY, - VCNL4000_AL_RESULT_HI, val); + ret = data->chip_spec->measure_light(data, val); if (ret < 0) return ret; return IIO_VAL_INT; case IIO_PROXIMITY: - ret = vcnl4000_measure(data, - VCNL4000_PS_OD, VCNL4000_PS_RDY, - VCNL4000_PS_RESULT_HI, val); + ret = data->chip_spec->measure_proximity(data, val); if (ret < 0) return ret; return IIO_VAL_INT; @@ -146,7 +198,7 @@ static int vcnl4000_read_raw(struct iio_dev *indio_dev, return -EINVAL; *val = 0; - *val2 = 250000; + *val2 = data->al_scale; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; @@ -162,7 +214,7 @@ static int vcnl4000_probe(struct i2c_client *client, { struct vcnl4000_data *data; struct iio_dev *indio_dev; - int ret, prod_id; + int ret; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) @@ -171,19 +223,16 @@ static int vcnl4000_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; + data->id = id->driver_data; + data->chip_spec = &vcnl4000_chip_spec_cfg[data->id]; mutex_init(&data->lock); - ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV); + ret = data->chip_spec->init(data); if (ret < 0) return ret; - prod_id = ret >> 4; - if (prod_id != VCNL4010_ID && prod_id != VCNL4000_ID) - return -ENODEV; - dev_dbg(&client->dev, "%s Ambient light/proximity sensor, Rev: %02x\n", - (prod_id == VCNL4010_ID) ? "VCNL4010/4020" : "VCNL4000", - ret & 0xf); + data->chip_spec->prod, data->rev); indio_dev->dev.parent = &client->dev; indio_dev->info = &vcnl4000_info; From bd757b5d2e0b30939ba63b80af7355fe755fe2da Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 24 Jul 2018 09:49:33 -0700 Subject: [PATCH 638/903] staging: rtl8192e: ieee80211: Convert from ahash to shash This is an identical change to the wireless/lib80211 of the same name. In preparing to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash to direct shash. By removing a layer of indirection this both improves performance and reduces stack usage. The stack allocation will be made a fixed size in a later patch to the crypto subsystem. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 56 ++++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index ae103b0b7a2a..9f18be14dda6 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -50,9 +50,9 @@ struct rtllib_tkip_data { int key_idx; struct crypto_skcipher *rx_tfm_arc4; - struct crypto_ahash *rx_tfm_michael; + struct crypto_shash *rx_tfm_michael; struct crypto_skcipher *tx_tfm_arc4; - struct crypto_ahash *tx_tfm_michael; + struct crypto_shash *tx_tfm_michael; /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16]; u8 tx_hdr[16]; @@ -74,8 +74,7 @@ static void *rtllib_tkip_init(int key_idx) goto fail; } - priv->tx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->tx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->tx_tfm_michael)) { pr_debug("Could not allocate crypto API michael_mic\n"); priv->tx_tfm_michael = NULL; @@ -90,8 +89,7 @@ static void *rtllib_tkip_init(int key_idx) goto fail; } - priv->rx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->rx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->rx_tfm_michael)) { pr_debug("Could not allocate crypto API michael_mic\n"); priv->rx_tfm_michael = NULL; @@ -101,9 +99,9 @@ static void *rtllib_tkip_init(int key_idx) fail: if (priv) { - crypto_free_ahash(priv->tx_tfm_michael); + crypto_free_shash(priv->tx_tfm_michael); crypto_free_skcipher(priv->tx_tfm_arc4); - crypto_free_ahash(priv->rx_tfm_michael); + crypto_free_shash(priv->rx_tfm_michael); crypto_free_skcipher(priv->rx_tfm_arc4); kfree(priv); } @@ -117,9 +115,9 @@ static void rtllib_tkip_deinit(void *priv) struct rtllib_tkip_data *_priv = priv; if (_priv) { - crypto_free_ahash(_priv->tx_tfm_michael); + crypto_free_shash(_priv->tx_tfm_michael); crypto_free_skcipher(_priv->tx_tfm_arc4); - crypto_free_ahash(_priv->rx_tfm_michael); + crypto_free_shash(_priv->rx_tfm_michael); crypto_free_skcipher(_priv->rx_tfm_arc4); } kfree(priv); @@ -504,29 +502,31 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } -static int michael_mic(struct crypto_ahash *tfm_michael, u8 *key, u8 *hdr, +static int michael_mic(struct crypto_shash *tfm_michael, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { - AHASH_REQUEST_ON_STACK(req, tfm_michael); - struct scatterlist sg[2]; + SHASH_DESC_ON_STACK(desc, tfm_michael); int err; - if (tfm_michael == NULL) { - pr_warn("michael_mic: tfm_michael == NULL\n"); - return -1; - } - sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); + desc->tfm = tfm_michael; + desc->flags = 0; - if (crypto_ahash_setkey(tfm_michael, key, 8)) + if (crypto_shash_setkey(tfm_michael, key, 8)) return -1; - ahash_request_set_tfm(req, tfm_michael); - ahash_request_set_callback(req, 0, NULL, NULL); - ahash_request_set_crypt(req, sg, mic, data_len + 16); - err = crypto_ahash_digest(req); - ahash_request_zero(req); + err = crypto_shash_init(desc); + if (err) + goto out; + err = crypto_shash_update(desc, hdr, 16); + if (err) + goto out; + err = crypto_shash_update(desc, data, data_len); + if (err) + goto out; + err = crypto_shash_final(desc, mic); + +out: + shash_desc_zero(desc); return err; } @@ -663,9 +663,9 @@ static int rtllib_tkip_set_key(void *key, int len, u8 *seq, void *priv) { struct rtllib_tkip_data *tkey = priv; int keyidx; - struct crypto_ahash *tfm = tkey->tx_tfm_michael; + struct crypto_shash *tfm = tkey->tx_tfm_michael; struct crypto_skcipher *tfm2 = tkey->tx_tfm_arc4; - struct crypto_ahash *tfm3 = tkey->rx_tfm_michael; + struct crypto_shash *tfm3 = tkey->rx_tfm_michael; struct crypto_skcipher *tfm4 = tkey->rx_tfm_arc4; keyidx = tkey->key_idx; From 2f675c91eeb7f59d649825f931184becdc94b905 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 24 Jul 2018 09:49:32 -0700 Subject: [PATCH 639/903] staging: rtl8192u: ieee80211: Convert from ahash to shash This is an identical change to the wireless/lib80211 of the same name. In preparing to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash to direct shash. By removing a layer of indirection this both improves performance and reduces stack usage. The stack allocation will be made a fixed size in a later patch to the crypto subsystem. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c index a7efaae4e25a..1088fa0aee0e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c @@ -54,9 +54,9 @@ struct ieee80211_tkip_data { int key_idx; struct crypto_skcipher *rx_tfm_arc4; - struct crypto_ahash *rx_tfm_michael; + struct crypto_shash *rx_tfm_michael; struct crypto_skcipher *tx_tfm_arc4; - struct crypto_ahash *tx_tfm_michael; + struct crypto_shash *tx_tfm_michael; /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; @@ -80,8 +80,7 @@ static void *ieee80211_tkip_init(int key_idx) goto fail; } - priv->tx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->tx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->tx_tfm_michael)) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); @@ -98,8 +97,7 @@ static void *ieee80211_tkip_init(int key_idx) goto fail; } - priv->rx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->rx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->rx_tfm_michael)) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); @@ -111,9 +109,9 @@ static void *ieee80211_tkip_init(int key_idx) fail: if (priv) { - crypto_free_ahash(priv->tx_tfm_michael); + crypto_free_shash(priv->tx_tfm_michael); crypto_free_skcipher(priv->tx_tfm_arc4); - crypto_free_ahash(priv->rx_tfm_michael); + crypto_free_shash(priv->rx_tfm_michael); crypto_free_skcipher(priv->rx_tfm_arc4); kfree(priv); } @@ -127,9 +125,9 @@ static void ieee80211_tkip_deinit(void *priv) struct ieee80211_tkip_data *_priv = priv; if (_priv) { - crypto_free_ahash(_priv->tx_tfm_michael); + crypto_free_shash(_priv->tx_tfm_michael); crypto_free_skcipher(_priv->tx_tfm_arc4); - crypto_free_ahash(_priv->rx_tfm_michael); + crypto_free_shash(_priv->rx_tfm_michael); crypto_free_skcipher(_priv->rx_tfm_arc4); } kfree(priv); @@ -500,30 +498,31 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return keyidx; } -static int michael_mic(struct crypto_ahash *tfm_michael, u8 *key, u8 *hdr, +static int michael_mic(struct crypto_shash *tfm_michael, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { - AHASH_REQUEST_ON_STACK(req, tfm_michael); - struct scatterlist sg[2]; + SHASH_DESC_ON_STACK(desc, tfm_michael); int err; - if (tfm_michael == NULL) { - printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); - return -1; - } + desc->tfm = tfm_michael; + desc->flags = 0; - sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); - - if (crypto_ahash_setkey(tfm_michael, key, 8)) + if (crypto_shash_setkey(tfm_michael, key, 8)) return -1; - ahash_request_set_tfm(req, tfm_michael); - ahash_request_set_callback(req, 0, NULL, NULL); - ahash_request_set_crypt(req, sg, mic, data_len + 16); - err = crypto_ahash_digest(req); - ahash_request_zero(req); + err = crypto_shash_init(desc); + if (err) + goto out; + err = crypto_shash_update(desc, hdr, 16); + if (err) + goto out; + err = crypto_shash_update(desc, data, data_len); + if (err) + goto out; + err = crypto_shash_final(desc, mic); + +out: + shash_desc_zero(desc); return err; } @@ -663,9 +662,9 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; - struct crypto_ahash *tfm = tkey->tx_tfm_michael; + struct crypto_shash *tfm = tkey->tx_tfm_michael; struct crypto_skcipher *tfm2 = tkey->tx_tfm_arc4; - struct crypto_ahash *tfm3 = tkey->rx_tfm_michael; + struct crypto_shash *tfm3 = tkey->rx_tfm_michael; struct crypto_skcipher *tfm4 = tkey->rx_tfm_arc4; keyidx = tkey->key_idx; From 910ca496b8dceac588adb85d81a9351f1cdf63d1 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Fri, 27 Jul 2018 21:37:37 +0530 Subject: [PATCH 640/903] staging: mt7621-mmc: Use BIT macro instead of explicit shifting in board.h Replace explicit shifting with BIT macro in board.h. Issue found by checkpatch. Signed-off-by: Nishad Kamdar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/board.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-mmc/board.h b/drivers/staging/mt7621-mmc/board.h index a7d82f321b00..983791ee308d 100644 --- a/drivers/staging/mt7621-mmc/board.h +++ b/drivers/staging/mt7621-mmc/board.h @@ -36,10 +36,10 @@ #ifndef __ARCH_ARM_MACH_BOARD_H #define __ARCH_ARM_MACH_BOARD_H -#define MSDC_CD_PIN_EN (1 << 0) /* card detection pin is wired */ -#define MSDC_WP_PIN_EN (1 << 1) /* write protection pin is wired */ -#define MSDC_RST_PIN_EN (1 << 2) /* emmc reset pin is wired */ -#define MSDC_REMOVABLE (1 << 5) /* removable slot */ +#define MSDC_CD_PIN_EN BIT(0) /* card detection pin is wired */ +#define MSDC_WP_PIN_EN BIT(1) /* write protection pin is wired */ +#define MSDC_RST_PIN_EN BIT(2) /* emmc reset pin is wired */ +#define MSDC_REMOVABLE BIT(5) /* removable slot */ #define MSDC_SMPL_RISING (0) #define MSDC_SMPL_FALLING (1) From d3094361a91f21a5b6092b4d50c47be570ae02cf Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 26 Jul 2018 21:46:59 +0200 Subject: [PATCH 641/903] staging: rtl8188eu: remove unused sreset_get_wifi_status() The function sreset_get_wifi_status() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sreset.c | 27 ------------------- .../staging/rtl8188eu/include/rtw_sreset.h | 1 - 2 files changed, 28 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_sreset.c b/drivers/staging/rtl8188eu/core/rtw_sreset.c index 4097380b0bc9..fb5adaf4a42c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sreset.c +++ b/drivers/staging/rtl8188eu/core/rtw_sreset.c @@ -15,33 +15,6 @@ void rtw_hal_sreset_init(struct adapter *padapter) psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; } -u8 sreset_get_wifi_status(struct adapter *padapter) -{ - struct sreset_priv *psrtpriv = &padapter->HalData->srestpriv; - - u8 status = WIFI_STATUS_SUCCESS; - u32 val32 = 0; - - val32 = usb_read32(padapter, REG_TXDMA_STATUS); - if (val32 == 0xeaeaeaea) { - psrtpriv->Wifi_Error_Status = WIFI_IF_NOT_EXIST; - } else if (val32 != 0) { - DBG_88E("txdmastatu(%x)\n", val32); - psrtpriv->Wifi_Error_Status = WIFI_MAC_TXDMA_ERROR; - } - - if (WIFI_STATUS_SUCCESS != psrtpriv->Wifi_Error_Status) { - DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->Wifi_Error_Status); - status = psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL|USB_WRITE_PORT_FAIL)); - } - DBG_88E("==> %s wifi_status(0x%x)\n", __func__, status); - - /* status restore */ - psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; - - return status; -} - void sreset_set_wifi_error_status(struct adapter *padapter, u32 status) { padapter->HalData->srestpriv.Wifi_Error_Status = status; diff --git a/drivers/staging/rtl8188eu/include/rtw_sreset.h b/drivers/staging/rtl8188eu/include/rtw_sreset.h index a03989461985..3ee6a4a7847d 100644 --- a/drivers/staging/rtl8188eu/include/rtw_sreset.h +++ b/drivers/staging/rtl8188eu/include/rtw_sreset.h @@ -25,7 +25,6 @@ struct sreset_priv { #define WIFI_RX_HANG BIT(5) #define WIFI_IF_NOT_EXIST BIT(6) -u8 sreset_get_wifi_status(struct adapter *padapter); void sreset_set_wifi_error_status(struct adapter *padapter, u32 status); #endif From 318c66d456b81ce15b5e17b551d7db6ecc4aeac6 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Wed, 25 Jul 2018 20:30:31 +0100 Subject: [PATCH 642/903] staging: wlan-ng: remove volatile from reapable field in hfa384x_usbctlx Fix checkpatch.pl warning: "Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rs" reapable is not used to access h/w directly, so volatile is not necessary. >From reading the code, the contexts in which the field may be updated/accessed across threads are protected by the hw->ctlxq.lock spinlock, where hw is the device struct, so appears thread-safe. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 67a944c0d690..992ebaa1071f 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1176,7 +1176,7 @@ struct hfa384x_usbctlx { enum ctlx_state state; /* Tracks running state */ struct completion done; - volatile int reapable; /* Food for the reaper task */ + int reapable; /* Food for the reaper task */ ctlx_cmdcb_t cmdcb; /* Async command callback */ ctlx_usercb_t usercb; /* Async user callback, */ From d47b10e6f90de6f0275eb3c9ffbc68c5534af9e4 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Wed, 25 Jul 2018 20:30:32 +0100 Subject: [PATCH 643/903] staging: wlan-ng: correction to comment in hfa384x_usb The comment for hfa384x_docmd incorrectly states that usercb_data should be NULL for DOASYNC calls; in fact, it should be NULL for DOWAIT calls (this is consistent with the other similar functions and the rest of the comment text). Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 33e97ffbb436..16f7dd266e3b 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -1290,7 +1290,7 @@ cleanup: * cmdcb command-specific callback * usercb user callback for async calls, NULL for DOWAIT calls * usercb_data user supplied data pointer for async calls, NULL - * for DOASYNC calls + * for DOWAIT calls * * Returns: * 0 success From 891f6de39ced523544a5391608c088c015e738d2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 25 Jul 2018 21:37:55 +0200 Subject: [PATCH 644/903] staging: rtl8188eu: remove unused ODM_RASupport_Init() The function ODM_RASupport_Init() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 10 ---------- .../staging/rtl8188eu/include/hal8188e_rate_adaptive.h | 2 -- 2 files changed, 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c index bbb981c6bcec..464c11710398 100644 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c @@ -542,16 +542,6 @@ odm_RATxRPTTimerSetting( ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" <===== odm_RATxRPTTimerSetting()\n")); } -void -ODM_RASupport_Init( - struct odm_dm_struct *dm_odm - ) -{ - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n")); - - dm_odm->RaSupport88E = true; -} - int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) { struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid]; diff --git a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h index 96ebda93b4ee..5b59c25e4c8a 100644 --- a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h +++ b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h @@ -49,8 +49,6 @@ /* End rate adaptive define */ -void ODM_RASupport_Init(struct odm_dm_struct *dm_odm); - int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm); int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 MacID); From b045b429151c40a00fece3318fcab4c5f9ab5ebc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 25 Jul 2018 21:37:56 +0200 Subject: [PATCH 645/903] staging: rtl8188eu: remove unused CAM_empty_entry() The function CAM_empty_entry() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 5 ----- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 1 - 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 5c4f3f8d013f..474aa9dcf39d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -434,11 +434,6 @@ unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval) return bcn_interval << 2; } -void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex) -{ - rtw_hal_set_hwreg(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex)); -} - void invalidate_cam_all(struct adapter *padapter) { rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 8ecf43d03278..43a3c5009ad0 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -487,7 +487,6 @@ void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key); void clear_cam_entry(struct adapter *padapter, u8 entry); void invalidate_cam_all(struct adapter *padapter); -void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex); int allocate_fw_sta_entry(struct adapter *padapter); void flush_all_cam_entry(struct adapter *padapter); From c60b03effc26a392107992cbc99c7d7e381c8f20 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 25 Jul 2018 21:37:57 +0200 Subject: [PATCH 646/903] staging: rtl8188eu: remove unused rtw_get_oper_bw() The function rtw_get_oper_bw() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 5 ----- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 1 - 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 474aa9dcf39d..ab97fcdd6481 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -298,11 +298,6 @@ inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch) adapter->mlmeextpriv.oper_channel = ch; } -inline u8 rtw_get_oper_bw(struct adapter *adapter) -{ - return adapter->mlmeextpriv.oper_bwmode; -} - inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw) { adapter->mlmeextpriv.oper_bwmode = bw; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 43a3c5009ad0..50051a1b0655 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -470,7 +470,6 @@ void Set_MSR(struct adapter *padapter, u8 type); u8 rtw_get_oper_ch(struct adapter *adapter); void rtw_set_oper_ch(struct adapter *adapter, u8 ch); -u8 rtw_get_oper_bw(struct adapter *adapter); void rtw_set_oper_bw(struct adapter *adapter, u8 bw); u8 rtw_get_oper_choffset(struct adapter *adapter); void rtw_set_oper_choffset(struct adapter *adapter, u8 offset); From 12f3ccfbc560cf62ea29a50dd6c6edd2fc75aa4c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 25 Jul 2018 21:37:58 +0200 Subject: [PATCH 647/903] staging: rtl8188eu: remove unused rtw_get_oper_choffset() The function rtw_get_oper_choffset() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 5 ----- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 1 - 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index ab97fcdd6481..0fe35e141926 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -303,11 +303,6 @@ inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw) adapter->mlmeextpriv.oper_bwmode = bw; } -inline u8 rtw_get_oper_choffset(struct adapter *adapter) -{ - return adapter->mlmeextpriv.oper_ch_offset; -} - inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset) { adapter->mlmeextpriv.oper_ch_offset = offset; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 50051a1b0655..c072e1e25d61 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -471,7 +471,6 @@ void Set_MSR(struct adapter *padapter, u8 type); u8 rtw_get_oper_ch(struct adapter *adapter); void rtw_set_oper_ch(struct adapter *adapter, u8 ch); void rtw_set_oper_bw(struct adapter *adapter, u8 bw); -u8 rtw_get_oper_choffset(struct adapter *adapter); void rtw_set_oper_choffset(struct adapter *adapter, u8 offset); void set_channel_bwmode(struct adapter *padapter, unsigned char channel, From 66b19887fbaf054b74c1d9c37a2c20fcac756de6 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 25 Jul 2018 23:16:23 +0100 Subject: [PATCH 648/903] staging:rtl8192u: Rename bit definition ISR_TxBcnOk - Style Rename the bit definition ISR_TxBcnOk to ISR_TX_BCN_OK. This change clears the checkpatch issue with CamelCase naming. The change is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 80672100ea26..dee3180f02ba 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -249,7 +249,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { + if (rx_intr_status.interrupt_status & ISR_TX_BCN_OK) { priv->ieee80211->bibsscoordinator = true; priv->stats.txbeaconokint++; } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 85fb49ca7bc8..5de6d8f4fd81 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -10,7 +10,7 @@ #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) /* 2008/05/08 amy For USB constant. */ -#define ISR_TxBcnOk BIT(27) /* Transmit Beacon OK */ +#define ISR_TX_BCN_OK BIT(27) /* Transmit Beacon OK */ #define ISR_TxBcnErr BIT(26) /* Transmit Beacon Error */ #define ISR_BcnTimerIntr BIT(13) /* Beacon Timer Interrupt */ From 85dc31eb8c49d6c2427b35b7cb58f91c67357f78 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 25 Jul 2018 23:16:25 +0100 Subject: [PATCH 649/903] staging:rtl8192u: Rename ISR_TxBcnErr bit definition - Style Rename the bit definition ISR_TxBcnErr to ISR_TX_BCN_ERR. This change clears the checkpatch issue with CamelCase naming. The change is purely a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index dee3180f02ba..5eebadbbf48d 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -252,7 +252,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) if (rx_intr_status.interrupt_status & ISR_TX_BCN_OK) { priv->ieee80211->bibsscoordinator = true; priv->stats.txbeaconokint++; - } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { + } else if (rx_intr_status.interrupt_status & ISR_TX_BCN_ERR) { priv->ieee80211->bibsscoordinator = false; priv->stats.txbeaconerr++; } diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 5de6d8f4fd81..06f57016de2b 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -11,7 +11,7 @@ /* 2008/05/08 amy For USB constant. */ #define ISR_TX_BCN_OK BIT(27) /* Transmit Beacon OK */ -#define ISR_TxBcnErr BIT(26) /* Transmit Beacon Error */ +#define ISR_TX_BCN_ERR BIT(26) /* Transmit Beacon Error */ #define ISR_BcnTimerIntr BIT(13) /* Beacon Timer Interrupt */ From 4434e159d064f41e138cd1c8a758f066043e9e09 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 25 Jul 2018 23:16:26 +0100 Subject: [PATCH 650/903] staging:rtl8192u: Rename ISR_BcnTimerIntr - Style Rename the bit definition ISR_BcnTimerIntr to ISR_BCN_TIMER_INTR. This change clears the checkpatch issue with CamelCase naming. The change is purely a style change and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 5eebadbbf48d..3140b3413f91 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -257,7 +257,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) priv->stats.txbeaconerr++; } - if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) + if (rx_intr_status.interrupt_status & ISR_BCN_TIMER_INTR) cmdpkt_beacontimerinterrupt_819xusb(dev); } diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 06f57016de2b..85f2ba5821ac 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -12,7 +12,7 @@ /* 2008/05/08 amy For USB constant. */ #define ISR_TX_BCN_OK BIT(27) /* Transmit Beacon OK */ #define ISR_TX_BCN_ERR BIT(26) /* Transmit Beacon Error */ -#define ISR_BcnTimerIntr BIT(13) /* Beacon Timer Interrupt */ +#define ISR_BCN_TIMER_INTR BIT(13) /* Beacon Timer Interrupt */ /* Define element ID of command packet. */ From 6b59fd408d1bc6bec8629ff49f55b96420bb6add Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Wed, 25 Jul 2018 23:16:27 +0100 Subject: [PATCH 651/903] staging:rtl8192u: Remove multiple blank lines - Style Remove multiple blank lines, raise a checkpatch issue. This is purely a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 85f2ba5821ac..0eb6b2321c9c 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -14,7 +14,6 @@ #define ISR_TX_BCN_ERR BIT(26) /* Transmit Beacon Error */ #define ISR_BCN_TIMER_INTR BIT(13) /* Beacon Timer Interrupt */ - /* Define element ID of command packet. */ /*------------------------------Define structure----------------------------*/ @@ -65,7 +64,6 @@ typedef struct tag_cmd_pkt_interrupt_status { u32 interrupt_status; /* Interrupt Status. */ } cmpk_intr_sta_t; - /* 3. TX side: Set configuration packet. */ typedef struct tag_cmd_pkt_set_configuration { u8 element_id; /* Command packet type. */ @@ -191,5 +189,4 @@ u32 cmpk_message_handle_rx(struct net_device *dev, rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen); - #endif From a1b34e427c5602f7e21ea449e6561165a0c4b7dc Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:11 +0100 Subject: [PATCH 652/903] staging:rtl8192u: Rename SwChnlCmd - Style Rename the structure SwChnlCmd to sw_chnl_cmd. This change clears the checkpatch issue with CamelCase naming. The change is purely a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 16 ++++++++-------- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 75fcd3134b6d..4a49bc1f139c 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1215,8 +1215,8 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, } /****************************************************************************** - * function: This function sets command table variable (struct SwChnlCmd). - * input: SwChnlCmd *CmdTable //table to be set + * function: This function sets command table variable (struct sw_chnl_cmd). + * input: sw_chnl_cmd *CmdTable //table to be set * u32 CmdTableIdx //variable index in table to be set * u32 CmdTableSz //table size * switch_chan_cmd_id CmdID //command ID to set @@ -1227,11 +1227,11 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, * return: true if finished, false otherwise * notice: ******************************************************************************/ -static u8 rtl8192_phy_SetSwChnlCmdArray(struct SwChnlCmd *CmdTable, u32 CmdTableIdx, +static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, u32 CmdTableSz, enum switch_chan_cmd_id CmdID, u32 Para1, u32 Para2, u32 msDelay) { - struct SwChnlCmd *pCmd; + struct sw_chnl_cmd *pCmd; if (CmdTable == NULL) { RT_TRACE(COMP_ERR, "%s(): CmdTable cannot be NULL\n", __func__); @@ -1268,13 +1268,13 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, u8 *step, u32 *delay) { struct r8192_priv *priv = ieee80211_priv(dev); - struct SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT]; + struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; u32 PreCommonCmdCnt; - struct SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT]; + struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT]; u32 PostCommonCmdCnt; - struct SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; + struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; u32 RfDependCmdCnt; - struct SwChnlCmd *CurrentCmd = NULL; + struct sw_chnl_cmd *CurrentCmd = NULL; u8 eRFPath; RT_TRACE(COMP_CH, "%s() stage: %d, step: %d, channel: %d\n", diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 75aa56ddd22f..509b18415127 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -18,7 +18,7 @@ enum switch_chan_cmd_id { /* -----------------------Define structure---------------------- */ /* 1. Switch channel related */ -struct SwChnlCmd { +struct sw_chnl_cmd { enum switch_chan_cmd_id CmdID; u32 Para1; u32 Para2; From d2a5c987e7f25461cbd87d679155d19047920898 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:12 +0100 Subject: [PATCH 653/903] staging:rtl8192u: Rename CmdID - Style Rename the member variable CmdId to cmd_id. This change clears the checkpatch issue with CamelCase naming. The change is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 6 +++--- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 4a49bc1f139c..17cc47e20145 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1244,7 +1244,7 @@ static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTab } pCmd = CmdTable + CmdTableIdx; - pCmd->CmdID = CmdID; + pCmd->cmd_id = CmdID; pCmd->Para1 = Para1; pCmd->Para2 = Para2; pCmd->msDelay = msDelay; @@ -1363,7 +1363,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, break; } - if (CurrentCmd->CmdID == CMD_ID_END) { + if (CurrentCmd->cmd_id == CMD_ID_END) { if ((*stage) == 2) { (*delay) = CurrentCmd->msDelay; return true; @@ -1373,7 +1373,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, continue; } - switch (CurrentCmd->CmdID) { + switch (CurrentCmd->cmd_id) { case CMD_ID_SET_TX_PWR_LEVEL: if (priv->card_8192_version == (u8)VERSION_819xU_A) /* consider it later! */ diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 509b18415127..75970febaac5 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -19,7 +19,7 @@ enum switch_chan_cmd_id { /* -----------------------Define structure---------------------- */ /* 1. Switch channel related */ struct sw_chnl_cmd { - enum switch_chan_cmd_id CmdID; + enum switch_chan_cmd_id cmd_id; u32 Para1; u32 Para2; u32 msDelay; From 33f28ab7a0b72c79c67b7c677fcadc5e63fa2282 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:13 +0100 Subject: [PATCH 654/903] staging:rtl8192u: Rename Para1 > para_1 - Style Rename the member variable Para1 to para_1. This change clears the checkpatch issue with CamelCase naming. The change is purely a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 10 +++++----- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 17cc47e20145..c2a73ec90f70 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1245,7 +1245,7 @@ static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTab pCmd = CmdTable + CmdTableIdx; pCmd->cmd_id = CmdID; - pCmd->Para1 = Para1; + pCmd->para_1 = Para1; pCmd->Para2 = Para2; pCmd->msDelay = msDelay; @@ -1380,22 +1380,22 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, rtl8192_SetTxPowerLevel(dev, channel); break; case CMD_ID_WRITE_PORT_ULONG: - write_nic_dword(dev, CurrentCmd->Para1, + write_nic_dword(dev, CurrentCmd->para_1, CurrentCmd->Para2); break; case CMD_ID_WRITE_PORT_USHORT: - write_nic_word(dev, CurrentCmd->Para1, + write_nic_word(dev, CurrentCmd->para_1, (u16)CurrentCmd->Para2); break; case CMD_ID_WRITE_PORT_UCHAR: - write_nic_byte(dev, CurrentCmd->Para1, + write_nic_byte(dev, CurrentCmd->para_1, (u8)CurrentCmd->Para2); break; case CMD_ID_RF_WRITE_REG: for (eRFPath = 0; eRFPath < RF90_PATH_MAX; eRFPath++) { rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, - CurrentCmd->Para1, + CurrentCmd->para_1, bZebra1_ChannelNum, CurrentCmd->Para2); } diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 75970febaac5..77ae606c77ce 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -20,7 +20,7 @@ enum switch_chan_cmd_id { /* 1. Switch channel related */ struct sw_chnl_cmd { enum switch_chan_cmd_id cmd_id; - u32 Para1; + u32 para_1; u32 Para2; u32 msDelay; } __packed; From 21807031af7c9bd66d134787811677eb8b6ae50c Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:14 +0100 Subject: [PATCH 655/903] staging:rtl8192u: Rename Para2 to para_2 - style Rename member variable Para2 to para_2. This change clears the checkpatch issue with CamelCase naming. The change is purely a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 10 +++++----- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index c2a73ec90f70..904cc8c1a83b 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1246,7 +1246,7 @@ static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTab pCmd = CmdTable + CmdTableIdx; pCmd->cmd_id = CmdID; pCmd->para_1 = Para1; - pCmd->Para2 = Para2; + pCmd->para_2 = Para2; pCmd->msDelay = msDelay; return true; @@ -1381,15 +1381,15 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, break; case CMD_ID_WRITE_PORT_ULONG: write_nic_dword(dev, CurrentCmd->para_1, - CurrentCmd->Para2); + CurrentCmd->para_2); break; case CMD_ID_WRITE_PORT_USHORT: write_nic_word(dev, CurrentCmd->para_1, - (u16)CurrentCmd->Para2); + (u16)CurrentCmd->para_2); break; case CMD_ID_WRITE_PORT_UCHAR: write_nic_byte(dev, CurrentCmd->para_1, - (u8)CurrentCmd->Para2); + (u8)CurrentCmd->para_2); break; case CMD_ID_RF_WRITE_REG: for (eRFPath = 0; eRFPath < RF90_PATH_MAX; eRFPath++) { @@ -1397,7 +1397,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, (enum RF90_RADIO_PATH_E)eRFPath, CurrentCmd->para_1, bZebra1_ChannelNum, - CurrentCmd->Para2); + CurrentCmd->para_2); } break; default: diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 77ae606c77ce..0d4c083ea718 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -21,7 +21,7 @@ enum switch_chan_cmd_id { struct sw_chnl_cmd { enum switch_chan_cmd_id cmd_id; u32 para_1; - u32 Para2; + u32 para_2; u32 msDelay; } __packed; From e918443caf095387a8ccf57e8b38fc858e4b231f Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:15 +0100 Subject: [PATCH 656/903] staging:rtl8192u: Rename msDelay to ms_delay - Style Rename the member variable msDelay to ms_delay. This change clears the checkpatch issue with CamelCase naming. The change is purely a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 6 +++--- drivers/staging/rtl8192u/r819xU_phy.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 904cc8c1a83b..496f42b8f425 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1247,7 +1247,7 @@ static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTab pCmd->cmd_id = CmdID; pCmd->para_1 = Para1; pCmd->para_2 = Para2; - pCmd->msDelay = msDelay; + pCmd->ms_delay = msDelay; return true; } @@ -1365,7 +1365,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, if (CurrentCmd->cmd_id == CMD_ID_END) { if ((*stage) == 2) { - (*delay) = CurrentCmd->msDelay; + (*delay) = CurrentCmd->ms_delay; return true; } (*stage)++; @@ -1407,7 +1407,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, break; } while (true); - (*delay) = CurrentCmd->msDelay; + (*delay) = CurrentCmd->ms_delay; (*step)++; return false; } diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 0d4c083ea718..d783e9c0dfd1 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -22,7 +22,7 @@ struct sw_chnl_cmd { enum switch_chan_cmd_id cmd_id; u32 para_1; u32 para_2; - u32 msDelay; + u32 ms_delay; } __packed; extern u32 rtl819XMACPHY_Array_PG[]; From 4531f1934bf6aefee296c783a42d8d4867800d99 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:16 +0100 Subject: [PATCH 657/903] staging:rtl8192u: Remove proxy struct rtl819XMACPHY_Array_PG - Style Remove the struct rtl819XMACPHY_Array_PG which is simply a proxy for the struct Rtl8192UsbMACPHY_Array_PG. There appears to be no purpose served by this implementation, other then to obscure the Rtl8192UsbMACPHY_Array_PG structure. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 3 +-- drivers/staging/rtl8192u/r819xU_phy.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 496f42b8f425..cc35ca7b9140 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -30,7 +30,6 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { #define rtl819XPHY_REG_1T2RArray Rtl8192UsbPHY_REG_1T2RArray -#define rtl819XMACPHY_Array_PG Rtl8192UsbMACPHY_Array_PG #define rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array #define rtl819XRadioA_Array Rtl8192UsbRadioA_Array #define rtl819XRadioB_Array Rtl8192UsbRadioB_Array @@ -491,7 +490,7 @@ void rtl8192_phy_configmac(struct net_device *dev) if (priv->btxpowerdata_readfromEEPORM) { RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); dwArrayLen = MACPHY_Array_PGLength; - pdwArray = rtl819XMACPHY_Array_PG; + pdwArray = Rtl8192UsbMACPHY_Array_PG; } else { RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array\n"); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index d783e9c0dfd1..3c069b89bcdb 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,7 +25,6 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -extern u32 rtl819XMACPHY_Array_PG[]; extern u32 rtl819XPHY_REG_1T2RArray[]; extern u32 rtl819XAGCTAB_Array[]; extern u32 rtl819XRadioA_Array[]; From 22be361aa9045a60c47fcd9b001e2d478f387989 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:17 +0100 Subject: [PATCH 658/903] staging:rtl8192u: Remove proxy struct rtl819XPHY_REG_1T2RArray - Style Remove the struct rtl819XPHY_REG_1T2RArray which is simply a proxy for the struct Rtl8192UsbPHY_REG_1T2RArray. There appears to be no purpose served by this implementation, other then to obscure the Rtl8192UsbPHY_REG_1T2RArray structure. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 10 ++++------ drivers/staging/rtl8192u/r819xU_phy.h | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index cc35ca7b9140..8d44bbe90221 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -28,8 +28,6 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { 0x0f72, /* 2484 */ }; - -#define rtl819XPHY_REG_1T2RArray Rtl8192UsbPHY_REG_1T2RArray #define rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array #define rtl819XRadioA_Array Rtl8192UsbRadioA_Array #define rtl819XRadioB_Array Rtl8192UsbRadioB_Array @@ -534,13 +532,13 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType) #endif if (ConfigType == BaseBand_Config_PHY_REG) { for (i = 0; i < PHY_REG_1T2RArrayLength; i += 2) { - rtl8192_setBBreg(dev, rtl819XPHY_REG_1T2RArray[i], + rtl8192_setBBreg(dev, Rtl8192UsbPHY_REG_1T2RArray[i], bMaskDWord, - rtl819XPHY_REG_1T2RArray[i+1]); + Rtl8192UsbPHY_REG_1T2RArray[i+1]); RT_TRACE(COMP_DBG, "i: %x, Rtl819xUsbPHY_REGArray[0]=%x Rtl819xUsbPHY_REGArray[1]=%x\n", - i, rtl819XPHY_REG_1T2RArray[i], - rtl819XPHY_REG_1T2RArray[i+1]); + i, Rtl8192UsbPHY_REG_1T2RArray[i], + Rtl8192UsbPHY_REG_1T2RArray[i+1]); } } else if (ConfigType == BaseBand_Config_AGC_TAB) { for (i = 0; i < AGCTAB_ArrayLength; i += 2) { diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 3c069b89bcdb..842837bd6631 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,7 +25,6 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -extern u32 rtl819XPHY_REG_1T2RArray[]; extern u32 rtl819XAGCTAB_Array[]; extern u32 rtl819XRadioA_Array[]; extern u32 rtl819XRadioB_Array[]; From def6b79f3f2d0439822a2eab5ddfe8696e999ad4 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:18 +0100 Subject: [PATCH 659/903] staging:rtl8192u: Remove proxy array rtl819XAGCTAB_Array - Style Remove the array rtl819XAGCTAB_Array which is only a proxy to the array Rtl8192UsbAGCTAB_Array. There appears to be no purpose served by this implementation, other then to obscure the Rtl8192UsbAGCTAB_Array structure, which is actually written to and read from. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 11 +++++------ drivers/staging/rtl8192u/r819xU_phy.h | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 8d44bbe90221..cf7b09f9818a 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -33,7 +33,6 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { #define rtl819XRadioB_Array Rtl8192UsbRadioB_Array #define rtl819XRadioC_Array Rtl8192UsbRadioC_Array #define rtl819XRadioD_Array Rtl8192UsbRadioD_Array -#define rtl819XAGCTAB_Array Rtl8192UsbAGCTAB_Array /****************************************************************************** * function: This function checks different RF type to execute legal judgement. @@ -542,12 +541,12 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType) } } else if (ConfigType == BaseBand_Config_AGC_TAB) { for (i = 0; i < AGCTAB_ArrayLength; i += 2) { - rtl8192_setBBreg(dev, rtl819XAGCTAB_Array[i], - bMaskDWord, rtl819XAGCTAB_Array[i+1]); + rtl8192_setBBreg(dev, Rtl8192UsbAGCTAB_Array[i], + bMaskDWord, Rtl8192UsbAGCTAB_Array[i+1]); RT_TRACE(COMP_DBG, - "i: %x, rtl819XAGCTAB_Array[0]=%x rtl819XAGCTAB_Array[1]=%x\n", - i, rtl819XAGCTAB_Array[i], - rtl819XAGCTAB_Array[i+1]); + "i: %x, Rtl8192UsbAGCTAB_Array[0]=%x Rtl8192UsbAGCTAB_Array[1]=%x\n", + i, Rtl8192UsbAGCTAB_Array[i], + Rtl8192UsbAGCTAB_Array[i+1]); } } } diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 842837bd6631..808a11c475a4 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,7 +25,6 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -extern u32 rtl819XAGCTAB_Array[]; extern u32 rtl819XRadioA_Array[]; extern u32 rtl819XRadioB_Array[]; extern u32 rtl819XRadioC_Array[]; From be208c7695ffb0c873435048c849d7d8323a5a96 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:19 +0100 Subject: [PATCH 660/903] staging:rtl8192u: Remove proxy rtl819XRadioA_Array - Style The array rtl819XRadioA_Array serves as a proxy array for the actual array Rtl8192UsbRadioA_Array. This implementation seems to serve no other purpose then to obscure the actually array Rtl8192UsbRadioA_Array. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 7 +++---- drivers/staging/rtl8192u/r819xU_phy.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index cf7b09f9818a..775dfa847b93 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -29,7 +29,6 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { }; #define rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array -#define rtl819XRadioA_Array Rtl8192UsbRadioA_Array #define rtl819XRadioB_Array Rtl8192UsbRadioB_Array #define rtl819XRadioC_Array Rtl8192UsbRadioC_Array #define rtl819XRadioD_Array Rtl8192UsbRadioD_Array @@ -981,14 +980,14 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, case RF90_PATH_A: for (i = 0; i < RadioA_ArrayLength; i = i+2) { - if (rtl819XRadioA_Array[i] == 0xfe) { + if (Rtl8192UsbRadioA_Array[i] == 0xfe) { mdelay(100); continue; } rtl8192_phy_SetRFReg(dev, eRFPath, - rtl819XRadioA_Array[i], + Rtl8192UsbRadioA_Array[i], bMask12Bits, - rtl819XRadioA_Array[i+1]); + Rtl8192UsbRadioA_Array[i+1]); mdelay(1); } diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 808a11c475a4..7c4b89a5c592 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,7 +25,6 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -extern u32 rtl819XRadioA_Array[]; extern u32 rtl819XRadioB_Array[]; extern u32 rtl819XRadioC_Array[]; extern u32 rtl819XRadioD_Array[]; From 416599d096ae05b164b5112b064df91fdd9dd980 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:20 +0100 Subject: [PATCH 661/903] staging:rtl8192u: Remove proxy rtl819XRadioB_Array - Style Remove the array rtl819XRadioB_Array Rtl8192UsbRadioB_Array which acts as a proxy the actual array Rtl8192UsbRadioB_Array. The only purpose, I can see for this implementation is to obscure the actual array being used Rtl8192UsbRadioB_Array. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 7 +++---- drivers/staging/rtl8192u/r819xU_phy.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 775dfa847b93..1cbb48c5c110 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -29,7 +29,6 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { }; #define rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array -#define rtl819XRadioB_Array Rtl8192UsbRadioB_Array #define rtl819XRadioC_Array Rtl8192UsbRadioC_Array #define rtl819XRadioD_Array Rtl8192UsbRadioD_Array @@ -995,14 +994,14 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, case RF90_PATH_B: for (i = 0; i < RadioB_ArrayLength; i = i+2) { - if (rtl819XRadioB_Array[i] == 0xfe) { + if (Rtl8192UsbRadioB_Array[i] == 0xfe) { mdelay(100); continue; } rtl8192_phy_SetRFReg(dev, eRFPath, - rtl819XRadioB_Array[i], + Rtl8192UsbRadioB_Array[i], bMask12Bits, - rtl819XRadioB_Array[i+1]); + Rtl8192UsbRadioB_Array[i+1]); mdelay(1); } diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 7c4b89a5c592..d708796d7cec 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,7 +25,6 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -extern u32 rtl819XRadioB_Array[]; extern u32 rtl819XRadioC_Array[]; extern u32 rtl819XRadioD_Array[]; From 281da5305b051ea5dd4a8a9dfec5a3b4b7688125 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:21 +0100 Subject: [PATCH 662/903] staging:rtl8192u: Remove proxy rtl819XRadioC_Array - Style Remove the array rtl819XRadioC_Array which is only serving as a proxy for the real array Rtl8192UsbRadioC_Array. This is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 7 +++---- drivers/staging/rtl8192u/r819xU_phy.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 1cbb48c5c110..3ed48d6095d7 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -29,7 +29,6 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { }; #define rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array -#define rtl819XRadioC_Array Rtl8192UsbRadioC_Array #define rtl819XRadioD_Array Rtl8192UsbRadioD_Array /****************************************************************************** @@ -1009,14 +1008,14 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, case RF90_PATH_C: for (i = 0; i < RadioC_ArrayLength; i = i+2) { - if (rtl819XRadioC_Array[i] == 0xfe) { + if (Rtl8192UsbRadioC_Array[i] == 0xfe) { mdelay(100); continue; } rtl8192_phy_SetRFReg(dev, eRFPath, - rtl819XRadioC_Array[i], + Rtl8192UsbRadioC_Array[i], bMask12Bits, - rtl819XRadioC_Array[i+1]); + Rtl8192UsbRadioC_Array[i+1]); mdelay(1); } diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index d708796d7cec..44af37f19f45 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,7 +25,6 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -extern u32 rtl819XRadioC_Array[]; extern u32 rtl819XRadioD_Array[]; enum HW90_BLOCK_E { From a99d02401f2493fb0ddaa34b94e30e9437d2726f Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:22 +0100 Subject: [PATCH 663/903] staging:rtl8192u: Remove proxy rtl819XRadioD_Array - Style Remove the array rtl819XRadioD_Array which is only acting as a proxy to the real array Rtl8192UsbRadioD_Array. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 7 +++---- drivers/staging/rtl8192u/r819xU_phy.h | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 3ed48d6095d7..983520b3aa25 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -29,7 +29,6 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { }; #define rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array -#define rtl819XRadioD_Array Rtl8192UsbRadioD_Array /****************************************************************************** * function: This function checks different RF type to execute legal judgement. @@ -1023,14 +1022,14 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, case RF90_PATH_D: for (i = 0; i < RadioD_ArrayLength; i = i+2) { - if (rtl819XRadioD_Array[i] == 0xfe) { + if (Rtl8192UsbRadioD_Array[i] == 0xfe) { mdelay(100); continue; } rtl8192_phy_SetRFReg(dev, eRFPath, - rtl819XRadioD_Array[i], + Rtl8192UsbRadioD_Array[i], bMask12Bits, - rtl819XRadioD_Array[i+1]); + Rtl8192UsbRadioD_Array[i+1]); mdelay(1); } diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 44af37f19f45..2cd1c25164a2 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,8 +25,6 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -extern u32 rtl819XRadioD_Array[]; - enum HW90_BLOCK_E { HW90_BLOCK_MAC = 0, HW90_BLOCK_PHY0 = 1, From b714c8c0b0558406950fb936a47c8868a917c164 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:23 +0100 Subject: [PATCH 664/903] staging:rtl8192u: Rename HW90_BLOCK_E - Style Rename the enumerated type HW90_BLOCK_E to hw90_block_e. Whilst this is not flagged by checkpatch types are meant to be in lowercase. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 8 ++++---- drivers/staging/rtl8192u/r819xU_phy.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 983520b3aa25..c8c54484eab5 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -687,14 +687,14 @@ static void rtl8192_InitBBRFRegDef(struct net_device *dev) * function: This function is to write register and then readback to make * sure whether BB and RF is OK * input: net_device *dev - * HW90_BLOCK_E CheckBlock + * hw90_block_e CheckBlock * RF90_RADIO_PATH_E eRFPath //only used when checkblock is * //HW90_BLOCK_RF * output: none * return: return whether BB and RF is ok (0:OK, 1:Fail) * notice: This function may be removed in the ASIC ******************************************************************************/ -u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum HW90_BLOCK_E CheckBlock, +u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum hw90_block_e CheckBlock, enum RF90_RADIO_PATH_E eRFPath) { u8 ret = 0; @@ -786,10 +786,10 @@ static void rtl8192_BB_Config_ParaFile(struct net_device *dev) /* ----Ckeck FPGAPHY0 and PHY1 board is OK---- */ /* TODO: this function should be removed on ASIC */ - for (eCheckItem = (enum HW90_BLOCK_E)HW90_BLOCK_PHY0; + for (eCheckItem = (enum hw90_block_e)HW90_BLOCK_PHY0; eCheckItem <= HW90_BLOCK_PHY1; eCheckItem++) { /* don't care RF path */ - status = rtl8192_phy_checkBBAndRF(dev, (enum HW90_BLOCK_E)eCheckItem, + status = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block_e)eCheckItem, (enum RF90_RADIO_PATH_E)0); if (status != 0) { RT_TRACE((COMP_ERR | COMP_PHY), diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 2cd1c25164a2..d9503996457d 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -25,7 +25,7 @@ struct sw_chnl_cmd { u32 ms_delay; } __packed; -enum HW90_BLOCK_E { +enum hw90_block_e { HW90_BLOCK_MAC = 0, HW90_BLOCK_PHY0 = 1, HW90_BLOCK_PHY1 = 2, @@ -62,7 +62,7 @@ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, void rtl8192_phy_configmac(struct net_device *dev); void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, - enum HW90_BLOCK_E CheckBlock, + enum hw90_block_e CheckBlock, enum RF90_RADIO_PATH_E eRFPath); void rtl8192_BBConfig(struct net_device *dev); void rtl8192_phy_getTxPower(struct net_device *dev); From fb37edcfcba7088d07a0ebb79f2991cd190d0a99 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:24 +0100 Subject: [PATCH 665/903] staging:rtl8192u: Rename RF90_RADIO_PATH_E - Style Rename the enumerated type RF90_RADIO_PATH_E to rf90_radio_path_e. Whilst it is not flagged as an issue by checkpatch, types are meant to be named in lowercase. This change is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8190_rtl8256.c | 42 ++++++++++++------------ drivers/staging/rtl8192u/r8192U_core.c | 4 +-- drivers/staging/rtl8192u/r819xU_phy.c | 38 ++++++++++----------- drivers/staging/rtl8192u/r819xU_phy.h | 10 +++--- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c index 9f35dcb9e13e..9b7f822e9762 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.c +++ b/drivers/staging/rtl8192u/r8190_rtl8256.c @@ -41,16 +41,16 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, enum ht_channel_width Bandwi || priv->card_8192_version == VERSION_819xU_B) { /* 8256 D-cut, E-cut, xiong: consider it later! */ rtl8192_phy_SetRFReg(dev, - (enum RF90_RADIO_PATH_E)eRFPath, + (enum rf90_radio_path_e)eRFPath, 0x0b, bMask12Bits, 0x100); /* phy para:1ba */ rtl8192_phy_SetRFReg(dev, - (enum RF90_RADIO_PATH_E)eRFPath, + (enum rf90_radio_path_e)eRFPath, 0x2c, bMask12Bits, 0x3d7); rtl8192_phy_SetRFReg(dev, - (enum RF90_RADIO_PATH_E)eRFPath, + (enum rf90_radio_path_e)eRFPath, 0x0e, bMask12Bits, 0x021); rtl8192_phy_SetRFReg(dev, - (enum RF90_RADIO_PATH_E)eRFPath, + (enum rf90_radio_path_e)eRFPath, 0x14, bMask12Bits, 0x5ab); } else { RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); @@ -58,15 +58,15 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, enum ht_channel_width Bandwi break; case HT_CHANNEL_WIDTH_20_40: if (priv->card_8192_version == VERSION_819xU_A || priv->card_8192_version == VERSION_819xU_B) { /* 8256 D-cut, E-cut, xiong: consider it later! */ - rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x0b, bMask12Bits, 0x300); /* phy para:3ba */ - rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x2c, bMask12Bits, 0x3df); - rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x0e, bMask12Bits, 0x0a1); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)eRFPath, 0x0b, bMask12Bits, 0x300); /* phy para:3ba */ + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)eRFPath, 0x2c, bMask12Bits, 0x3df); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)eRFPath, 0x0e, bMask12Bits, 0x0a1); if (priv->chan == 3 || priv->chan == 9) /* I need to set priv->chan whenever current channel changes */ - rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x59b); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)eRFPath, 0x14, bMask12Bits, 0x59b); else - rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, 0x14, bMask12Bits, 0x5ab); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)eRFPath, 0x14, bMask12Bits, 0x5ab); } else { RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); } @@ -115,14 +115,14 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; /* Initialize RF */ - for (eRFPath = (enum RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath < priv->NumTotalRFPath; eRFPath++) { + for (eRFPath = (enum rf90_radio_path_e)RF90_PATH_A; eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; pPhyReg = &priv->PHYRegDef[eRFPath]; /* Joseph test for shorten RF config - * pHalData->RfReg0Value[eRFPath] = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, rGlobalCtrl, bMaskDWord); + * pHalData->RfReg0Value[eRFPath] = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path_e)eRFPath, rGlobalCtrl, bMaskDWord); * ----Store original RFENV control type */ switch (eRFPath) { @@ -146,12 +146,12 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258 */ rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for Z-serial and 8258, and set 1 to 14 bits for ??? */ - rtl8192_phy_SetRFReg(dev, (enum RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e) eRFPath, 0x0, bMask12Bits, 0xbf); /* Check RF block (for FPGA platform only)---- * TODO: this function should be removed on ASIC , Emily 2007.2.2 */ - if (rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum RF90_RADIO_PATH_E)eRFPath)) { + if (rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum rf90_radio_path_e)eRFPath)) { RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -162,32 +162,32 @@ void phy_RF8256_Config_ParaFile(struct net_device *dev) switch (eRFPath) { case RF90_PATH_A: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum rf90_radio_path_e)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path_e)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_B: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum rf90_radio_path_e)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path_e)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_C: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum rf90_radio_path_e)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path_e)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_D: while (RF3_Final_Value != RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum RF90_RADIO_PATH_E)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum RF90_RADIO_PATH_E)eRFPath, RegOffSetToBeCheck, bMask12Bits); + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, (enum rf90_radio_path_e)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path_e)eRFPath, RegOffSetToBeCheck, bMask12Bits); RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index c99923d467a7..28592a8d6dd0 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2897,7 +2897,7 @@ static bool rtl8192_adapter_start(struct net_device *dev) */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) PHY_SetRFReg(Adapter, - (enum RF90_RADIO_PATH_E)eRFPath, + (enum rf90_radio_path_e)eRFPath, 0x4, 0xC00, 0x0); } else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) { /* H/W or S/W RF OFF before sleep. */ @@ -2923,7 +2923,7 @@ static bool rtl8192_adapter_start(struct net_device *dev) */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) PHY_SetRFReg(Adapter, - (enum RF90_RADIO_PATH_E)eRFPath, + (enum rf90_radio_path_e)eRFPath, 0x4, 0xC00, 0x0); } } diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index c8c54484eab5..fb74b749fbcf 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -101,18 +101,18 @@ u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask) } static u32 phy_FwRFSerialRead(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 offset); static void phy_FwRFSerialWrite(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 offset, u32 data); /****************************************************************************** * function: This function reads register from RF chip * input: net_device *dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D + * rf90_radio_path_e eRFPath //radio path of A/B/C/D * u32 offset //target address to be read * output: none * return: u32 readback value @@ -124,7 +124,7 @@ static void phy_FwRFSerialWrite(struct net_device *dev, * ---need more spec for this information. ******************************************************************************/ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, u32 offset) + enum rf90_radio_path_e eRFPath, u32 offset) { struct r8192_priv *priv = ieee80211_priv(dev); u32 ret = 0; @@ -191,7 +191,7 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, /****************************************************************************** * function: This function writes data to RF register * input: net_device *dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D + * rf90_radio_path_e eRFPath //radio path of A/B/C/D * u32 offset //target address to be written * u32 data //the new register data to be written * output: none @@ -209,7 +209,7 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, * --------------------------------------------------------------------------- *****************************************************************************/ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 offset, u32 data) { @@ -266,7 +266,7 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, /****************************************************************************** * function: This function set specific bits to RF register * input: net_device dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D + * rf90_radio_path_e eRFPath //radio path of A/B/C/D * u32 reg_addr //target addr to be modified * u32 bitmask //taget bit pos to be modified * u32 data //value to be written @@ -275,7 +275,7 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, * notice: *****************************************************************************/ void rtl8192_phy_SetRFReg(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 reg_addr, u32 bitmask, u32 data) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -324,7 +324,7 @@ void rtl8192_phy_SetRFReg(struct net_device *dev, * notice: *****************************************************************************/ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 reg_addr, u32 bitmask) { u32 reg, bitshift; @@ -348,14 +348,14 @@ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, /****************************************************************************** * function: We support firmware to execute RF-R/W. * input: net_device *dev - * RF90_RADIO_PATH_E eRFPath + * rf90_radio_path_e eRFPath * u32 offset * output: none * return: u32 * notice: ****************************************************************************/ static u32 phy_FwRFSerialRead(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 offset) { u32 reg = 0; @@ -412,7 +412,7 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, /****************************************************************************** * function: We support firmware to execute RF-R/W. * input: net_device *dev - * RF90_RADIO_PATH_E eRFPath + * rf90_radio_path_e eRFPath * u32 offset * u32 data * output: none @@ -420,7 +420,7 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, * notice: ****************************************************************************/ static void phy_FwRFSerialWrite(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 offset, u32 data) { u8 time = 0; @@ -688,14 +688,14 @@ static void rtl8192_InitBBRFRegDef(struct net_device *dev) * sure whether BB and RF is OK * input: net_device *dev * hw90_block_e CheckBlock - * RF90_RADIO_PATH_E eRFPath //only used when checkblock is + * rf90_radio_path_e eRFPath //only used when checkblock is * //HW90_BLOCK_RF * output: none * return: return whether BB and RF is ok (0:OK, 1:Fail) * notice: This function may be removed in the ASIC ******************************************************************************/ u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum hw90_block_e CheckBlock, - enum RF90_RADIO_PATH_E eRFPath) + enum rf90_radio_path_e eRFPath) { u8 ret = 0; u32 i, CheckTimes = 4, reg = 0; @@ -790,7 +790,7 @@ static void rtl8192_BB_Config_ParaFile(struct net_device *dev) eCheckItem <= HW90_BLOCK_PHY1; eCheckItem++) { /* don't care RF path */ status = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block_e)eCheckItem, - (enum RF90_RADIO_PATH_E)0); + (enum rf90_radio_path_e)0); if (status != 0) { RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config(): Check PHY%d Fail!!\n", @@ -962,13 +962,13 @@ void rtl8192_phy_updateInitGain(struct net_device *dev) * function: This function read RF parameters from general head file, * and do RF 3-wire * input: net_device *dev - * RF90_RADIO_PATH_E eRFPath + * rf90_radio_path_e eRFPath * output: none * return: return code show if RF configuration is successful(0:pass, 1:fail) * notice: Delay may be required for RF configuration *****************************************************************************/ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath) + enum rf90_radio_path_e eRFPath) { int i; @@ -1386,7 +1386,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, case CMD_ID_RF_WRITE_REG: for (eRFPath = 0; eRFPath < RF90_PATH_MAX; eRFPath++) { rtl8192_phy_SetRFReg(dev, - (enum RF90_RADIO_PATH_E)eRFPath, + (enum rf90_radio_path_e)eRFPath, CurrentCmd->para_1, bZebra1_ChannelNum, CurrentCmd->para_2); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index d9503996457d..1ad459cf05ae 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -33,7 +33,7 @@ enum hw90_block_e { HW90_BLOCK_MAXIMUM = 4, /* Never use this */ }; -enum RF90_RADIO_PATH_E { +enum rf90_radio_path_e { RF90_PATH_A = 0, /* Radio Path A */ RF90_PATH_B = 1, /* Radio Path B */ RF90_PATH_C = 2, /* Radio Path C */ @@ -54,23 +54,23 @@ void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr, u32 bitmask, u32 data); u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask); void rtl8192_phy_SetRFReg(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 reg_addr, u32 bitmask, u32 data); u32 rtl8192_phy_QueryRFReg(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath, + enum rf90_radio_path_e eRFPath, u32 reg_addr, u32 bitmask); void rtl8192_phy_configmac(struct net_device *dev); void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum hw90_block_e CheckBlock, - enum RF90_RADIO_PATH_E eRFPath); + enum rf90_radio_path_e eRFPath); void rtl8192_BBConfig(struct net_device *dev); void rtl8192_phy_getTxPower(struct net_device *dev); void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); void rtl8192_phy_RFConfig(struct net_device *dev); void rtl8192_phy_updateInitGain(struct net_device *dev); u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, - enum RF90_RADIO_PATH_E eRFPath); + enum rf90_radio_path_e eRFPath); u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); void rtl8192_SetBWMode(struct net_device *dev, From 14c964a2d3707891bd20b1883fd339f41bba4068 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:25 +0100 Subject: [PATCH 666/903] staging:rtl8192u: Remove repeated definitions - Style Remove bit field masks which are defined in two files: r819xU_phy.h and r819xU_phyreg.h. Or in the case of bMaskByte3 defined but never used. The definitions have been removed from the file r819xU_phy.h. This is a coding style change, which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 1ad459cf05ae..8ca869e8ee2f 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -41,14 +41,6 @@ enum rf90_radio_path_e { RF90_PATH_MAX /* Max RF number 92 support */ }; -#define bMaskByte0 0xff -#define bMaskByte1 0xff00 -#define bMaskByte2 0xff0000 -#define bMaskByte3 0xff000000 -#define bMaskHWord 0xffff0000 -#define bMaskLWord 0x0000ffff -#define bMaskDWord 0xffffffff - u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath); void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr, u32 bitmask, u32 data); From cc29db86378e131d13859529b7285ae92ae3143f Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Thu, 26 Jul 2018 20:24:26 +0100 Subject: [PATCH 667/903] staging:rtl8192u: Rename eRFPath - Style Rename the variable eRFPath to e_rfpath. This change resolves a checkpatch issue with CamelCase naming. The variable name is used both as a parameter name in function definitions, function prototypes and as a local variable. This change is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 120 +++++++++++++------------- drivers/staging/rtl8192u/r819xU_phy.h | 10 +-- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index fb74b749fbcf..7ee10d49894b 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -34,11 +34,11 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { * function: This function checks different RF type to execute legal judgement. * If RF Path is illegal, we will return false. * input: net_device *dev - * u32 eRFPath + * u32 e_rfpath * output: none * return: 0(illegal, false), 1(legal, true) *****************************************************************************/ -u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath) +u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 e_rfpath) { u8 ret = 1; struct r8192_priv *priv = ieee80211_priv(dev); @@ -46,9 +46,9 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath) if (priv->rf_type == RF_2T4R) { ret = 0; } else if (priv->rf_type == RF_1T2R) { - if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) + if (e_rfpath == RF90_PATH_A || e_rfpath == RF90_PATH_B) ret = 1; - else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) + else if (e_rfpath == RF90_PATH_C || e_rfpath == RF90_PATH_D) ret = 0; } return ret; @@ -101,18 +101,18 @@ u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask) } static u32 phy_FwRFSerialRead(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 offset); static void phy_FwRFSerialWrite(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 offset, u32 data); /****************************************************************************** * function: This function reads register from RF chip * input: net_device *dev - * rf90_radio_path_e eRFPath //radio path of A/B/C/D + * rf90_radio_path_e e_rfpath //radio path of A/B/C/D * u32 offset //target address to be read * output: none * return: u32 readback value @@ -124,12 +124,12 @@ static void phy_FwRFSerialWrite(struct net_device *dev, * ---need more spec for this information. ******************************************************************************/ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, - enum rf90_radio_path_e eRFPath, u32 offset) + enum rf90_radio_path_e e_rfpath, u32 offset) { struct r8192_priv *priv = ieee80211_priv(dev); u32 ret = 0; u32 new_offset = 0; - BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath]; + BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[e_rfpath]; rtl8192_setBBreg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData, 0); /* Make sure RF register offset is correct */ @@ -138,20 +138,20 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, /* Switch page for 8256 RF IC */ if (priv->rf_chip == RF_8256) { if (offset >= 31) { - priv->RfReg0Value[eRFPath] |= 0x140; + priv->RfReg0Value[e_rfpath] |= 0x140; /* Switch to Reg_Mode2 for Reg 31-45 */ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - priv->RfReg0Value[eRFPath]<<16); + priv->RfReg0Value[e_rfpath]<<16); /* Modify offset */ new_offset = offset - 30; } else if (offset >= 16) { - priv->RfReg0Value[eRFPath] |= 0x100; - priv->RfReg0Value[eRFPath] &= (~0x40); + priv->RfReg0Value[e_rfpath] |= 0x100; + priv->RfReg0Value[e_rfpath] &= (~0x40); /* Switch to Reg_Mode1 for Reg16-30 */ rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - priv->RfReg0Value[eRFPath]<<16); + priv->RfReg0Value[e_rfpath]<<16); new_offset = offset - 15; } else { @@ -179,10 +179,10 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, /* Switch back to Reg_Mode0 */ if (priv->rf_chip == RF_8256) { - priv->RfReg0Value[eRFPath] &= 0xebf; + priv->RfReg0Value[e_rfpath] &= 0xebf; rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - priv->RfReg0Value[eRFPath] << 16); + priv->RfReg0Value[e_rfpath] << 16); } return ret; @@ -191,7 +191,7 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, /****************************************************************************** * function: This function writes data to RF register * input: net_device *dev - * rf90_radio_path_e eRFPath //radio path of A/B/C/D + * rf90_radio_path_e e_rfpath //radio path of A/B/C/D * u32 offset //target address to be written * u32 data //the new register data to be written * output: none @@ -209,29 +209,29 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, * --------------------------------------------------------------------------- *****************************************************************************/ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 offset, u32 data) { struct r8192_priv *priv = ieee80211_priv(dev); u32 DataAndAddr = 0, new_offset = 0; - BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[eRFPath]; + BB_REGISTER_DEFINITION_T *pPhyReg = &priv->PHYRegDef[e_rfpath]; offset &= 0x3f; if (priv->rf_chip == RF_8256) { if (offset >= 31) { - priv->RfReg0Value[eRFPath] |= 0x140; + priv->RfReg0Value[e_rfpath] |= 0x140; rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - priv->RfReg0Value[eRFPath] << 16); + priv->RfReg0Value[e_rfpath] << 16); new_offset = offset - 30; } else if (offset >= 16) { - priv->RfReg0Value[eRFPath] |= 0x100; - priv->RfReg0Value[eRFPath] &= (~0x40); + priv->RfReg0Value[e_rfpath] |= 0x100; + priv->RfReg0Value[e_rfpath] &= (~0x40); rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - priv->RfReg0Value[eRFPath]<<16); + priv->RfReg0Value[e_rfpath]<<16); new_offset = offset - 15; } else { new_offset = offset; @@ -250,15 +250,15 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, if (offset == 0x0) - priv->RfReg0Value[eRFPath] = data; + priv->RfReg0Value[e_rfpath] = data; /* Switch back to Reg_Mode0 */ if (priv->rf_chip == RF_8256) { if (offset != 0) { - priv->RfReg0Value[eRFPath] &= 0xebf; + priv->RfReg0Value[e_rfpath] &= 0xebf; rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - priv->RfReg0Value[eRFPath] << 16); + priv->RfReg0Value[e_rfpath] << 16); } } } @@ -266,7 +266,7 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, /****************************************************************************** * function: This function set specific bits to RF register * input: net_device dev - * rf90_radio_path_e eRFPath //radio path of A/B/C/D + * rf90_radio_path_e e_rfpath //radio path of A/B/C/D * u32 reg_addr //target addr to be modified * u32 bitmask //taget bit pos to be modified * u32 data //value to be written @@ -275,26 +275,26 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev, * notice: *****************************************************************************/ void rtl8192_phy_SetRFReg(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 reg_addr, u32 bitmask, u32 data) { struct r8192_priv *priv = ieee80211_priv(dev); u32 reg, bitshift; - if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) + if (!rtl8192_phy_CheckIsLegalRFPath(dev, e_rfpath)) return; if (priv->Rf_Mode == RF_OP_By_FW) { if (bitmask != bMask12Bits) { /* RF data is 12 bits only */ - reg = phy_FwRFSerialRead(dev, eRFPath, reg_addr); + reg = phy_FwRFSerialRead(dev, e_rfpath, reg_addr); bitshift = ffs(bitmask) - 1; reg &= ~bitmask; reg |= data << bitshift; - phy_FwRFSerialWrite(dev, eRFPath, reg_addr, reg); + phy_FwRFSerialWrite(dev, e_rfpath, reg_addr, reg); } else { - phy_FwRFSerialWrite(dev, eRFPath, reg_addr, data); + phy_FwRFSerialWrite(dev, e_rfpath, reg_addr, data); } udelay(200); @@ -302,14 +302,14 @@ void rtl8192_phy_SetRFReg(struct net_device *dev, } else { if (bitmask != bMask12Bits) { /* RF data is 12 bits only */ - reg = rtl8192_phy_RFSerialRead(dev, eRFPath, reg_addr); + reg = rtl8192_phy_RFSerialRead(dev, e_rfpath, reg_addr); bitshift = ffs(bitmask) - 1; reg &= ~bitmask; reg |= data << bitshift; - rtl8192_phy_RFSerialWrite(dev, eRFPath, reg_addr, reg); + rtl8192_phy_RFSerialWrite(dev, e_rfpath, reg_addr, reg); } else { - rtl8192_phy_RFSerialWrite(dev, eRFPath, reg_addr, data); + rtl8192_phy_RFSerialWrite(dev, e_rfpath, reg_addr, data); } } } @@ -324,20 +324,20 @@ void rtl8192_phy_SetRFReg(struct net_device *dev, * notice: *****************************************************************************/ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 reg_addr, u32 bitmask) { u32 reg, bitshift; struct r8192_priv *priv = ieee80211_priv(dev); - if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) + if (!rtl8192_phy_CheckIsLegalRFPath(dev, e_rfpath)) return 0; if (priv->Rf_Mode == RF_OP_By_FW) { - reg = phy_FwRFSerialRead(dev, eRFPath, reg_addr); + reg = phy_FwRFSerialRead(dev, e_rfpath, reg_addr); udelay(200); } else { - reg = rtl8192_phy_RFSerialRead(dev, eRFPath, reg_addr); + reg = rtl8192_phy_RFSerialRead(dev, e_rfpath, reg_addr); } bitshift = ffs(bitmask) - 1; reg = (reg & bitmask) >> bitshift; @@ -348,14 +348,14 @@ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, /****************************************************************************** * function: We support firmware to execute RF-R/W. * input: net_device *dev - * rf90_radio_path_e eRFPath + * rf90_radio_path_e e_rfpath * u32 offset * output: none * return: u32 * notice: ****************************************************************************/ static u32 phy_FwRFSerialRead(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 offset) { u32 reg = 0; @@ -372,7 +372,7 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, /* 2. Write RF register address. bit 12-19 */ data |= ((offset&0xFF)<<12); /* 3. Write RF path. bit 20-21 */ - data |= ((eRFPath&0x3)<<20); + data |= ((e_rfpath&0x3)<<20); /* 4. Set RF read indicator. bit 22=0 */ /* 5. Trigger Fw to operate the command. bit 31 */ data |= 0x80000000; @@ -412,7 +412,7 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, /****************************************************************************** * function: We support firmware to execute RF-R/W. * input: net_device *dev - * rf90_radio_path_e eRFPath + * rf90_radio_path_e e_rfpath * u32 offset * u32 data * output: none @@ -420,7 +420,7 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, * notice: ****************************************************************************/ static void phy_FwRFSerialWrite(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 offset, u32 data) { u8 time = 0; @@ -436,7 +436,7 @@ static void phy_FwRFSerialWrite(struct net_device *dev, /* 2. Write RF register address. bit 12-19 */ data |= ((offset&0xFF)<<12); /* 3. Write RF path. bit 20-21 */ - data |= ((eRFPath&0x3)<<20); + data |= ((e_rfpath&0x3)<<20); /* 4. Set RF write indicator. bit 22=1 */ data |= 0x400000; /* 5. Trigger Fw to operate the command. bit 31=1 */ @@ -688,14 +688,14 @@ static void rtl8192_InitBBRFRegDef(struct net_device *dev) * sure whether BB and RF is OK * input: net_device *dev * hw90_block_e CheckBlock - * rf90_radio_path_e eRFPath //only used when checkblock is + * rf90_radio_path_e e_rfpath //only used when checkblock is * //HW90_BLOCK_RF * output: none * return: return whether BB and RF is ok (0:OK, 1:Fail) * notice: This function may be removed in the ASIC ******************************************************************************/ u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum hw90_block_e CheckBlock, - enum rf90_radio_path_e eRFPath) + enum rf90_radio_path_e e_rfpath) { u8 ret = 0; u32 i, CheckTimes = 4, reg = 0; @@ -726,14 +726,14 @@ u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum hw90_block_e CheckBlock case HW90_BLOCK_RF: WriteData[i] &= 0xfff; - rtl8192_phy_SetRFReg(dev, eRFPath, + rtl8192_phy_SetRFReg(dev, e_rfpath, WriteAddr[HW90_BLOCK_RF], bMask12Bits, WriteData[i]); /* TODO: we should not delay for such a long time. * Ask SD3 */ usleep_range(1000, 1000); - reg = rtl8192_phy_QueryRFReg(dev, eRFPath, + reg = rtl8192_phy_QueryRFReg(dev, e_rfpath, WriteAddr[HW90_BLOCK_RF], bMask12Bits); usleep_range(1000, 1000); @@ -962,18 +962,18 @@ void rtl8192_phy_updateInitGain(struct net_device *dev) * function: This function read RF parameters from general head file, * and do RF 3-wire * input: net_device *dev - * rf90_radio_path_e eRFPath + * rf90_radio_path_e e_rfpath * output: none * return: return code show if RF configuration is successful(0:pass, 1:fail) * notice: Delay may be required for RF configuration *****************************************************************************/ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, - enum rf90_radio_path_e eRFPath) + enum rf90_radio_path_e e_rfpath) { int i; - switch (eRFPath) { + switch (e_rfpath) { case RF90_PATH_A: for (i = 0; i < RadioA_ArrayLength; i = i+2) { @@ -981,7 +981,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, mdelay(100); continue; } - rtl8192_phy_SetRFReg(dev, eRFPath, + rtl8192_phy_SetRFReg(dev, e_rfpath, Rtl8192UsbRadioA_Array[i], bMask12Bits, Rtl8192UsbRadioA_Array[i+1]); @@ -996,7 +996,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, mdelay(100); continue; } - rtl8192_phy_SetRFReg(dev, eRFPath, + rtl8192_phy_SetRFReg(dev, e_rfpath, Rtl8192UsbRadioB_Array[i], bMask12Bits, Rtl8192UsbRadioB_Array[i+1]); @@ -1011,7 +1011,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, mdelay(100); continue; } - rtl8192_phy_SetRFReg(dev, eRFPath, + rtl8192_phy_SetRFReg(dev, e_rfpath, Rtl8192UsbRadioC_Array[i], bMask12Bits, Rtl8192UsbRadioC_Array[i+1]); @@ -1026,7 +1026,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, mdelay(100); continue; } - rtl8192_phy_SetRFReg(dev, eRFPath, + rtl8192_phy_SetRFReg(dev, e_rfpath, Rtl8192UsbRadioD_Array[i], bMask12Bits, Rtl8192UsbRadioD_Array[i+1]); @@ -1267,7 +1267,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; u32 RfDependCmdCnt; struct sw_chnl_cmd *CurrentCmd = NULL; - u8 eRFPath; + u8 e_rfpath; RT_TRACE(COMP_CH, "%s() stage: %d, step: %d, channel: %d\n", __func__, *stage, *step, channel); @@ -1384,9 +1384,9 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, (u8)CurrentCmd->para_2); break; case CMD_ID_RF_WRITE_REG: - for (eRFPath = 0; eRFPath < RF90_PATH_MAX; eRFPath++) { + for (e_rfpath = 0; e_rfpath < RF90_PATH_MAX; e_rfpath++) { rtl8192_phy_SetRFReg(dev, - (enum rf90_radio_path_e)eRFPath, + (enum rf90_radio_path_e)e_rfpath, CurrentCmd->para_1, bZebra1_ChannelNum, CurrentCmd->para_2); diff --git a/drivers/staging/rtl8192u/r819xU_phy.h b/drivers/staging/rtl8192u/r819xU_phy.h index 8ca869e8ee2f..c7ec3182857f 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.h +++ b/drivers/staging/rtl8192u/r819xU_phy.h @@ -41,28 +41,28 @@ enum rf90_radio_path_e { RF90_PATH_MAX /* Max RF number 92 support */ }; -u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath); +u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 e_rfpath); void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr, u32 bitmask, u32 data); u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask); void rtl8192_phy_SetRFReg(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 reg_addr, u32 bitmask, u32 data); u32 rtl8192_phy_QueryRFReg(struct net_device *dev, - enum rf90_radio_path_e eRFPath, + enum rf90_radio_path_e e_rfpath, u32 reg_addr, u32 bitmask); void rtl8192_phy_configmac(struct net_device *dev); void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, enum hw90_block_e CheckBlock, - enum rf90_radio_path_e eRFPath); + enum rf90_radio_path_e e_rfpath); void rtl8192_BBConfig(struct net_device *dev); void rtl8192_phy_getTxPower(struct net_device *dev); void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); void rtl8192_phy_RFConfig(struct net_device *dev); void rtl8192_phy_updateInitGain(struct net_device *dev); u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, - enum rf90_radio_path_e eRFPath); + enum rf90_radio_path_e e_rfpath); u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); void rtl8192_SetBWMode(struct net_device *dev, From 1538be280259fb03ecda3a69cf308116d61698d6 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:04 +0100 Subject: [PATCH 668/903] staging:rtl8192u: Remove typedef and rename TX_TS_RECORD - Style Remove the typdef from structure TX_TS_RECORD and rename to tx_ts_record. The removal of the typedef clears the checkpatch issue with creating new types in code. The name change, whilst not specifically flagged by checkpatch, is an issue since types are meant to be named in lowercase. These changes are purely coding style changes and should have no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211.h | 6 +++--- .../staging/rtl8192u/ieee80211/ieee80211_tx.c | 4 ++-- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 20 +++++++++---------- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 4 ++-- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 16 +++++++-------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index bb4bb68bb3dd..aecb697f3729 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1646,7 +1646,7 @@ struct ieee80211_device { struct list_head Tx_TS_Admit_List; struct list_head Tx_TS_Pending_List; struct list_head Tx_TS_Unused_List; - TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM]; + struct tx_ts_record TxTsRecord[TOTAL_TS_NUM]; // 802.11e and WMM Traffic Stream Info (RX) struct list_head Rx_TS_Admit_List; struct list_head Rx_TS_Pending_List; @@ -2388,7 +2388,7 @@ u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate); int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb); int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb); int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb); -void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS, +void TsInitAddBA(struct ieee80211_device *ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending); void TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect); @@ -2406,7 +2406,7 @@ bool GetTs( bool bAddNewTs ); void TSInitialize(struct ieee80211_device *ieee); -void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS); +void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTxTS); void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr); void RemoveAllTS(struct ieee80211_device *ieee); void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 010b53b45825..142b86b393dc 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -306,7 +306,7 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, struct sk_buff *skb, struct cb_desc *tcb_desc) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - PTX_TS_RECORD pTxTs = NULL; + struct tx_ts_record *pTxTs = NULL; struct rtl_80211_hdr_1addr *hdr = (struct rtl_80211_hdr_1addr *)skb->data; if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) @@ -584,7 +584,7 @@ static void ieee80211_query_seqnum(struct ieee80211_device *ieee, return; if (IsQoSDataFrame(skb->data)) //we deal qos data only { - PTX_TS_RECORD pTS = NULL; + struct tx_ts_record *pTS = NULL; if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, skb->priority, TX_DIR, true)) { return; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 2c7d3ab1b5f7..507014d44d54 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -36,11 +36,11 @@ static void DeActivateBAEntry(struct ieee80211_device *ieee, PBA_RECORD pBA) /******************************************************************************************************************** *function: deactivete BA entry in Tx Ts, and send DELBA. * input: - * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry. + * struct tx_ts_record *pTxTs //Tx Ts which is to deactivate BA entry. * output: none - * notice: As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME + * notice: As struct tx_ts_record * structure will be defined in QOS, so wait to be merged. //FIXME ********************************************************************************************************************/ -static u8 TxTsDeleteBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTs) +static u8 TxTsDeleteBA(struct ieee80211_device *ieee, struct tx_ts_record *pTxTs) { PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord; @@ -420,7 +420,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) { struct rtl_80211_hdr_3addr *rsp = NULL; PBA_RECORD pPendingBA, pAdmittedBA; - PTX_TS_RECORD pTS = NULL; + struct tx_ts_record *pTS = NULL; u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; u16 *pStatusCode = NULL, *pBaTimeoutVal = NULL; PBA_PARAM_SET pBaParamSet = NULL; @@ -581,7 +581,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) RxTsDeleteBA(ieee, pRxTs); } else { - PTX_TS_RECORD pTxTs; + struct tx_ts_record *pTxTs; if (!GetTs( ieee, @@ -610,7 +610,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) void TsInitAddBA( struct ieee80211_device *ieee, - PTX_TS_RECORD pTS, + struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending ) @@ -641,7 +641,7 @@ void TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect) { if (TxRxSelect == TX_DIR) { - PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo; + struct tx_ts_record *pTxTs = (struct tx_ts_record *)pTsCommonInfo; if (TxTsDeleteBA(ieee, pTxTs)) ieee80211_send_DELBA( @@ -663,13 +663,13 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, } /******************************************************************************************************************** *function: BA setup timer - * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer + * input: unsigned long data //acturally we send struct tx_ts_record or RX_TS_RECORD to these timer * return: NULL * notice: ********************************************************************************************************************/ void BaSetupTimeOut(struct timer_list *t) { - PTX_TS_RECORD pTxTs = from_timer(pTxTs, t, TxPendingBARecord.Timer); + struct tx_ts_record *pTxTs = from_timer(pTxTs, t, TxPendingBARecord.Timer); pTxTs->bAddBaReqInProgress = false; pTxTs->bAddBaReqDelayed = true; @@ -678,7 +678,7 @@ void BaSetupTimeOut(struct timer_list *t) void TxBaInactTimeout(struct timer_list *t) { - PTX_TS_RECORD pTxTs = from_timer(pTxTs, t, TxAdmittedBARecord.Timer); + struct tx_ts_record *pTxTs = from_timer(pTxTs, t, TxAdmittedBARecord.Timer); struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]); TxTsDeleteBA(ieee, pTxTs); ieee80211_send_DELBA( diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 3da1ef6ef105..0f744b112dcf 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -26,7 +26,7 @@ struct ts_common_info { u8 t_clas_num; }; -typedef struct _TX_TS_RECORD { +struct tx_ts_record { struct ts_common_info TsCommonInfo; u16 TxCurSeq; BA_RECORD TxPendingBARecord; /* For BA Originator */ @@ -37,7 +37,7 @@ typedef struct _TX_TS_RECORD { u8 bUsingBa; struct timer_list TsAddBaTimer; u8 num; -} TX_TS_RECORD, *PTX_TS_RECORD; +}; typedef struct _RX_TS_RECORD { struct ts_common_info TsCommonInfo; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 4b2da7f31166..f2a5771185f0 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -19,7 +19,7 @@ static void TsInactTimeout(struct timer_list *unused) /******************************************************************************************************************** *function: I still not understand this function, so wait for further implementation - * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer + * input: unsigned long data //acturally we send struct tx_ts_record or RX_TS_RECORD to these timer * return: NULL * notice: ********************************************************************************************************************/ @@ -86,13 +86,13 @@ static void RxPktPendingTimeout(struct timer_list *t) /******************************************************************************************************************** *function: Add BA timer function - * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer + * input: unsigned long data //acturally we send struct tx_ts_record or RX_TS_RECORD to these timer * return: NULL * notice: ********************************************************************************************************************/ static void TsAddBaProcess(struct timer_list *t) { - PTX_TS_RECORD pTxTs = from_timer(pTxTs, t, TsAddBaTimer); + struct tx_ts_record *pTxTs = from_timer(pTxTs, t, TsAddBaTimer); u8 num = pTxTs->num; struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]); @@ -110,7 +110,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) pTsCommonInfo->t_clas_num = 0; } -static void ResetTxTsEntry(PTX_TS_RECORD pTS) +static void ResetTxTsEntry(struct tx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->TxCurSeq = 0; @@ -131,7 +131,7 @@ static void ResetRxTsEntry(PRX_TS_RECORD pTS) void TSInitialize(struct ieee80211_device *ieee) { - PTX_TS_RECORD pTxTS = ieee->TxTsRecord; + struct tx_ts_record *pTxTS = ieee->TxTsRecord; PRX_TS_RECORD pRxTS = ieee->RxTsRecord; PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; u8 count = 0; @@ -374,7 +374,7 @@ bool GetTs( (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, list); list_del_init(&(*ppTS)->list); if(TxRxSelect==TX_DIR) { - PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo); + struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, TsCommonInfo); ResetTxTsEntry(tmp); } else { PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo); @@ -447,7 +447,7 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info * //#endif } else { - PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs; + struct tx_ts_record *pTxTS = (struct tx_ts_record *)pTs; del_timer_sync(&pTxTS->TsAddBaTimer); } } @@ -520,7 +520,7 @@ void RemoveAllTS(struct ieee80211_device *ieee) } } -void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS) +void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTxTS) { if(!pTxTS->bAddBaReqInProgress) { pTxTS->bAddBaReqInProgress = true; From c1fdc5de69aa516a4ea25708188724b5208f54a2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:05 +0100 Subject: [PATCH 669/903] staging:rtl8192u: Rename TsCommonInfo - Style Rename the member variable TsCommonInfo in two structures, both tx_ts_record and RX_TS_RECORD. This member variable is used in both structures and in both cases causes a checkpatch issue with CamelCase naming. The changes are purely coding style and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 8 ++++---- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 4 ++-- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 20 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 507014d44d54..686d4e917384 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -626,7 +626,7 @@ TsInitAddBA( pBA->DialogToken++; // DialogToken: Only keep the latest dialog token pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!! pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate - pBA->BaParamSet.field.TID = pTS->TsCommonInfo.t_spec.f.TSInfo.field.ucTSID; // TID + pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.field.ucTSID; // TID // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer @@ -634,7 +634,7 @@ TsInitAddBA( ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT); - ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.addr, pBA); + ieee80211_send_ADDBAReq(ieee, pTS->ts_common_info.addr, pBA); } void @@ -683,7 +683,7 @@ void TxBaInactTimeout(struct timer_list *t) TxTsDeleteBA(ieee, pTxTs); ieee80211_send_DELBA( ieee, - pTxTs->TsCommonInfo.addr, + pTxTs->ts_common_info.addr, &pTxTs->TxAdmittedBARecord, TX_DIR, DELBA_REASON_TIMEOUT); @@ -697,7 +697,7 @@ void RxBaInactTimeout(struct timer_list *t) RxTsDeleteBA(ieee, pRxTs); ieee80211_send_DELBA( ieee, - pRxTs->TsCommonInfo.addr, + pRxTs->ts_common_info.addr, &pRxTs->RxAdmittedBARecord, RX_DIR, DELBA_REASON_TIMEOUT); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 0f744b112dcf..e2c2001dc5ca 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -27,7 +27,7 @@ struct ts_common_info { }; struct tx_ts_record { - struct ts_common_info TsCommonInfo; + struct ts_common_info ts_common_info; u16 TxCurSeq; BA_RECORD TxPendingBARecord; /* For BA Originator */ BA_RECORD TxAdmittedBARecord; /* For BA Originator */ @@ -40,7 +40,7 @@ struct tx_ts_record { }; typedef struct _RX_TS_RECORD { - struct ts_common_info TsCommonInfo; + struct ts_common_info ts_common_info; u16 RxIndicateSeq; u16 RxTimeoutIndicateSeq; struct list_head RxPendingPktList; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index f2a5771185f0..e1ce4e5096bb 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -112,7 +112,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) static void ResetTxTsEntry(struct tx_ts_record *pTS) { - ResetTsCommonInfo(&pTS->TsCommonInfo); + ResetTsCommonInfo(&pTS->ts_common_info); pTS->TxCurSeq = 0; pTS->bAddBaReqInProgress = false; pTS->bAddBaReqDelayed = false; @@ -123,7 +123,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) static void ResetRxTsEntry(PRX_TS_RECORD pTS) { - ResetTsCommonInfo(&pTS->TsCommonInfo); + ResetTsCommonInfo(&pTS->ts_common_info); pTS->RxIndicateSeq = 0xffff; // This indicate the RxIndicateSeq is not used now!! pTS->RxTimeoutIndicateSeq = 0xffff; // This indicate the RxTimeoutIndicateSeq is not used now!! ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recipient @@ -146,9 +146,9 @@ void TSInitialize(struct ieee80211_device *ieee) pTxTS->num = count; // The timers for the operation of Traffic Stream and Block Ack. // DLS related timer will be add here in the future!! - timer_setup(&pTxTS->TsCommonInfo.setup_timer, TsSetupTimeOut, + timer_setup(&pTxTS->ts_common_info.setup_timer, TsSetupTimeOut, 0); - timer_setup(&pTxTS->TsCommonInfo.inact_timer, TsInactTimeout, + timer_setup(&pTxTS->ts_common_info.inact_timer, TsInactTimeout, 0); timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0); timer_setup(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut, @@ -156,7 +156,7 @@ void TSInitialize(struct ieee80211_device *ieee) timer_setup(&pTxTS->TxAdmittedBARecord.Timer, TxBaInactTimeout, 0); ResetTxTsEntry(pTxTS); - list_add_tail(&pTxTS->TsCommonInfo.list, &ieee->Tx_TS_Unused_List); + list_add_tail(&pTxTS->ts_common_info.list, &ieee->Tx_TS_Unused_List); pTxTS++; } @@ -167,15 +167,15 @@ void TSInitialize(struct ieee80211_device *ieee) for(count = 0; count < TOTAL_TS_NUM; count++) { pRxTS->num = count; INIT_LIST_HEAD(&pRxTS->RxPendingPktList); - timer_setup(&pRxTS->TsCommonInfo.setup_timer, TsSetupTimeOut, + timer_setup(&pRxTS->ts_common_info.setup_timer, TsSetupTimeOut, 0); - timer_setup(&pRxTS->TsCommonInfo.inact_timer, TsInactTimeout, + timer_setup(&pRxTS->ts_common_info.inact_timer, TsInactTimeout, 0); timer_setup(&pRxTS->RxAdmittedBARecord.Timer, RxBaInactTimeout, 0); timer_setup(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, 0); ResetRxTsEntry(pRxTS); - list_add_tail(&pRxTS->TsCommonInfo.list, &ieee->Rx_TS_Unused_List); + list_add_tail(&pRxTS->ts_common_info.list, &ieee->Rx_TS_Unused_List); pRxTS++; } // Initialize unused Rx Reorder List. @@ -374,10 +374,10 @@ bool GetTs( (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, list); list_del_init(&(*ppTS)->list); if(TxRxSelect==TX_DIR) { - struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, TsCommonInfo); + struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, ts_common_info); ResetTxTsEntry(tmp); } else { - PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo); + PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, ts_common_info); ResetRxTsEntry(tmp); } From 4925d4b76647cfade3fff9aa37bd605086ad439b Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:06 +0100 Subject: [PATCH 670/903] staging:rtl8192u: Rename TxCurSeq - Style Rename the member variable TxCurSeq to tx_cur_seq. This change clears the checkpatch issue with CamelCase naming. The changes are coding style changes which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 142b86b393dc..77ec1d5938be 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -342,7 +342,7 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, } else if (!pTxTs->bUsingBa) { - if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096)) + if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->tx_cur_seq + 1) % 4096)) pTxTs->bUsingBa = true; else goto FORCED_AGG_SETTING; @@ -589,7 +589,7 @@ static void ieee80211_query_seqnum(struct ieee80211_device *ieee, { return; } - pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096; + pTS->tx_cur_seq = (pTS->tx_cur_seq + 1) % 4096; } } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 686d4e917384..b217310f9875 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -630,7 +630,7 @@ TsInitAddBA( // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer - pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later. + pBA->BaStartSeqCtrl.field.SeqNum = (pTS->tx_cur_seq + 3) % 4096; // Block Ack will start after 3 packets later. ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index e2c2001dc5ca..8bb55e537bfd 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -28,7 +28,7 @@ struct ts_common_info { struct tx_ts_record { struct ts_common_info ts_common_info; - u16 TxCurSeq; + u16 tx_cur_seq; BA_RECORD TxPendingBARecord; /* For BA Originator */ BA_RECORD TxAdmittedBARecord; /* For BA Originator */ /* QOS_DL_RECORD DLRecord; */ diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index e1ce4e5096bb..3dd42091ed9a 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -113,7 +113,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) static void ResetTxTsEntry(struct tx_ts_record *pTS) { ResetTsCommonInfo(&pTS->ts_common_info); - pTS->TxCurSeq = 0; + pTS->tx_cur_seq = 0; pTS->bAddBaReqInProgress = false; pTS->bAddBaReqDelayed = false; pTS->bUsingBa = false; From 43a420e31de5d1e2b1612ddb08d9ebd2cf9a4d24 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:07 +0100 Subject: [PATCH 671/903] staging:rtl8192u: Rename TxPendingBARecord - Style Rename the member variable TxPendingBARecord to tx_pending_ba_record. This change clears the checkpatch issue with CamelCase naming. The changes are purely coding style changes and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 12 ++++++------ drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index b217310f9875..55b989d71ab8 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -43,7 +43,7 @@ static void DeActivateBAEntry(struct ieee80211_device *ieee, PBA_RECORD pBA) static u8 TxTsDeleteBA(struct ieee80211_device *ieee, struct tx_ts_record *pTxTs) { PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure - PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord; + PBA_RECORD pPendingBa = &pTxTs->tx_pending_ba_record; u8 bSendDELBA = false; // Delete pending BA @@ -470,7 +470,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) } pTS->bAddBaReqInProgress = false; - pPendingBA = &pTS->TxPendingBARecord; + pPendingBA = &pTS->tx_pending_ba_record; pAdmittedBA = &pTS->TxAdmittedBARecord; @@ -615,7 +615,7 @@ TsInitAddBA( u8 bOverwritePending ) { - PBA_RECORD pBA = &pTS->TxPendingBARecord; + PBA_RECORD pBA = &pTS->tx_pending_ba_record; if (pBA->bValid && !bOverwritePending) return; @@ -647,7 +647,7 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, ieee80211_send_DELBA( ieee, pTsCommonInfo->addr, - (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), + (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->tx_pending_ba_record), TxRxSelect, DELBA_REASON_END_BA); } else if (TxRxSelect == RX_DIR) { @@ -669,11 +669,11 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, ********************************************************************************************************************/ void BaSetupTimeOut(struct timer_list *t) { - struct tx_ts_record *pTxTs = from_timer(pTxTs, t, TxPendingBARecord.Timer); + struct tx_ts_record *pTxTs = from_timer(pTxTs, t, tx_pending_ba_record.Timer); pTxTs->bAddBaReqInProgress = false; pTxTs->bAddBaReqDelayed = true; - pTxTs->TxPendingBARecord.bValid = false; + pTxTs->tx_pending_ba_record.bValid = false; } void TxBaInactTimeout(struct timer_list *t) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 8bb55e537bfd..3af894fe5afe 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -29,7 +29,7 @@ struct ts_common_info { struct tx_ts_record { struct ts_common_info ts_common_info; u16 tx_cur_seq; - BA_RECORD TxPendingBARecord; /* For BA Originator */ + BA_RECORD tx_pending_ba_record; /* For BA Originator */ BA_RECORD TxAdmittedBARecord; /* For BA Originator */ /* QOS_DL_RECORD DLRecord; */ u8 bAddBaReqInProgress; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 3dd42091ed9a..3cb6354cf14e 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -118,7 +118,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) pTS->bAddBaReqDelayed = false; pTS->bUsingBa = false; ResetBaEntry(&pTS->TxAdmittedBARecord); //For BA Originator - ResetBaEntry(&pTS->TxPendingBARecord); + ResetBaEntry(&pTS->tx_pending_ba_record); } static void ResetRxTsEntry(PRX_TS_RECORD pTS) @@ -151,7 +151,7 @@ void TSInitialize(struct ieee80211_device *ieee) timer_setup(&pTxTS->ts_common_info.inact_timer, TsInactTimeout, 0); timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0); - timer_setup(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut, + timer_setup(&pTxTS->tx_pending_ba_record.Timer, BaSetupTimeOut, 0); timer_setup(&pTxTS->TxAdmittedBARecord.Timer, TxBaInactTimeout, 0); From f57383bcdace3e7901957ecbbcc8c22bd15a7cf8 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:08 +0100 Subject: [PATCH 672/903] staging:rtl8192u: Rename TxAdmittedBARecord - Style Rename the member variable TxAdmittedBARecord to tx_admitted_ba_record This change clears the checkpatch issue with CamelCase naming. The resulting changes are purely coding style changes which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 77ec1d5938be..2fb9464f6ec3 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -335,14 +335,14 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, printk("===>can't get TS\n"); return; } - if (!pTxTs->TxAdmittedBARecord.bValid) + if (!pTxTs->tx_admitted_ba_record.bValid) { TsStartAddBaProcess(ieee, pTxTs); goto FORCED_AGG_SETTING; } else if (!pTxTs->bUsingBa) { - if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->tx_cur_seq + 1) % 4096)) + if (SN_LESS(pTxTs->tx_admitted_ba_record.BaStartSeqCtrl.field.SeqNum, (pTxTs->tx_cur_seq + 1) % 4096)) pTxTs->bUsingBa = true; else goto FORCED_AGG_SETTING; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 55b989d71ab8..92666fdf8ca8 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -42,7 +42,7 @@ static void DeActivateBAEntry(struct ieee80211_device *ieee, PBA_RECORD pBA) ********************************************************************************************************************/ static u8 TxTsDeleteBA(struct ieee80211_device *ieee, struct tx_ts_record *pTxTs) { - PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure + PBA_RECORD pAdmittedBa = &pTxTs->tx_admitted_ba_record; //These two BA entries must exist in TS structure PBA_RECORD pPendingBa = &pTxTs->tx_pending_ba_record; u8 bSendDELBA = false; @@ -471,7 +471,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) pTS->bAddBaReqInProgress = false; pPendingBA = &pTS->tx_pending_ba_record; - pAdmittedBA = &pTS->TxAdmittedBARecord; + pAdmittedBA = &pTS->tx_admitted_ba_record; // @@ -647,7 +647,7 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, ieee80211_send_DELBA( ieee, pTsCommonInfo->addr, - (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->tx_pending_ba_record), + (pTxTs->tx_admitted_ba_record.bValid)?(&pTxTs->tx_admitted_ba_record):(&pTxTs->tx_pending_ba_record), TxRxSelect, DELBA_REASON_END_BA); } else if (TxRxSelect == RX_DIR) { @@ -678,13 +678,13 @@ void BaSetupTimeOut(struct timer_list *t) void TxBaInactTimeout(struct timer_list *t) { - struct tx_ts_record *pTxTs = from_timer(pTxTs, t, TxAdmittedBARecord.Timer); + struct tx_ts_record *pTxTs = from_timer(pTxTs, t, tx_admitted_ba_record.Timer); struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]); TxTsDeleteBA(ieee, pTxTs); ieee80211_send_DELBA( ieee, pTxTs->ts_common_info.addr, - &pTxTs->TxAdmittedBARecord, + &pTxTs->tx_admitted_ba_record, TX_DIR, DELBA_REASON_TIMEOUT); } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 3af894fe5afe..cacf9b9c295d 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -30,7 +30,7 @@ struct tx_ts_record { struct ts_common_info ts_common_info; u16 tx_cur_seq; BA_RECORD tx_pending_ba_record; /* For BA Originator */ - BA_RECORD TxAdmittedBARecord; /* For BA Originator */ + BA_RECORD tx_admitted_ba_record; /* For BA Originator */ /* QOS_DL_RECORD DLRecord; */ u8 bAddBaReqInProgress; u8 bAddBaReqDelayed; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 3cb6354cf14e..e347a83d6a4f 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -117,7 +117,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) pTS->bAddBaReqInProgress = false; pTS->bAddBaReqDelayed = false; pTS->bUsingBa = false; - ResetBaEntry(&pTS->TxAdmittedBARecord); //For BA Originator + ResetBaEntry(&pTS->tx_admitted_ba_record); //For BA Originator ResetBaEntry(&pTS->tx_pending_ba_record); } @@ -153,7 +153,7 @@ void TSInitialize(struct ieee80211_device *ieee) timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0); timer_setup(&pTxTS->tx_pending_ba_record.Timer, BaSetupTimeOut, 0); - timer_setup(&pTxTS->TxAdmittedBARecord.Timer, + timer_setup(&pTxTS->tx_admitted_ba_record.Timer, TxBaInactTimeout, 0); ResetTxTsEntry(pTxTS); list_add_tail(&pTxTS->ts_common_info.list, &ieee->Tx_TS_Unused_List); From e5afcc0f40b00ca349b0316700af63e9cfd9e549 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:09 +0100 Subject: [PATCH 673/903] staging:rtl8192u: Rename bAddBaReqInProgress - Style Rename the member variable bAddBaReqInProgress to add_ba_req_in_progress This change clears the checkpatch issue with CamelCase naming. Changes are purely coding style and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 92666fdf8ca8..3430a3041560 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -469,7 +469,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) goto OnADDBARsp_Reject; } - pTS->bAddBaReqInProgress = false; + pTS->add_ba_req_in_progress = false; pPendingBA = &pTS->tx_pending_ba_record; pAdmittedBA = &pTS->tx_admitted_ba_record; @@ -595,7 +595,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) } pTxTs->bUsingBa = false; - pTxTs->bAddBaReqInProgress = false; + pTxTs->add_ba_req_in_progress = false; pTxTs->bAddBaReqDelayed = false; del_timer_sync(&pTxTs->TsAddBaTimer); //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer); @@ -671,7 +671,7 @@ void BaSetupTimeOut(struct timer_list *t) { struct tx_ts_record *pTxTs = from_timer(pTxTs, t, tx_pending_ba_record.Timer); - pTxTs->bAddBaReqInProgress = false; + pTxTs->add_ba_req_in_progress = false; pTxTs->bAddBaReqDelayed = true; pTxTs->tx_pending_ba_record.bValid = false; } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index cacf9b9c295d..4d4c25c0f7c4 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -32,7 +32,7 @@ struct tx_ts_record { BA_RECORD tx_pending_ba_record; /* For BA Originator */ BA_RECORD tx_admitted_ba_record; /* For BA Originator */ /* QOS_DL_RECORD DLRecord; */ - u8 bAddBaReqInProgress; + u8 add_ba_req_in_progress; u8 bAddBaReqDelayed; u8 bUsingBa; struct timer_list TsAddBaTimer; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index e347a83d6a4f..54ba60725317 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -114,7 +114,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) { ResetTsCommonInfo(&pTS->ts_common_info); pTS->tx_cur_seq = 0; - pTS->bAddBaReqInProgress = false; + pTS->add_ba_req_in_progress = false; pTS->bAddBaReqDelayed = false; pTS->bUsingBa = false; ResetBaEntry(&pTS->tx_admitted_ba_record); //For BA Originator @@ -522,8 +522,8 @@ void RemoveAllTS(struct ieee80211_device *ieee) void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTxTS) { - if(!pTxTS->bAddBaReqInProgress) { - pTxTS->bAddBaReqInProgress = true; + if(!pTxTS->add_ba_req_in_progress) { + pTxTS->add_ba_req_in_progress = true; if(pTxTS->bAddBaReqDelayed) { IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); mod_timer(&pTxTS->TsAddBaTimer, From df5d5bc8d095d1ad36d8b48e7323cb281761660e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:10 +0100 Subject: [PATCH 674/903] staging:rtl8192u: Rename bAddBaReqDelayed - Style Rename the member variable bAddBaReqDelayed to add_ba_req_delayed This change clears the checkpatch issue with CamelCase naming. The resulting changes are purely coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 8 ++++---- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 3430a3041560..93967e56916c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -500,7 +500,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) // if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { // Since this is a kind of ADDBA failed, we delay next ADDBA process. - pTS->bAddBaReqDelayed = true; + pTS->add_ba_req_delayed = true; DeActivateBAEntry(ieee, pAdmittedBA); ReasonCode = DELBA_REASON_END_BA; goto OnADDBARsp_Reject; @@ -518,7 +518,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal); } else { // Delay next ADDBA process. - pTS->bAddBaReqDelayed = true; + pTS->add_ba_req_delayed = true; } // End of procedure @@ -596,7 +596,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) pTxTs->bUsingBa = false; pTxTs->add_ba_req_in_progress = false; - pTxTs->bAddBaReqDelayed = false; + pTxTs->add_ba_req_delayed = false; del_timer_sync(&pTxTs->TsAddBaTimer); //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer); TxTsDeleteBA(ieee, pTxTs); @@ -672,7 +672,7 @@ void BaSetupTimeOut(struct timer_list *t) struct tx_ts_record *pTxTs = from_timer(pTxTs, t, tx_pending_ba_record.Timer); pTxTs->add_ba_req_in_progress = false; - pTxTs->bAddBaReqDelayed = true; + pTxTs->add_ba_req_delayed = true; pTxTs->tx_pending_ba_record.bValid = false; } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 4d4c25c0f7c4..4c11ed776c25 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -33,7 +33,7 @@ struct tx_ts_record { BA_RECORD tx_admitted_ba_record; /* For BA Originator */ /* QOS_DL_RECORD DLRecord; */ u8 add_ba_req_in_progress; - u8 bAddBaReqDelayed; + u8 add_ba_req_delayed; u8 bUsingBa; struct timer_list TsAddBaTimer; u8 num; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 54ba60725317..ba7763265c08 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -115,7 +115,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) ResetTsCommonInfo(&pTS->ts_common_info); pTS->tx_cur_seq = 0; pTS->add_ba_req_in_progress = false; - pTS->bAddBaReqDelayed = false; + pTS->add_ba_req_delayed = false; pTS->bUsingBa = false; ResetBaEntry(&pTS->tx_admitted_ba_record); //For BA Originator ResetBaEntry(&pTS->tx_pending_ba_record); @@ -524,7 +524,7 @@ void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTx { if(!pTxTS->add_ba_req_in_progress) { pTxTS->add_ba_req_in_progress = true; - if(pTxTS->bAddBaReqDelayed) { + if(pTxTS->add_ba_req_delayed) { IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); mod_timer(&pTxTS->TsAddBaTimer, jiffies + msecs_to_jiffies(TS_ADDBA_DELAY)); From 5ef43de1d2ff68eea82d38caff741d662cea573c Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:11 +0100 Subject: [PATCH 675/903] staging:rtl8192u: Rename bUsingBa - Style Rename the member variable bUsingBa to using_ba. This change clears the checkpatch issue with CamelCase naming. The resulting changes are purely coding style and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 2fb9464f6ec3..cc4049de975d 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -340,10 +340,10 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, TsStartAddBaProcess(ieee, pTxTs); goto FORCED_AGG_SETTING; } - else if (!pTxTs->bUsingBa) + else if (!pTxTs->using_ba) { if (SN_LESS(pTxTs->tx_admitted_ba_record.BaStartSeqCtrl.field.SeqNum, (pTxTs->tx_cur_seq + 1) % 4096)) - pTxTs->bUsingBa = true; + pTxTs->using_ba = true; else goto FORCED_AGG_SETTING; } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 93967e56916c..7bd2d0fb2ebb 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -594,7 +594,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) return -1; } - pTxTs->bUsingBa = false; + pTxTs->using_ba = false; pTxTs->add_ba_req_in_progress = false; pTxTs->add_ba_req_delayed = false; del_timer_sync(&pTxTs->TsAddBaTimer); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 4c11ed776c25..4cb53c75f438 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -34,7 +34,7 @@ struct tx_ts_record { /* QOS_DL_RECORD DLRecord; */ u8 add_ba_req_in_progress; u8 add_ba_req_delayed; - u8 bUsingBa; + u8 using_ba; struct timer_list TsAddBaTimer; u8 num; }; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index ba7763265c08..09fb339203aa 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -116,7 +116,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) pTS->tx_cur_seq = 0; pTS->add_ba_req_in_progress = false; pTS->add_ba_req_delayed = false; - pTS->bUsingBa = false; + pTS->using_ba = false; ResetBaEntry(&pTS->tx_admitted_ba_record); //For BA Originator ResetBaEntry(&pTS->tx_pending_ba_record); } From 1c194ce9fc1d3c0a712d57bd0e75b15dfcd89db1 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:12 +0100 Subject: [PATCH 676/903] staging:rtl8192u: Rename TsAddBaTimer - Style Rename the member variable TsAddBaTimer to ts_add_ba_timer. This change clears the checkpatch issue with CamelCase naming. The resulting changes are coding style in nature and as such should not have any impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 7bd2d0fb2ebb..01bf9f3488ab 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -597,8 +597,8 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) pTxTs->using_ba = false; pTxTs->add_ba_req_in_progress = false; pTxTs->add_ba_req_delayed = false; - del_timer_sync(&pTxTs->TsAddBaTimer); - //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer); + del_timer_sync(&pTxTs->ts_add_ba_timer); + //PlatformCancelTimer(Adapter, &pTxTs->ts_add_ba_timer); TxTsDeleteBA(ieee, pTxTs); } return 0; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 4cb53c75f438..b878ff5f7d0f 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -35,7 +35,7 @@ struct tx_ts_record { u8 add_ba_req_in_progress; u8 add_ba_req_delayed; u8 using_ba; - struct timer_list TsAddBaTimer; + struct timer_list ts_add_ba_timer; u8 num; }; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 09fb339203aa..399e97ce62b4 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -92,7 +92,7 @@ static void RxPktPendingTimeout(struct timer_list *t) ********************************************************************************************************************/ static void TsAddBaProcess(struct timer_list *t) { - struct tx_ts_record *pTxTs = from_timer(pTxTs, t, TsAddBaTimer); + struct tx_ts_record *pTxTs = from_timer(pTxTs, t, ts_add_ba_timer); u8 num = pTxTs->num; struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]); @@ -150,7 +150,7 @@ void TSInitialize(struct ieee80211_device *ieee) 0); timer_setup(&pTxTS->ts_common_info.inact_timer, TsInactTimeout, 0); - timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0); + timer_setup(&pTxTS->ts_add_ba_timer, TsAddBaProcess, 0); timer_setup(&pTxTS->tx_pending_ba_record.Timer, BaSetupTimeOut, 0); timer_setup(&pTxTS->tx_admitted_ba_record.Timer, @@ -448,7 +448,7 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info * //#endif } else { struct tx_ts_record *pTxTS = (struct tx_ts_record *)pTs; - del_timer_sync(&pTxTS->TsAddBaTimer); + del_timer_sync(&pTxTS->ts_add_ba_timer); } } @@ -526,11 +526,11 @@ void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTx pTxTS->add_ba_req_in_progress = true; if(pTxTS->add_ba_req_delayed) { IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); - mod_timer(&pTxTS->TsAddBaTimer, + mod_timer(&pTxTS->ts_add_ba_timer, jiffies + msecs_to_jiffies(TS_ADDBA_DELAY)); } else { IEEE80211_DEBUG(IEEE80211_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); - mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); //set 10 ticks + mod_timer(&pTxTS->ts_add_ba_timer, jiffies+10); //set 10 ticks } } else { IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s()==>BA timer is already added\n", __func__); From 80b6f0d45c76331861b696dfb65aeb218bd5e8b5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:13 +0100 Subject: [PATCH 677/903] staging:rtl8192u: Remove typedef and rename RX_TS_RECORD - Style Remove the typedef from structure RX_TS_RECORD, this change clears the checkpatch issue with creation of new types. Additionally the structure is renamed from RX_TS_RECORD to rx_ts_record. Whilst this is not raised as a checkpatch error structures are meant to be named in lower case. These changes are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +- .../staging/rtl8192u/ieee80211/ieee80211_rx.c | 8 ++++---- .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 16 ++++++++-------- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 4 ++-- .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 14 +++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index aecb697f3729..326a1e47bade 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1651,7 +1651,7 @@ struct ieee80211_device { struct list_head Rx_TS_Admit_List; struct list_head Rx_TS_Pending_List; struct list_head Rx_TS_Unused_List; - RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM]; + struct rx_ts_record RxTsRecord[TOTAL_TS_NUM]; //#ifdef TO_DO_LIST RX_REORDER_ENTRY RxReorderEntry[128]; struct list_head RxReorder_Unused_List; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index a84de8c52a2b..037bd5dfb21a 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -508,7 +508,7 @@ drop: return 1; } -static bool AddReorderEntry(PRX_TS_RECORD pTS, PRX_REORDER_ENTRY pReorderEntry) +static bool AddReorderEntry(struct rx_ts_record *pTS, PRX_REORDER_ENTRY pReorderEntry) { struct list_head *pList = &pTS->RxPendingPktList; while(pList->next != &pTS->RxPendingPktList) @@ -586,7 +586,7 @@ void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, struct ieee80211_rxb *prxb, - PRX_TS_RECORD pTS, u16 SeqNum) + struct rx_ts_record *pTS, u16 SeqNum) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; PRX_REORDER_ENTRY pReorderEntry = NULL; @@ -898,7 +898,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, //added by amy for reorder u8 TID = 0; u16 SeqNum = 0; - PRX_TS_RECORD pTS = NULL; + struct rx_ts_record *pTS = NULL; //bool bIsAggregateFrame = false; //added by amy for reorder #ifdef NOT_YET @@ -1017,7 +1017,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } else { - PRX_TS_RECORD pRxTS = NULL; + struct rx_ts_record *pRxTS = NULL; //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__func__, tid); if(GetTs( ieee, diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 01bf9f3488ab..c2a51a6c2969 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -64,11 +64,11 @@ static u8 TxTsDeleteBA(struct ieee80211_device *ieee, struct tx_ts_record *pTxTs /******************************************************************************************************************** *function: deactivete BA entry in Tx Ts, and send DELBA. * input: - * PRX_TS_RECORD pRxTs //Rx Ts which is to deactivate BA entry. + * struct rx_ts_record *pRxTs //Rx Ts which is to deactivate BA entry. * output: none - * notice: As PRX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME, same with above + * notice: As struct rx_ts_record * structure will be defined in QOS, so wait to be merged. //FIXME, same with above ********************************************************************************************************************/ -static u8 RxTsDeleteBA(struct ieee80211_device *ieee, PRX_TS_RECORD pRxTs) +static u8 RxTsDeleteBA(struct ieee80211_device *ieee, struct rx_ts_record *pRxTs) { PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; @@ -325,7 +325,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) PBA_PARAM_SET pBaParamSet = NULL; u16 *pBaTimeoutVal = NULL; PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; - PRX_TS_RECORD pTS = NULL; + struct rx_ts_record *pTS = NULL; if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) { IEEE80211_DEBUG(IEEE80211_DL_ERR, @@ -566,7 +566,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) pDelBaParamSet = (PDELBA_PARAM_SET)&delba->payload[2]; if (pDelBaParamSet->field.Initiator == 1) { - PRX_TS_RECORD pRxTs; + struct rx_ts_record *pRxTs; if (!GetTs( ieee, @@ -651,7 +651,7 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, TxRxSelect, DELBA_REASON_END_BA); } else if (TxRxSelect == RX_DIR) { - PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo; + struct rx_ts_record *pRxTs = (struct rx_ts_record *)pTsCommonInfo; if (RxTsDeleteBA(ieee, pRxTs)) ieee80211_send_DELBA( ieee, @@ -663,7 +663,7 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, } /******************************************************************************************************************** *function: BA setup timer - * input: unsigned long data //acturally we send struct tx_ts_record or RX_TS_RECORD to these timer + * input: unsigned long data //acturally we send struct tx_ts_record or struct rx_ts_record to these timer * return: NULL * notice: ********************************************************************************************************************/ @@ -691,7 +691,7 @@ void TxBaInactTimeout(struct timer_list *t) void RxBaInactTimeout(struct timer_list *t) { - PRX_TS_RECORD pRxTs = from_timer(pRxTs, t, RxAdmittedBARecord.Timer); + struct rx_ts_record *pRxTs = from_timer(pRxTs, t, RxAdmittedBARecord.Timer); struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); RxTsDeleteBA(ieee, pRxTs); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index b878ff5f7d0f..53203e633c0b 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -39,7 +39,7 @@ struct tx_ts_record { u8 num; }; -typedef struct _RX_TS_RECORD { +struct rx_ts_record { struct ts_common_info ts_common_info; u16 RxIndicateSeq; u16 RxTimeoutIndicateSeq; @@ -50,7 +50,7 @@ typedef struct _RX_TS_RECORD { u8 RxLastFragNum; u8 num; /* QOS_DL_RECORD DLRecord; */ -} RX_TS_RECORD, *PRX_TS_RECORD; +}; #endif diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 399e97ce62b4..8728048d3f27 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -19,13 +19,13 @@ static void TsInactTimeout(struct timer_list *unused) /******************************************************************************************************************** *function: I still not understand this function, so wait for further implementation - * input: unsigned long data //acturally we send struct tx_ts_record or RX_TS_RECORD to these timer + * input: unsigned long data //acturally we send struct tx_ts_record or struct rx_ts_record to these timer * return: NULL * notice: ********************************************************************************************************************/ static void RxPktPendingTimeout(struct timer_list *t) { - PRX_TS_RECORD pRxTs = from_timer(pRxTs, t, RxPktPendingTimer); + struct rx_ts_record *pRxTs = from_timer(pRxTs, t, RxPktPendingTimer); struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); PRX_REORDER_ENTRY pReorderEntry = NULL; @@ -86,7 +86,7 @@ static void RxPktPendingTimeout(struct timer_list *t) /******************************************************************************************************************** *function: Add BA timer function - * input: unsigned long data //acturally we send struct tx_ts_record or RX_TS_RECORD to these timer + * input: unsigned long data //acturally we send struct tx_ts_record or struct rx_ts_record to these timer * return: NULL * notice: ********************************************************************************************************************/ @@ -121,7 +121,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) ResetBaEntry(&pTS->tx_pending_ba_record); } -static void ResetRxTsEntry(PRX_TS_RECORD pTS) +static void ResetRxTsEntry(struct rx_ts_record *pTS) { ResetTsCommonInfo(&pTS->ts_common_info); pTS->RxIndicateSeq = 0xffff; // This indicate the RxIndicateSeq is not used now!! @@ -132,7 +132,7 @@ static void ResetRxTsEntry(PRX_TS_RECORD pTS) void TSInitialize(struct ieee80211_device *ieee) { struct tx_ts_record *pTxTS = ieee->TxTsRecord; - PRX_TS_RECORD pRxTS = ieee->RxTsRecord; + struct rx_ts_record *pRxTS = ieee->RxTsRecord; PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; u8 count = 0; IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __func__); @@ -377,7 +377,7 @@ bool GetTs( struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, ts_common_info); ResetTxTsEntry(tmp); } else { - PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, ts_common_info); + struct rx_ts_record *tmp = container_of(*ppTS, struct rx_ts_record, ts_common_info); ResetRxTsEntry(tmp); } @@ -419,7 +419,7 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info * if(TxRxSelect == RX_DIR) { //#ifdef TO_DO_LIST PRX_REORDER_ENTRY pRxReorderEntry; - PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs; + struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs; if(timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); From b88668ace9fa31605bdcde7c9626142525419bcf Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:14 +0100 Subject: [PATCH 678/903] staging:rtl8192u: Remove commented out code - Style Remove commented out sections of code, specifically for a structure, QOS_DL_RECORD, which no longer exists in the module. This change is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 53203e633c0b..2840d6e8dfda 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -31,7 +31,6 @@ struct tx_ts_record { u16 tx_cur_seq; BA_RECORD tx_pending_ba_record; /* For BA Originator */ BA_RECORD tx_admitted_ba_record; /* For BA Originator */ -/* QOS_DL_RECORD DLRecord; */ u8 add_ba_req_in_progress; u8 add_ba_req_delayed; u8 using_ba; @@ -49,7 +48,6 @@ struct rx_ts_record { u16 RxLastSeqNum; u8 RxLastFragNum; u8 num; -/* QOS_DL_RECORD DLRecord; */ }; From 596a2ca3b48b4109cdf390dfd99f7e422bbe7b9f Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:15 +0100 Subject: [PATCH 679/903] staging:rtl8192u: Remove unused timer values - Style Remove the unused timer constants TS_SETUP_TIMEOUT and TS_INACT_TIMEOUT as neither are used in code. This is a style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 2840d6e8dfda..0db0d01ec5c4 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -2,8 +2,7 @@ #ifndef _TSTYPE_H_ #define _TSTYPE_H_ #include "rtl819x_Qos.h" -#define TS_SETUP_TIMEOUT 60 /* In millisecond */ -#define TS_INACT_TIMEOUT 60 + #define TS_ADDBA_DELAY 60 #define TOTAL_TS_NUM 16 From dfbb36f7173465e8e59eeef37e569caafc0cbaa4 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:16 +0100 Subject: [PATCH 680/903] staging:rtl8192u: Rename RxIndicateSeq - Style Rename the member variable RxIndicateSeq to rx_indicate_seq. This change clears the checkpatch issue with CamelCase naming. The resulting changes are purely coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211_rx.c | 40 +++++++++---------- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 14 +++---- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 037bd5dfb21a..e1f5161be4f3 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -592,10 +592,10 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, PRX_REORDER_ENTRY pReorderEntry = NULL; struct ieee80211_rxb **prxbIndicateArray; u8 WinSize = pHTInfo->RxReorderWinSize; - u16 WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096; + u16 WinEnd = (pTS->rx_indicate_seq + WinSize - 1) % 4096; u8 index = 0; bool bMatchWinStart = false, bPktInBuf = false; - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); + IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->rx_indicate_seq is %d, WinSize is %d\n",__func__,SeqNum,pTS->rx_indicate_seq,WinSize); prxbIndicateArray = kmalloc_array(REORDER_WIN_SIZE, sizeof(struct ieee80211_rxb *), @@ -604,14 +604,14 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, return; /* Rx Reorder initialize condition.*/ - if (pTS->RxIndicateSeq == 0xffff) { - pTS->RxIndicateSeq = SeqNum; + if (pTS->rx_indicate_seq == 0xffff) { + pTS->rx_indicate_seq = SeqNum; } /* Drop out the packet which SeqNum is smaller than WinStart */ - if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) { + if (SN_LESS(SeqNum, pTS->rx_indicate_seq)) { IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n", - pTS->RxIndicateSeq, SeqNum); + pTS->rx_indicate_seq, SeqNum); pHTInfo->RxReorderDropCounter++; { int i; @@ -631,16 +631,16 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, * 1. Incoming SeqNum is equal to WinStart =>Window shift 1 * 2. Incoming SeqNum is larger than the WinEnd => Window shift N */ - if(SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) { - pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; + if(SN_EQUAL(SeqNum, pTS->rx_indicate_seq)) { + pTS->rx_indicate_seq = (pTS->rx_indicate_seq + 1) % 4096; bMatchWinStart = true; } else if(SN_LESS(WinEnd, SeqNum)) { if(SeqNum >= (WinSize - 1)) { - pTS->RxIndicateSeq = SeqNum + 1 -WinSize; + pTS->rx_indicate_seq = SeqNum + 1 -WinSize; } else { - pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1; + pTS->rx_indicate_seq = 4095 - (WinSize - (SeqNum + 1)) + 1; } - IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->rx_indicate_seq, SeqNum); } /* @@ -655,7 +655,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, if(bMatchWinStart) { /* Current packet is going to be indicated.*/ IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\ - pTS->RxIndicateSeq, SeqNum); + pTS->rx_indicate_seq, SeqNum); prxbIndicateArray[0] = prxb; // printk("========================>%s(): SeqNum is %d\n",__func__,SeqNum); index = 1; @@ -673,7 +673,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, if(!AddReorderEntry(pTS, pReorderEntry)) { IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", - __func__, pTS->RxIndicateSeq, SeqNum); + __func__, pTS->rx_indicate_seq, SeqNum); list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); { int i; @@ -685,7 +685,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, } } else { IEEE80211_DEBUG(IEEE80211_DL_REORDER, - "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->rx_indicate_seq, SeqNum); } } else { @@ -710,8 +710,8 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, while(!list_empty(&pTS->RxPendingPktList)) { IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); - if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) + if (SN_LESS(pReorderEntry->SeqNum, pTS->rx_indicate_seq) || + SN_EQUAL(pReorderEntry->SeqNum, pTS->rx_indicate_seq)) { /* This protect buffer from overflow. */ if (index >= REORDER_WIN_SIZE) { @@ -722,10 +722,10 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, list_del_init(&pReorderEntry->List); - if(SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) - pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; + if(SN_EQUAL(pReorderEntry->SeqNum, pTS->rx_indicate_seq)) + pTS->rx_indicate_seq = (pTS->rx_indicate_seq + 1) % 4096; - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->rx_indicate_seq, SeqNum); prxbIndicateArray[index] = pReorderEntry->prxb; // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__func__,pReorderEntry->SeqNum); index++; @@ -755,7 +755,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, if (bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { // Set new pending timer. IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); - pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; + pTS->RxTimeoutIndicateSeq = pTS->rx_indicate_seq; if(timer_pending(&pTS->RxPktPendingTimer)) del_timer_sync(&pTS->RxPktPendingTimer); pTS->RxPktPendingTimer.expires = jiffies + diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 0db0d01ec5c4..98be5e1b7c84 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -39,7 +39,7 @@ struct tx_ts_record { struct rx_ts_record { struct ts_common_info ts_common_info; - u16 RxIndicateSeq; + u16 rx_indicate_seq; u16 RxTimeoutIndicateSeq; struct list_head RxPendingPktList; struct timer_list RxPktPendingTimer; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 8728048d3f27..ac45b502d07d 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -42,14 +42,14 @@ static void RxPktPendingTimeout(struct timer_list *t) while(!list_empty(&pRxTs->RxPendingPktList)) { pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List); if(index == 0) - pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; + pRxTs->rx_indicate_seq = pReorderEntry->SeqNum; - if( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ) { + if( SN_LESS(pReorderEntry->SeqNum, pRxTs->rx_indicate_seq) || + SN_EQUAL(pReorderEntry->SeqNum, pRxTs->rx_indicate_seq) ) { list_del_init(&pReorderEntry->List); - if(SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) - pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; + if(SN_EQUAL(pReorderEntry->SeqNum, pRxTs->rx_indicate_seq)) + pRxTs->rx_indicate_seq = (pRxTs->rx_indicate_seq + 1) % 4096; IEEE80211_DEBUG(IEEE80211_DL_REORDER,"RxPktPendingTimeout(): IndicateSeq: %d\n", pReorderEntry->SeqNum); ieee->stats_IndicateArray[index] = pReorderEntry->prxb; @@ -77,7 +77,7 @@ static void RxPktPendingTimeout(struct timer_list *t) } if(bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)) { - pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; + pRxTs->RxTimeoutIndicateSeq = pRxTs->rx_indicate_seq; mod_timer(&pRxTs->RxPktPendingTimer, jiffies + msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime)); } @@ -124,7 +124,7 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS) static void ResetRxTsEntry(struct rx_ts_record *pTS) { ResetTsCommonInfo(&pTS->ts_common_info); - pTS->RxIndicateSeq = 0xffff; // This indicate the RxIndicateSeq is not used now!! + pTS->rx_indicate_seq = 0xffff; // This indicate the rx_indicate_seq is not used now!! pTS->RxTimeoutIndicateSeq = 0xffff; // This indicate the RxTimeoutIndicateSeq is not used now!! ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recipient } From 902efe070caf5d5a901c1d51bb4a5e0ebcb5c7c5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:17 +0100 Subject: [PATCH 681/903] staging:rtl8192u: Rename RxTimeoutIndicateSeq _Style Rename member variable RxTimeoutIndicateSeq to rx_timeout_indicate_seq. This change clears the checkpatch issue with CamelCase naming. The resulting changes are purely coding style in nature and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index e1f5161be4f3..99fb59a3b8f0 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -741,7 +741,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, if (index>0) { // Cancel previous pending timer. // del_timer_sync(&pTS->RxPktPendingTimer); - pTS->RxTimeoutIndicateSeq = 0xffff; + pTS->rx_timeout_indicate_seq = 0xffff; // Indicate packets if(index>REORDER_WIN_SIZE){ @@ -752,10 +752,10 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, ieee80211_indicate_packets(ieee, prxbIndicateArray, index); } - if (bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { + if (bPktInBuf && pTS->rx_timeout_indicate_seq == 0xffff) { // Set new pending timer. IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); - pTS->RxTimeoutIndicateSeq = pTS->rx_indicate_seq; + pTS->rx_timeout_indicate_seq = pTS->rx_indicate_seq; if(timer_pending(&pTS->RxPktPendingTimer)) del_timer_sync(&pTS->RxPktPendingTimer); pTS->RxPktPendingTimer.expires = jiffies + diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 98be5e1b7c84..02b76d49b5e1 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -40,7 +40,7 @@ struct tx_ts_record { struct rx_ts_record { struct ts_common_info ts_common_info; u16 rx_indicate_seq; - u16 RxTimeoutIndicateSeq; + u16 rx_timeout_indicate_seq; struct list_head RxPendingPktList; struct timer_list RxPktPendingTimer; BA_RECORD RxAdmittedBARecord; /* For BA Recipient */ diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index ac45b502d07d..e3877f35e677 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -37,7 +37,7 @@ static void RxPktPendingTimeout(struct timer_list *t) spin_lock_irqsave(&(ieee->reorder_spinlock), flags); IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__func__); - if(pRxTs->RxTimeoutIndicateSeq != 0xffff) { + if(pRxTs->rx_timeout_indicate_seq != 0xffff) { // Indicate the pending packets sequentially according to SeqNum until meet the gap. while(!list_empty(&pRxTs->RxPendingPktList)) { pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List); @@ -64,8 +64,8 @@ static void RxPktPendingTimeout(struct timer_list *t) } if(index>0) { - // Set RxTimeoutIndicateSeq to 0xffff to indicate no pending packets in buffer now. - pRxTs->RxTimeoutIndicateSeq = 0xffff; + // Set rx_timeout_indicate_seq to 0xffff to indicate no pending packets in buffer now. + pRxTs->rx_timeout_indicate_seq = 0xffff; // Indicate packets if(index > REORDER_WIN_SIZE) { @@ -76,8 +76,8 @@ static void RxPktPendingTimeout(struct timer_list *t) ieee80211_indicate_packets(ieee, ieee->stats_IndicateArray, index); } - if(bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)) { - pRxTs->RxTimeoutIndicateSeq = pRxTs->rx_indicate_seq; + if(bPktInBuf && (pRxTs->rx_timeout_indicate_seq == 0xffff)) { + pRxTs->rx_timeout_indicate_seq = pRxTs->rx_indicate_seq; mod_timer(&pRxTs->RxPktPendingTimer, jiffies + msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime)); } @@ -125,7 +125,7 @@ static void ResetRxTsEntry(struct rx_ts_record *pTS) { ResetTsCommonInfo(&pTS->ts_common_info); pTS->rx_indicate_seq = 0xffff; // This indicate the rx_indicate_seq is not used now!! - pTS->RxTimeoutIndicateSeq = 0xffff; // This indicate the RxTimeoutIndicateSeq is not used now!! + pTS->rx_timeout_indicate_seq = 0xffff; // This indicate the rx_timeout_indicate_seq is not used now!! ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recipient } From a1ac7d1c470372089d5cec4c47db8a165c06bdb2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:18 +0100 Subject: [PATCH 682/903] staging:rtl8192u: Rename RxPendingPktList - Style Rename the member variable RxPendingPktList to rx_pending_pkt_list. This change resolves the checkpatch issue with CamelCase naming. The resulting changes are purely coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 8 ++++---- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 99fb59a3b8f0..0a1f433def2f 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -510,8 +510,8 @@ drop: static bool AddReorderEntry(struct rx_ts_record *pTS, PRX_REORDER_ENTRY pReorderEntry) { - struct list_head *pList = &pTS->RxPendingPktList; - while(pList->next != &pTS->RxPendingPktList) + struct list_head *pList = &pTS->rx_pending_pkt_list; + while(pList->next != &pTS->rx_pending_pkt_list) { if( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) ) { @@ -707,9 +707,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, } /* Check if there is any packet need indicate.*/ - while(!list_empty(&pTS->RxPendingPktList)) { + while(!list_empty(&pTS->rx_pending_pkt_list)) { IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->rx_pending_pkt_list.prev,RX_REORDER_ENTRY,List); if (SN_LESS(pReorderEntry->SeqNum, pTS->rx_indicate_seq) || SN_EQUAL(pReorderEntry->SeqNum, pTS->rx_indicate_seq)) { diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 02b76d49b5e1..9c85d3623578 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -41,7 +41,7 @@ struct rx_ts_record { struct ts_common_info ts_common_info; u16 rx_indicate_seq; u16 rx_timeout_indicate_seq; - struct list_head RxPendingPktList; + struct list_head rx_pending_pkt_list; struct timer_list RxPktPendingTimer; BA_RECORD RxAdmittedBARecord; /* For BA Recipient */ u16 RxLastSeqNum; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index e3877f35e677..6a6aad6decd6 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -39,8 +39,8 @@ static void RxPktPendingTimeout(struct timer_list *t) IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__func__); if(pRxTs->rx_timeout_indicate_seq != 0xffff) { // Indicate the pending packets sequentially according to SeqNum until meet the gap. - while(!list_empty(&pRxTs->RxPendingPktList)) { - pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + while(!list_empty(&pRxTs->rx_pending_pkt_list)) { + pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->rx_pending_pkt_list.prev,RX_REORDER_ENTRY,List); if(index == 0) pRxTs->rx_indicate_seq = pReorderEntry->SeqNum; @@ -166,7 +166,7 @@ void TSInitialize(struct ieee80211_device *ieee) INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List); for(count = 0; count < TOTAL_TS_NUM; count++) { pRxTS->num = count; - INIT_LIST_HEAD(&pRxTS->RxPendingPktList); + INIT_LIST_HEAD(&pRxTS->rx_pending_pkt_list); timer_setup(&pRxTS->ts_common_info.setup_timer, TsSetupTimeOut, 0); timer_setup(&pRxTS->ts_common_info.inact_timer, TsInactTimeout, @@ -423,10 +423,10 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info * if(timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); - while(!list_empty(&pRxTS->RxPendingPktList)) { + while(!list_empty(&pRxTS->rx_pending_pkt_list)) { spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - //pRxReorderEntry = list_entry(&pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); - pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); + //pRxReorderEntry = list_entry(&pRxTS->rx_pending_pkt_list.prev,RX_REORDER_ENTRY,List); + pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->rx_pending_pkt_list.prev,RX_REORDER_ENTRY,List); list_del_init(&pRxReorderEntry->List); { int i = 0; From 5b76f8cbe23fc100e8447057e2dfcff4fb72617d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:19 +0100 Subject: [PATCH 683/903] staging:rtl8192u: Rename RxPktPendingTimer - Style Rename the member variable RxPktPendingTimer to rx_pkt_pending_timer. This change clears the checkpatch issue with CamelCase naming. The resulting changes are coding style changes in nature so should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 0a1f433def2f..5a2a7a4aedca 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -740,7 +740,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/ if (index>0) { // Cancel previous pending timer. - // del_timer_sync(&pTS->RxPktPendingTimer); + // del_timer_sync(&pTS->rx_pkt_pending_timer); pTS->rx_timeout_indicate_seq = 0xffff; // Indicate packets @@ -756,11 +756,11 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, // Set new pending timer. IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); pTS->rx_timeout_indicate_seq = pTS->rx_indicate_seq; - if(timer_pending(&pTS->RxPktPendingTimer)) - del_timer_sync(&pTS->RxPktPendingTimer); - pTS->RxPktPendingTimer.expires = jiffies + + if(timer_pending(&pTS->rx_pkt_pending_timer)) + del_timer_sync(&pTS->rx_pkt_pending_timer); + pTS->rx_pkt_pending_timer.expires = jiffies + msecs_to_jiffies(pHTInfo->RxReorderPendingTime); - add_timer(&pTS->RxPktPendingTimer); + add_timer(&pTS->rx_pkt_pending_timer); } kfree(prxbIndicateArray); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 9c85d3623578..a338d53ff88c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -42,7 +42,7 @@ struct rx_ts_record { u16 rx_indicate_seq; u16 rx_timeout_indicate_seq; struct list_head rx_pending_pkt_list; - struct timer_list RxPktPendingTimer; + struct timer_list rx_pkt_pending_timer; BA_RECORD RxAdmittedBARecord; /* For BA Recipient */ u16 RxLastSeqNum; u8 RxLastFragNum; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 6a6aad6decd6..aad2704a7f46 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -25,7 +25,7 @@ static void TsInactTimeout(struct timer_list *unused) ********************************************************************************************************************/ static void RxPktPendingTimeout(struct timer_list *t) { - struct rx_ts_record *pRxTs = from_timer(pRxTs, t, RxPktPendingTimer); + struct rx_ts_record *pRxTs = from_timer(pRxTs, t, rx_pkt_pending_timer); struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); PRX_REORDER_ENTRY pReorderEntry = NULL; @@ -78,7 +78,7 @@ static void RxPktPendingTimeout(struct timer_list *t) if(bPktInBuf && (pRxTs->rx_timeout_indicate_seq == 0xffff)) { pRxTs->rx_timeout_indicate_seq = pRxTs->rx_indicate_seq; - mod_timer(&pRxTs->RxPktPendingTimer, + mod_timer(&pRxTs->rx_pkt_pending_timer, jiffies + msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); @@ -173,7 +173,7 @@ void TSInitialize(struct ieee80211_device *ieee) 0); timer_setup(&pRxTS->RxAdmittedBARecord.Timer, RxBaInactTimeout, 0); - timer_setup(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, 0); + timer_setup(&pRxTS->rx_pkt_pending_timer, RxPktPendingTimeout, 0); ResetRxTsEntry(pRxTS); list_add_tail(&pRxTS->ts_common_info.list, &ieee->Rx_TS_Unused_List); pRxTS++; @@ -420,8 +420,8 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, struct ts_common_info * //#ifdef TO_DO_LIST PRX_REORDER_ENTRY pRxReorderEntry; struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs; - if(timer_pending(&pRxTS->RxPktPendingTimer)) - del_timer_sync(&pRxTS->RxPktPendingTimer); + if(timer_pending(&pRxTS->rx_pkt_pending_timer)) + del_timer_sync(&pRxTS->rx_pkt_pending_timer); while(!list_empty(&pRxTS->rx_pending_pkt_list)) { spin_lock_irqsave(&(ieee->reorder_spinlock), flags); From 02f2560cbedd1e222791c498a2878b45c1347b65 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:20 +0100 Subject: [PATCH 684/903] staging:rtl8192u: Rename RxAdmittedBARecord - Style Rename the member variable RxAdmittedBARecord to rx_admitted_ba_record. This change clears the checkpatch issue with CamelCase naming. The resulting changes are coding style in nature and as such should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 10 +++++----- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index c2a51a6c2969..e296813203aa 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -70,7 +70,7 @@ static u8 TxTsDeleteBA(struct ieee80211_device *ieee, struct tx_ts_record *pTxTs ********************************************************************************************************************/ static u8 RxTsDeleteBA(struct ieee80211_device *ieee, struct rx_ts_record *pRxTs) { - PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord; + PBA_RECORD pBa = &pRxTs->rx_admitted_ba_record; u8 bSendDELBA = false; if (pBa->bValid) { @@ -369,7 +369,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __func__); goto OnADDBAReq_Fail; } - pBA = &pTS->RxAdmittedBARecord; + pBA = &pTS->rx_admitted_ba_record; // To Determine the ADDBA Req content // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl... // I want to check StartSeqCtrl to make sure when we start aggregation!!! @@ -656,7 +656,7 @@ TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, ieee80211_send_DELBA( ieee, pTsCommonInfo->addr, - &pRxTs->RxAdmittedBARecord, + &pRxTs->rx_admitted_ba_record, TxRxSelect, DELBA_REASON_END_BA); } @@ -691,14 +691,14 @@ void TxBaInactTimeout(struct timer_list *t) void RxBaInactTimeout(struct timer_list *t) { - struct rx_ts_record *pRxTs = from_timer(pRxTs, t, RxAdmittedBARecord.Timer); + struct rx_ts_record *pRxTs = from_timer(pRxTs, t, rx_admitted_ba_record.Timer); struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); RxTsDeleteBA(ieee, pRxTs); ieee80211_send_DELBA( ieee, pRxTs->ts_common_info.addr, - &pRxTs->RxAdmittedBARecord, + &pRxTs->rx_admitted_ba_record, RX_DIR, DELBA_REASON_TIMEOUT); } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index a338d53ff88c..7cc13e5dfb2d 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -43,7 +43,7 @@ struct rx_ts_record { u16 rx_timeout_indicate_seq; struct list_head rx_pending_pkt_list; struct timer_list rx_pkt_pending_timer; - BA_RECORD RxAdmittedBARecord; /* For BA Recipient */ + BA_RECORD rx_admitted_ba_record; /* For BA Recipient */ u16 RxLastSeqNum; u8 RxLastFragNum; u8 num; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index aad2704a7f46..a44536d8cd42 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -126,7 +126,7 @@ static void ResetRxTsEntry(struct rx_ts_record *pTS) ResetTsCommonInfo(&pTS->ts_common_info); pTS->rx_indicate_seq = 0xffff; // This indicate the rx_indicate_seq is not used now!! pTS->rx_timeout_indicate_seq = 0xffff; // This indicate the rx_timeout_indicate_seq is not used now!! - ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recipient + ResetBaEntry(&pTS->rx_admitted_ba_record); // For BA Recipient } void TSInitialize(struct ieee80211_device *ieee) @@ -171,7 +171,7 @@ void TSInitialize(struct ieee80211_device *ieee) 0); timer_setup(&pRxTS->ts_common_info.inact_timer, TsInactTimeout, 0); - timer_setup(&pRxTS->RxAdmittedBARecord.Timer, + timer_setup(&pRxTS->rx_admitted_ba_record.Timer, RxBaInactTimeout, 0); timer_setup(&pRxTS->rx_pkt_pending_timer, RxPktPendingTimeout, 0); ResetRxTsEntry(pRxTS); From 01eb0ce4a84b5045822e71d4312d4fb66190c6c1 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:21 +0100 Subject: [PATCH 685/903] staging:rtl8192u: Rename RxLastSeqNum - Style Rename the member variable RxLastSeqNum to rx_last_seq_num. This change clears the checkpatch issue with CamelCase naming. The resulting changes are purely coding style in nature so should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 5a2a7a4aedca..c0c746bfd390 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -1028,16 +1028,16 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, true)) { - // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__func__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc)); + // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->rx_last_seq_num is %d,seq is %d\n",__func__,pRxTS->RxLastFragNum,frag,pRxTS->rx_last_seq_num,WLAN_GET_SEQ_SEQ(sc)); if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && - (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { + (WLAN_GET_SEQ_SEQ(sc) == pRxTS->rx_last_seq_num)) { goto rx_dropped; } else { pRxTS->RxLastFragNum = frag; - pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); + pRxTS->rx_last_seq_num = WLAN_GET_SEQ_SEQ(sc); } } else diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 7cc13e5dfb2d..0bf877162a8f 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -44,7 +44,7 @@ struct rx_ts_record { struct list_head rx_pending_pkt_list; struct timer_list rx_pkt_pending_timer; BA_RECORD rx_admitted_ba_record; /* For BA Recipient */ - u16 RxLastSeqNum; + u16 rx_last_seq_num; u8 RxLastFragNum; u8 num; }; From 99750726f9fafe7418c5f335803b1f55363c396e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:22 +0100 Subject: [PATCH 686/903] staging:rtl8192u: Rename RxLastFragNum - Style Rename the member variable RxLastFragNum to rx_last_frag_num. This change clears the checkpatch issue with CamelCase naming. The resulting edits are all coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index c0c746bfd390..28cae82d795c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -1028,15 +1028,15 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, true)) { - // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->rx_last_seq_num is %d,seq is %d\n",__func__,pRxTS->RxLastFragNum,frag,pRxTS->rx_last_seq_num,WLAN_GET_SEQ_SEQ(sc)); + // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->rx_last_frag_num is %d,frag is %d,pRxTS->rx_last_seq_num is %d,seq is %d\n",__func__,pRxTS->rx_last_frag_num,frag,pRxTS->rx_last_seq_num,WLAN_GET_SEQ_SEQ(sc)); if ((fc & (1<<11)) && - (frag == pRxTS->RxLastFragNum) && + (frag == pRxTS->rx_last_frag_num) && (WLAN_GET_SEQ_SEQ(sc) == pRxTS->rx_last_seq_num)) { goto rx_dropped; } else { - pRxTS->RxLastFragNum = frag; + pRxTS->rx_last_frag_num = frag; pRxTS->rx_last_seq_num = WLAN_GET_SEQ_SEQ(sc); } } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 0bf877162a8f..aaed1dab7100 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -45,7 +45,7 @@ struct rx_ts_record { struct timer_list rx_pkt_pending_timer; BA_RECORD rx_admitted_ba_record; /* For BA Recipient */ u16 rx_last_seq_num; - u8 RxLastFragNum; + u8 rx_last_frag_num; u8 num; }; From f164338121d78fb7344702e2a8726a89388e88dc Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 27 Jul 2018 18:31:23 +0100 Subject: [PATCH 687/903] staging:rtl8192u: Remove blank line - Style Remove a blank line to clear the checkpatch issue with use of multiple blank lines. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index aaed1dab7100..f5e79853fe9c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -49,5 +49,4 @@ struct rx_ts_record { u8 num; }; - #endif From c225b00d012e28487414a82d07d7dee8959c579d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 28 Jul 2018 00:28:17 +0100 Subject: [PATCH 688/903] staging:rtl8192u: Remove unused DM_check_fsync_time_interval - Style Remove the unused definition for DM_check_fsync_time_interval. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 8f3d618dcfdb..e86dda99c223 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -32,9 +32,6 @@ #define BW_AUTO_SWITCH_HIGH_LOW 25 #define BW_AUTO_SWITCH_LOW_HIGH 30 -#define DM_check_fsync_time_interval 500 - - #define DM_DIG_BACKOFF 12 #define DM_DIG_MAX 0x36 #define DM_DIG_MIN 0x1c From c39f4bb98ea48ff4c521fc5317ae65c490426098 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 28 Jul 2018 16:29:15 +0200 Subject: [PATCH 689/903] staging: rtl8188eu: fix comparsions to NULL - coding style Use !x instead of x == NULL. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 89843201a338..03b65e9b067a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -70,7 +70,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); - if (pxmitpriv->pallocated_frame_buf == NULL) { + if (!pxmitpriv->pallocated_frame_buf) { pxmitpriv->pxmit_frame_buf = NULL; RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); res = _FAIL; @@ -108,7 +108,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); - if (pxmitpriv->pallocated_xmitbuf == NULL) { + if (!pxmitpriv->pallocated_xmitbuf) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); res = _FAIL; goto exit; @@ -149,7 +149,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + if (!pxmitpriv->pallocated_xmit_extbuf) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); res = _FAIL; goto exit; @@ -210,7 +210,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - if (pxmitpriv->pxmit_frame_buf == NULL) + if (!pxmitpriv->pxmit_frame_buf) return; for (i = 0; i < NR_XMITFRAME; i++) { @@ -941,7 +941,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct if (!psta) return _FAIL; - if (pxmitframe->buf_addr == NULL) { + if (!pxmitframe->buf_addr) { DBG_88E("==> %s buf_addr == NULL\n", __func__); return _FAIL; } From 6da0bda8d7949abcddd1dc72befcb9cd40d53c07 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 28 Jul 2018 16:29:16 +0200 Subject: [PATCH 690/903] staging: rtl8188eu: replace tabs with spaces Replace tabs with spaces, clears a checkpatch 'line over 80 characters' warning. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 03b65e9b067a..4265ad84547d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -23,7 +23,7 @@ static void _init_txservq(struct tx_servq *ptxservq) ptxservq->qcnt = 0; } -void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) +void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) { memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv)); spin_lock_init(&psta_xmitpriv->lock); @@ -35,12 +35,12 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) INIT_LIST_HEAD(&psta_xmitpriv->apsd); } -s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) +s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) { int i; struct xmit_buf *pxmitbuf; struct xmit_frame *pxframe; - int res = _SUCCESS; + int res = _SUCCESS; u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; From 8cc7be34c6385dc04e01bc7c25868782e4d2fbd0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 28 Jul 2018 16:29:17 +0200 Subject: [PATCH 691/903] staging: rtl8188eu: remove unused rtw_calculate_wlan_pkt_size_by_attribue() The function rtw_calculate_wlan_pkt_size_by_attribue() also defined as rtw_wlan_pkt_size() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 18 ------------------ drivers/staging/rtl8188eu/include/rtw_xmit.h | 2 -- 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 4265ad84547d..2130d78e0d9f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -892,24 +892,6 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pat return ptxservq->qcnt; } -/* - * Calculate wlan 802.11 packet MAX size from pkt_attrib - * This function doesn't consider fragment case - */ -u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib) -{ - u32 len = 0; - - len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */ - len += SNAP_SIZE + sizeof(u16); /* LLC */ - len += pattrib->pktlen; - if (pattrib->encrypt == _TKIP_) - len += 8; /* MIC */ - len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */ - - return len; -} - /* This sub-routine will perform all the following: diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h index af6485aa6900..788f59c74ea1 100644 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h @@ -326,8 +326,6 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe); -u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib); -#define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib) s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe); s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); From 50c50b975d566e9384c3ae84fc37a997ea18eedd Mon Sep 17 00:00:00 2001 From: Tomas Novotny Date: Wed, 25 Jul 2018 17:18:19 +0200 Subject: [PATCH 692/903] iio: vcnl4000: add VCNL4010 and VCNL4020 device id The driver already supports VCNL4010/20 devices. The currently supported features and detectable product id are the same, so add shared id for them. This is a groundwork to extend the driver by detecting incorrectly specified device id. Signed-off-by: Tomas Novotny Signed-off-by: Jonathan Cameron --- drivers/iio/light/vcnl4000.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 32c0b531395f..980eb3b77d5f 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -48,6 +48,7 @@ enum vcnl4000_device_ids { VCNL4000, + VCNL4010, }; struct vcnl4000_data { @@ -68,6 +69,8 @@ struct vcnl4000_chip_spec { static const struct i2c_device_id vcnl4000_id[] = { { "vcnl4000", VCNL4000 }, + { "vcnl4010", VCNL4010 }, + { "vcnl4020", VCNL4010 }, { } }; MODULE_DEVICE_TABLE(i2c, vcnl4000_id); @@ -157,6 +160,12 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .measure_light = vcnl4000_measure_light, .measure_proximity = vcnl4000_measure_proximity, }, + [VCNL4010] = { + .prod = "VCNL4010/4020", + .init = vcnl4000_init, + .measure_light = vcnl4000_measure_light, + .measure_proximity = vcnl4000_measure_proximity, + }, }; static const struct iio_chan_spec vcnl4000_channels[] = { From 58bf9ace8c91be9b3e75cb001dbc199fae89d106 Mon Sep 17 00:00:00 2001 From: Tomas Novotny Date: Wed, 25 Jul 2018 17:18:20 +0200 Subject: [PATCH 693/903] iio: vcnl4000: warn on incorrectly specified device id We can detect incorrectly specified device id for some chips, so warn user in that case. Signed-off-by: Tomas Novotny Signed-off-by: Jonathan Cameron --- drivers/iio/light/vcnl4000.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 980eb3b77d5f..a0cd1dcbf935 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -84,8 +84,20 @@ static int vcnl4000_init(struct vcnl4000_data *data) return ret; prod_id = ret >> 4; - if (prod_id != VCNL4010_PROD_ID && prod_id != VCNL4000_PROD_ID) + switch (prod_id) { + case VCNL4000_PROD_ID: + if (data->id != VCNL4000) + dev_warn(&data->client->dev, + "wrong device id, use vcnl4000"); + break; + case VCNL4010_PROD_ID: + if (data->id != VCNL4010) + dev_warn(&data->client->dev, + "wrong device id, use vcnl4010/4020"); + break; + default: return -ENODEV; + } data->rev = ret & 0xf; data->al_scale = 250000; From be38866fbb97f0ee2b144ab1de9ee2833a76e0fb Mon Sep 17 00:00:00 2001 From: Tomas Novotny Date: Wed, 25 Jul 2018 17:18:21 +0200 Subject: [PATCH 694/903] iio: vcnl4000: add support for VCNL4200 VCNL4200 is an integrated long distance (up to 1500mm) proximity and ambient light sensor. The support is very basic. There is no configuration of proximity and ambient light sensing yet. Only the reading of both measured values is done. The reading of ambient light and proximity values is blocking. If you request a new value too early, the driver waits for new value to be ready. Signed-off-by: Tomas Novotny Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 5 +- drivers/iio/light/vcnl4000.c | 114 ++++++++++++++++++++++++++++++++--- 2 files changed, 109 insertions(+), 10 deletions(-) diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index f17f701a9b61..d66ea754ffff 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -450,11 +450,12 @@ config US5182D will be called us5182d. config VCNL4000 - tristate "VCNL4000/4010/4020 combined ALS and proximity sensor" + tristate "VCNL4000/4010/4020/4200 combined ALS and proximity sensor" depends on I2C help Say Y here if you want to build a driver for the Vishay VCNL4000, - VCNL4010, VCNL4020 combined ambient light and proximity sensor. + VCNL4010, VCNL4020, VCNL4200 combined ambient light and proximity + sensor. To compile this driver as a module, choose M here: the module will be called vcnl4000. diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index a0cd1dcbf935..04fd0d4b6f19 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -1,5 +1,5 @@ /* - * vcnl4000.c - Support for Vishay VCNL4000/4010/4020 combined ambient + * vcnl4000.c - Support for Vishay VCNL4000/4010/4020/4200 combined ambient * light and proximity sensor * * Copyright 2012 Peter Meerwald @@ -8,13 +8,15 @@ * the GNU General Public License. See the file COPYING in the main * directory of this archive for more details. * - * IIO driver for VCNL4000 (7-bit I2C slave address 0x13) + * IIO driver for: + * VCNL4000/10/20 (7-bit I2C slave address 0x13) + * VCNL4200 (7-bit I2C slave address 0x51) * * TODO: * allow to adjust IR current * proximity threshold and event handling * periodic ALS/proximity measurement (VCNL4010/20) - * interrupts (VCNL4010/20) + * interrupts (VCNL4010/20, VCNL4200) */ #include @@ -28,6 +30,7 @@ #define VCNL4000_DRV_NAME "vcnl4000" #define VCNL4000_PROD_ID 0x01 #define VCNL4010_PROD_ID 0x02 /* for VCNL4020, VCNL4010 */ +#define VCNL4200_PROD_ID 0x58 #define VCNL4000_COMMAND 0x80 /* Command register */ #define VCNL4000_PROD_REV 0x81 /* Product ID and Revision ID */ @@ -40,6 +43,12 @@ #define VCNL4000_PS_MEAS_FREQ 0x89 /* Proximity test signal frequency */ #define VCNL4000_PS_MOD_ADJ 0x8a /* Proximity modulator timing adjustment */ +#define VCNL4200_AL_CONF 0x00 /* Ambient light configuration */ +#define VCNL4200_PS_CONF1 0x03 /* Proximity configuration */ +#define VCNL4200_PS_DATA 0x08 /* Proximity data */ +#define VCNL4200_AL_DATA 0x09 /* Ambient light data */ +#define VCNL4200_DEV_ID 0x0e /* Device ID, slave address and version */ + /* Bit masks for COMMAND register */ #define VCNL4000_AL_RDY BIT(6) /* ALS data ready? */ #define VCNL4000_PS_RDY BIT(5) /* proximity data ready? */ @@ -49,6 +58,14 @@ enum vcnl4000_device_ids { VCNL4000, VCNL4010, + VCNL4200, +}; + +struct vcnl4200_channel { + u8 reg; + ktime_t last_measurement; + ktime_t sampling_rate; + struct mutex lock; }; struct vcnl4000_data { @@ -57,7 +74,9 @@ struct vcnl4000_data { int rev; int al_scale; const struct vcnl4000_chip_spec *chip_spec; - struct mutex lock; + struct mutex vcnl4000_lock; + struct vcnl4200_channel vcnl4200_al; + struct vcnl4200_channel vcnl4200_ps; }; struct vcnl4000_chip_spec { @@ -71,6 +90,7 @@ static const struct i2c_device_id vcnl4000_id[] = { { "vcnl4000", VCNL4000 }, { "vcnl4010", VCNL4010 }, { "vcnl4020", VCNL4010 }, + { "vcnl4200", VCNL4200 }, { } }; MODULE_DEVICE_TABLE(i2c, vcnl4000_id); @@ -101,6 +121,42 @@ static int vcnl4000_init(struct vcnl4000_data *data) data->rev = ret & 0xf; data->al_scale = 250000; + mutex_init(&data->vcnl4000_lock); + + return 0; +}; + +static int vcnl4200_init(struct vcnl4000_data *data) +{ + int ret; + + ret = i2c_smbus_read_word_data(data->client, VCNL4200_DEV_ID); + if (ret < 0) + return ret; + + if ((ret & 0xff) != VCNL4200_PROD_ID) + return -ENODEV; + + data->rev = (ret >> 8) & 0xf; + + /* Set defaults and enable both channels */ + ret = i2c_smbus_write_byte_data(data->client, VCNL4200_AL_CONF, 0x00); + if (ret < 0) + return ret; + ret = i2c_smbus_write_byte_data(data->client, VCNL4200_PS_CONF1, 0x00); + if (ret < 0) + return ret; + + data->al_scale = 24000; + data->vcnl4200_al.reg = VCNL4200_AL_DATA; + data->vcnl4200_ps.reg = VCNL4200_PS_DATA; + /* Integration time is 50ms, but the experiments show 54ms in total. */ + data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000); + data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000); + data->vcnl4200_al.last_measurement = ktime_set(0, 0); + data->vcnl4200_ps.last_measurement = ktime_set(0, 0); + mutex_init(&data->vcnl4200_al.lock); + mutex_init(&data->vcnl4200_ps.lock); return 0; }; @@ -112,7 +168,7 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask, __be16 buf; int ret; - mutex_lock(&data->lock); + mutex_lock(&data->vcnl4000_lock); ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND, req_mask); @@ -141,16 +197,43 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask, if (ret < 0) goto fail; - mutex_unlock(&data->lock); + mutex_unlock(&data->vcnl4000_lock); *val = be16_to_cpu(buf); return 0; fail: - mutex_unlock(&data->lock); + mutex_unlock(&data->vcnl4000_lock); return ret; } +static int vcnl4200_measure(struct vcnl4000_data *data, + struct vcnl4200_channel *chan, int *val) +{ + int ret; + s64 delta; + ktime_t next_measurement; + + mutex_lock(&chan->lock); + + next_measurement = ktime_add(chan->last_measurement, + chan->sampling_rate); + delta = ktime_us_delta(next_measurement, ktime_get()); + if (delta > 0) + usleep_range(delta, delta + 500); + chan->last_measurement = ktime_get(); + + mutex_unlock(&chan->lock); + + ret = i2c_smbus_read_word_data(data->client, chan->reg); + if (ret < 0) + return ret; + + *val = ret; + + return 0; +} + static int vcnl4000_measure_light(struct vcnl4000_data *data, int *val) { return vcnl4000_measure(data, @@ -158,6 +241,11 @@ static int vcnl4000_measure_light(struct vcnl4000_data *data, int *val) VCNL4000_AL_RESULT_HI, val); } +static int vcnl4200_measure_light(struct vcnl4000_data *data, int *val) +{ + return vcnl4200_measure(data, &data->vcnl4200_al, val); +} + static int vcnl4000_measure_proximity(struct vcnl4000_data *data, int *val) { return vcnl4000_measure(data, @@ -165,6 +253,11 @@ static int vcnl4000_measure_proximity(struct vcnl4000_data *data, int *val) VCNL4000_PS_RESULT_HI, val); } +static int vcnl4200_measure_proximity(struct vcnl4000_data *data, int *val) +{ + return vcnl4200_measure(data, &data->vcnl4200_ps, val); +} + static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { [VCNL4000] = { .prod = "VCNL4000", @@ -178,6 +271,12 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .measure_light = vcnl4000_measure_light, .measure_proximity = vcnl4000_measure_proximity, }, + [VCNL4200] = { + .prod = "VCNL4200", + .init = vcnl4200_init, + .measure_light = vcnl4200_measure_light, + .measure_proximity = vcnl4200_measure_proximity, + }, }; static const struct iio_chan_spec vcnl4000_channels[] = { @@ -246,7 +345,6 @@ static int vcnl4000_probe(struct i2c_client *client, data->client = client; data->id = id->driver_data; data->chip_spec = &vcnl4000_chip_spec_cfg[data->id]; - mutex_init(&data->lock); ret = data->chip_spec->init(data); if (ret < 0) From 0a8460966fc28c3c25160c34da055e9a8a0c90a1 Mon Sep 17 00:00:00 2001 From: Manish Narani Date: Mon, 23 Jul 2018 20:32:00 +0530 Subject: [PATCH 695/903] iio: adc: xilinx: Check for return values in clk related functions This patch adds check for return values from clock related functions. This was reported by static code analysis tool. Signed-off-by: Manish Narani Signed-off-by: Jonathan Cameron --- drivers/iio/adc/xilinx-xadc-core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 0127e8513166..23395fc5b267 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -340,6 +340,8 @@ static int xadc_zynq_setup(struct platform_device *pdev, xadc->zynq_intmask = ~0; pcap_rate = clk_get_rate(xadc->clk); + if (!pcap_rate) + return -EINVAL; if (tck_rate > pcap_rate / 2) { div = 2; @@ -887,6 +889,9 @@ static int xadc_write_raw(struct iio_dev *indio_dev, unsigned long clk_rate = xadc_get_dclk_rate(xadc); unsigned int div; + if (!clk_rate) + return -EINVAL; + if (info != IIO_CHAN_INFO_SAMP_FREQ) return -EINVAL; @@ -1237,8 +1242,10 @@ static int xadc_probe(struct platform_device *pdev) goto err_free_irq; /* Disable all alarms */ - xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK, - XADC_CONF1_ALARM_MASK); + ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK, + XADC_CONF1_ALARM_MASK); + if (ret) + goto err_free_irq; /* Set thresholds to min/max */ for (i = 0; i < 16; i++) { From 81f5471838c279c97f0b46f18e766c2ac0de8806 Mon Sep 17 00:00:00 2001 From: Manish Narani Date: Mon, 23 Jul 2018 20:32:01 +0530 Subject: [PATCH 696/903] iio: adc: xilinx: limit pcap clock frequency value This patch limits the xadc pcap clock frequency value to be less than 200MHz. This fixes the issue when zynq is booted at higher frequency values, pcap crosses the maximum limit of 200MHz(Fmax) as it is derived from IOPLL. If this limit is crossed it is required to alter the WEDGE and REDGE bits of XADC_CFG register to make timings better in the interface. So to avoid alteration of these bits every time, the pcap value should not cross the Fmax limit. Signed-off-by: Manish Narani Signed-off-by: Jonathan Cameron --- drivers/iio/adc/xilinx-xadc-core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 23395fc5b267..0dd306d2c7f1 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -322,6 +322,7 @@ static irqreturn_t xadc_zynq_interrupt_handler(int irq, void *devid) #define XADC_ZYNQ_TCK_RATE_MAX 50000000 #define XADC_ZYNQ_IGAP_DEFAULT 20 +#define XADC_ZYNQ_PCAP_RATE_MAX 200000000 static int xadc_zynq_setup(struct platform_device *pdev, struct iio_dev *indio_dev, int irq) @@ -332,6 +333,7 @@ static int xadc_zynq_setup(struct platform_device *pdev, unsigned int div; unsigned int igap; unsigned int tck_rate; + int ret; /* TODO: Figure out how to make igap and tck_rate configurable */ igap = XADC_ZYNQ_IGAP_DEFAULT; @@ -343,6 +345,13 @@ static int xadc_zynq_setup(struct platform_device *pdev, if (!pcap_rate) return -EINVAL; + if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) { + ret = clk_set_rate(xadc->clk, + (unsigned long)XADC_ZYNQ_PCAP_RATE_MAX); + if (ret) + return ret; + } + if (tck_rate > pcap_rate / 2) { div = 2; } else { @@ -368,6 +377,12 @@ static int xadc_zynq_setup(struct platform_device *pdev, XADC_ZYNQ_CFG_REDGE | XADC_ZYNQ_CFG_WEDGE | tck_div | XADC_ZYNQ_CFG_IGAP(igap)); + if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) { + ret = clk_set_rate(xadc->clk, pcap_rate); + if (ret) + return ret; + } + return 0; } From 50e8e9f3096bd4e9ce2f42da11f3824358a826a7 Mon Sep 17 00:00:00 2001 From: Manish Narani Date: Mon, 23 Jul 2018 20:32:02 +0530 Subject: [PATCH 697/903] iio: adc: xilinx: Remove platform_get_irq from xadc_remove function This patch avoids getting irq number in xadc_remove function. Instead store 'irq' in xadc struct and use xadc->irq wherever needed. This patch also resolves a warning reported by coverity where it asks to check return value of platform_get_irq() for any errors in xadc_remove. Signed-off-by: Manish Narani Signed-off-by: Jonathan Cameron --- drivers/iio/adc/xilinx-xadc-core.c | 10 +++++----- drivers/iio/adc/xilinx-xadc.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 0dd306d2c7f1..44a25198387d 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -1175,6 +1175,7 @@ static int xadc_probe(struct platform_device *pdev) xadc = iio_priv(indio_dev); xadc->ops = id->data; + xadc->irq = irq; init_completion(&xadc->completion); mutex_init(&xadc->mutex); spin_lock_init(&xadc->lock); @@ -1225,11 +1226,11 @@ static int xadc_probe(struct platform_device *pdev) if (ret) goto err_free_samplerate_trigger; - ret = xadc->ops->setup(pdev, indio_dev, irq); + ret = xadc->ops->setup(pdev, indio_dev, xadc->irq); if (ret) goto err_clk_disable_unprepare; - ret = request_irq(irq, xadc->ops->interrupt_handler, 0, + ret = request_irq(xadc->irq, xadc->ops->interrupt_handler, 0, dev_name(&pdev->dev), indio_dev); if (ret) goto err_clk_disable_unprepare; @@ -1288,7 +1289,7 @@ static int xadc_probe(struct platform_device *pdev) return 0; err_free_irq: - free_irq(irq, indio_dev); + free_irq(xadc->irq, indio_dev); err_clk_disable_unprepare: clk_disable_unprepare(xadc->clk); err_free_samplerate_trigger: @@ -1310,7 +1311,6 @@ static int xadc_remove(struct platform_device *pdev) { struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct xadc *xadc = iio_priv(indio_dev); - int irq = platform_get_irq(pdev, 0); iio_device_unregister(indio_dev); if (xadc->ops->flags & XADC_FLAGS_BUFFERED) { @@ -1318,7 +1318,7 @@ static int xadc_remove(struct platform_device *pdev) iio_trigger_free(xadc->convst_trigger); iio_triggered_buffer_cleanup(indio_dev); } - free_irq(irq, indio_dev); + free_irq(xadc->irq, indio_dev); clk_disable_unprepare(xadc->clk); cancel_delayed_work(&xadc->zynq_unmask_work); kfree(xadc->data); diff --git a/drivers/iio/adc/xilinx-xadc.h b/drivers/iio/adc/xilinx-xadc.h index 62edbdae1244..8c0009585c16 100644 --- a/drivers/iio/adc/xilinx-xadc.h +++ b/drivers/iio/adc/xilinx-xadc.h @@ -68,6 +68,7 @@ struct xadc { spinlock_t lock; struct completion completion; + int irq; }; struct xadc_ops { From 2fa03b92b62982c420c9c77a58bda52b96ed8ba4 Mon Sep 17 00:00:00 2001 From: Manish Narani Date: Mon, 23 Jul 2018 20:32:03 +0530 Subject: [PATCH 698/903] iio: adc: xilinx: Move request_irq before enabling interrupts Enabling the Interrupts before registering the irq handler is a bad idea. This patch corrects the same for XADC driver. Signed-off-by: Manish Narani Signed-off-by: Jonathan Cameron --- drivers/iio/adc/xilinx-xadc-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 44a25198387d..3f6be5ac049a 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -1226,15 +1226,15 @@ static int xadc_probe(struct platform_device *pdev) if (ret) goto err_free_samplerate_trigger; - ret = xadc->ops->setup(pdev, indio_dev, xadc->irq); - if (ret) - goto err_clk_disable_unprepare; - ret = request_irq(xadc->irq, xadc->ops->interrupt_handler, 0, dev_name(&pdev->dev), indio_dev); if (ret) goto err_clk_disable_unprepare; + ret = xadc->ops->setup(pdev, indio_dev, xadc->irq); + if (ret) + goto err_free_irq; + for (i = 0; i < 16; i++) xadc_read_adc_reg(xadc, XADC_REG_THRESHOLD(i), &xadc->threshold[i]); From b9f13084580c9032ba7c505da2c6c075f176472a Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Sun, 29 Jul 2018 19:19:26 +0800 Subject: [PATCH 699/903] staging: fix platform_no_drv_owner.cocci warnings drivers/staging/axis-fifo/axis-fifo.c:1081:3-8: No need to set .owner here. The core will do it. Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Fixes: 4a965c5f89de ("staging: add driver for Xilinx AXI-Stream FIFO v4.1 IP core") CC: Jacob Feder Signed-off-by: kbuild test robot Signed-off-by: Greg Kroah-Hartman --- drivers/staging/axis-fifo/axis-fifo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index 51a081df5741..abeee0ecc122 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -1078,7 +1078,6 @@ MODULE_DEVICE_TABLE(of, axis_fifo_of_match); static struct platform_driver axis_fifo_driver = { .driver = { .name = DRIVER_NAME, - .owner = THIS_MODULE, .of_match_table = axis_fifo_of_match, }, .probe = axis_fifo_probe, From 38c6aa2175c35358d01c29266000d26c78af9e36 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 30 Jul 2018 09:51:01 +0800 Subject: [PATCH 700/903] staging: erofs: use the wrapped PTR_ERR_OR_ZERO instead of open code Just clean up and logic doesn't change. Link: https://lists.01.org/pipermail/kbuild-all/2018-July/050766.html Fixes: d72d1ce60174 ("staging: erofs: add namei functions") Reported-by: kbuild test robot Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c index d2a0da3b1e44..546a47156101 100644 --- a/drivers/staging/erofs/namei.c +++ b/drivers/staging/erofs/namei.c @@ -195,7 +195,7 @@ int erofs_namei(struct inode *dir, kunmap_atomic(data); put_page(page); - return IS_ERR(de) ? PTR_ERR(de) : 0; + return PTR_ERR_OR_ZERO(de); } /* NOTE: i_mutex is already held by vfs */ From c7346797f5fb7be8e139fbeb1324669e7cb2ef9a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 30 Jul 2018 10:46:03 +0200 Subject: [PATCH 701/903] Revert "staging:r8188eu: Use lib80211 to encrypt (TKIP) tx frames" This reverts commit 0d4876f4e977798238db594321db9184704fcf5d as it breaks the build once 4.18-rc7 was merged into the staging-next tree. Cc: Ivan Safonov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 429 ++++++++++++++---- 1 file changed, 347 insertions(+), 82 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index add033114863..da5f308f9e30 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -12,6 +12,121 @@ #include #include +/* WEP related ===== */ + +#define CRC32_POLY 0x04c11db7 + +struct arc4context { + u32 x; + u32 y; + u8 state[256]; +}; + +static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) +{ + u32 t, u; + u32 keyindex; + u32 stateindex; + u8 *state; + u32 counter; + + state = parc4ctx->state; + parc4ctx->x = 0; + parc4ctx->y = 0; + for (counter = 0; counter < 256; counter++) + state[counter] = (u8)counter; + keyindex = 0; + stateindex = 0; + for (counter = 0; counter < 256; counter++) { + t = state[counter]; + stateindex = (stateindex + key[keyindex] + t) & 0xff; + u = state[stateindex]; + state[stateindex] = (u8)t; + state[counter] = (u8)u; + if (++keyindex >= key_len) + keyindex = 0; + } +} + +static u32 arcfour_byte(struct arc4context *parc4ctx) +{ + u32 x; + u32 y; + u32 sx, sy; + u8 *state; + + state = parc4ctx->state; + x = (parc4ctx->x + 1) & 0xff; + sx = state[x]; + y = (sx + parc4ctx->y) & 0xff; + sy = state[y]; + parc4ctx->x = x; + parc4ctx->y = y; + state[y] = (u8)sx; + state[x] = (u8)sy; + return state[(sx + sy) & 0xff]; +} + +static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) +{ + u32 i; + + for (i = 0; i < len; i++) + dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); +} + +static int bcrc32initialized; +static u32 crc32_table[256]; + +static u8 crc32_reverseBit(u8 data) +{ + return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) | + ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) | + ((data>>5)&0x02) | ((data>>7)&0x01); +} + +static void crc32_init(void) +{ + if (bcrc32initialized == 1) { + return; + } else { + int i, j; + u32 c; + u8 *p = (u8 *)&c, *p1; + u8 k; + + c = 0x12340000; + + for (i = 0; i < 256; ++i) { + k = crc32_reverseBit((u8)i); + for (c = ((u32)k) << 24, j = 8; j > 0; --j) + c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); + p1 = (u8 *)&crc32_table[i]; + + p1[0] = crc32_reverseBit(p[3]); + p1[1] = crc32_reverseBit(p[2]); + p1[2] = crc32_reverseBit(p[1]); + p1[3] = crc32_reverseBit(p[0]); + } + bcrc32initialized = 1; + } +} + +static __le32 getcrc32(u8 *buf, int len) +{ + u8 *p; + u32 crc; + + if (bcrc32initialized == 0) + crc32_init(); + + crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ + + for (p = buf; len > 0; ++p, --len) + crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); + return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ +} + /* Need to consider the fragment situation */ @@ -280,24 +395,202 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod #define P1K_SIZE 10 /* 80-bit Phase1 key */ #define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */ +/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */ +static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) */ +{ + 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, + 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, + 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, + 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, + 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, + 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, + 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, + 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, + 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, + 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, + 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, + 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, + 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, + 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, + 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, + 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, + 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, + 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, + 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, + 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, + 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, + 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, + 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, + 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, + 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, + 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, + 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, + 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, + 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, + 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, + 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, + 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, + }, + + { /* second half of table is unsigned char-reversed version of first! */ + 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, + 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, + 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, + 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, + 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, + 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, + 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, + 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, + 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, + 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, + 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, + 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, + 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, + 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, + 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, + 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, + 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, + 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, + 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, + 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, + 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, + 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, + 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, + 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, + 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, + 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, + 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, + 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, + 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, + 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, + 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, + 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C, + } +}; + + /* +********************************************************************** +* Routine: Phase 1 -- generate P1K, given TA, TK, IV32 +* +* Inputs: +* tk[] = temporal key [128 bits] +* ta[] = transmitter's MAC address [ 48 bits] +* iv32 = upper 32 bits of IV [ 32 bits] +* Output: +* p1k[] = Phase 1 key [ 80 bits] +* +* Note: +* This function only needs to be called every 2**16 packets, +* although in theory it could be called every packet. +* +********************************************************************** +*/ +static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) +{ + int i; + /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ + p1k[0] = Lo16(iv32); + p1k[1] = Hi16(iv32); + p1k[2] = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */ + p1k[3] = Mk16(ta[3], ta[2]); + p1k[4] = Mk16(ta[5], ta[4]); + + /* Now compute an unbalanced Feistel cipher with 80-bit block */ + /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ + for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */ + p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); + p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); + p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); + p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6)); + p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); + p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ + } +} + +/* +********************************************************************** +* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16 +* +* Inputs: +* tk[] = Temporal key [128 bits] +* p1k[] = Phase 1 output key [ 80 bits] +* iv16 = low 16 bits of IV counter [ 16 bits] +* Output: +* rc4key[] = the key used to encrypt the packet [128 bits] +* +* Note: +* The value {TA, IV32, IV16} for Phase1/Phase2 must be unique +* across all packets using the same key TK value. Then, for a +* given value of TK[], this TKIP48 construction guarantees that +* the final RC4KEY value is unique across all packets. +* +* Suggested implementation optimization: if PPK[] is "overlaid" +* appropriately on RC4KEY[], there is no need for the final +* for loop below that copies the PPK[] result into RC4KEY[]. +* +********************************************************************** +*/ +static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) +{ + int i; + u16 PPK[6]; /* temporary key for mixing */ + /* Note: all adds in the PPK[] equations below are mod 2**16 */ + for (i = 0; i < 5; i++) + PPK[i] = p1k[i]; /* first, copy P1K to PPK */ + PPK[5] = p1k[4] + iv16; /* next, add in IV16 */ + + /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ + PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */ + PPK[1] += _S_(PPK[0] ^ TK16(1)); + PPK[2] += _S_(PPK[1] ^ TK16(2)); + PPK[3] += _S_(PPK[2] ^ TK16(3)); + PPK[4] += _S_(PPK[3] ^ TK16(4)); + PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */ + + /* Final sweep: bijective, "linear". Rotates kill LSB correlations */ + PPK[0] += RotR1(PPK[5] ^ TK16(6)); + PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */ + PPK[2] += RotR1(PPK[1]); + PPK[3] += RotR1(PPK[2]); + PPK[4] += RotR1(PPK[3]); + PPK[5] += RotR1(PPK[4]); + /* Note: At this point, for a given key TK[0..15], the 96-bit output */ + /* value PPK[0..5] is guaranteed to be unique, as a function */ + /* of the 96-bit "input" value {TA, IV32, IV16}. That is, P1K */ + /* is now a keyed permutation of {TA, IV32, IV16}. */ + + /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key */ + rc4key[0] = Hi8(iv16); /* RC4KEY[0..2] is the WEP IV */ + rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */ + rc4key[2] = Lo8(iv16); + rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); + + /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ + for (i = 0; i < 6; i++) { + rc4key[4+2*i] = Lo8(PPK[i]); + rc4key[5+2*i] = Hi8(PPK[i]); + } +} + /* The hlen isn't include the IV */ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) -{ +{ /* exclude ICV */ + u16 pnl; + u32 pnh; + u8 rc4key[16]; + u8 ttkey[16]; + u8 crc[4]; u8 hw_hdr_offset = 0; + struct arc4context mycontext; int curfragnum, length; - u8 *pframe; + u8 *pframe, *payload, *iv, *prwskey; + union pn48 dot11txpn; struct sta_info *stainfo; struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; - void *crypto_private; - struct sk_buff *skb; - u8 key[32]; - int key_idx; - const int key_length = 32; - struct lib80211_crypto_ops *crypto_ops; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -306,85 +599,57 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt != _TKIP_) - return res; - - if (pattrib->psta) - stainfo = pattrib->psta; - else - stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - - if (!stainfo) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); - return _FAIL; - } - - crypto_ops = try_then_request_module(lib80211_get_crypto_ops("TKIP"), "lib80211_crypt_tkip"); - - if (IS_MCAST(pattrib->ra)) { - key_idx = psecuritypriv->dot118021XGrpKeyid; - memcpy(key, psecuritypriv->dot118021XGrpKey[key_idx].skey, 16); - memcpy(key + 16, psecuritypriv->dot118021XGrptxmickey[key_idx].skey, 16); - } else { - key_idx = 0; - memcpy(key, stainfo->dot118021x_UncstKey.skey, 16); - memcpy(key + 16, stainfo->dot11tkiptxmickey.skey, 16); - } - - if (!crypto_ops) { - res = _FAIL; - goto exit; - } - - crypto_private = crypto_ops->init(key_idx); - if (!crypto_private) { - res = _FAIL; - goto exit; - } - - if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) { - res = _FAIL; - goto exit_crypto_ops_deinit; - } - - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); - - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if ((curfragnum+1) == pattrib->nr_frags) - length = pattrib->last_txcmdsz; + if (pattrib->encrypt == _TKIP_) { + if (pattrib->psta) + stainfo = pattrib->psta; else - length = pxmitpriv->frag_len; + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - skb = dev_alloc_skb(length); - if (!skb) { + if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); + + if (IS_MCAST(pattrib->ra)) + prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + iv = pframe+pattrib->hdrlen; + payload = pframe+pattrib->iv_len+pattrib->hdrlen; + + GET_TKIP_PN(iv, dot11txpn); + + pnl = (u16)(dot11txpn.val); + pnh = (u32)(dot11txpn.val>>16); + phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); + phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); + + if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + RT_TRACE(_module_rtl871x_security_c_, _drv_info_, + ("pattrib->iv_len=%x, pattrib->icv_len=%x\n", + pattrib->iv_len, pattrib->icv_len)); + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + } else { + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + + pframe += pxmitpriv->frag_len; + pframe = (u8 *)round_up((size_t)(pframe), 4); + } + } + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); res = _FAIL; - goto exit_crypto_ops_deinit; } - - skb_put_data(skb, pframe, length); - - memmove(skb->data + pattrib->iv_len, skb->data, pattrib->hdrlen); - skb_pull(skb, pattrib->iv_len); - skb_trim(skb, skb->len - pattrib->icv_len); - - if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, crypto_private)) { - kfree_skb(skb); - res = _FAIL; - goto exit_crypto_ops_deinit; - } - - memcpy(pframe, skb->data, skb->len); - - pframe += skb->len; - pframe = (u8 *)round_up((size_t)(pframe), 4); - - kfree_skb(skb); } - -exit_crypto_ops_deinit: - crypto_ops->deinit(crypto_private); - -exit: return res; } From 8dd8a48b9a7dae5493494a8603adddfdf1914716 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:34 -0700 Subject: [PATCH 702/903] staging: gasket: core: hold reference to pci_dev while used Hold a reference on the struct pci_dev while a pointer to it is held in the gasket data structures. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 2b484d067c38..b832a4f529f2 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -488,6 +488,7 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev) internal_desc->devs[gasket_dev->dev_idx] = NULL; mutex_unlock(&internal_desc->mutex); put_device(gasket_dev->dev); + pci_dev_put(gasket_dev->pci_dev); kfree(gasket_dev); } @@ -565,6 +566,7 @@ static int gasket_pci_probe( ret = gasket_alloc_dev(internal_desc, parent, &gasket_dev, kobj_name); if (ret) return ret; + gasket_dev->pci_dev = pci_dev_get(pci_dev); if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) { pr_err("Cannot create %s device %s [ret = %ld]\n", driver_desc->name, gasket_dev->dev_info.name, @@ -572,7 +574,6 @@ static int gasket_pci_probe( ret = -ENODEV; goto fail1; } - gasket_dev->pci_dev = pci_dev; ret = gasket_setup_pci(pci_dev, gasket_dev); if (ret) @@ -703,7 +704,6 @@ static int gasket_setup_pci( { int i, mapped_bars, ret; - gasket_dev->pci_dev = pci_dev; ret = pci_enable_device(pci_dev); if (ret) { dev_err(gasket_dev->dev, "cannot enable PCI device\n"); From 34cf3ea8dae7f0aa2ab544c1d30a803016af779e Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:35 -0700 Subject: [PATCH 703/903] staging: gasket: sysfs: hold reference to device while in use Hold a reference to the struct device while a gasket sysfs mapping exists for the device and a pointer to the struct is kept in the mapping data structures. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index da972ce0e0db..fde04658419b 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -126,6 +126,7 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) kfree(mapping->attributes); mapping->attributes = NULL; mapping->attribute_count = 0; + put_device(mapping->device); mapping->device = NULL; mapping->gasket_dev = NULL; } @@ -208,22 +209,20 @@ int gasket_sysfs_create_mapping( device->kobj.name); mapping = &dev_mappings[map_idx]; - kref_init(&mapping->refcount); - mapping->device = device; - mapping->gasket_dev = gasket_dev; mapping->attributes = kcalloc(GASKET_SYSFS_MAX_NODES, sizeof(*mapping->attributes), GFP_KERNEL); - mapping->attribute_count = 0; if (!mapping->attributes) { dev_dbg(device, "Unable to allocate sysfs attribute array\n"); - mapping->device = NULL; - mapping->gasket_dev = NULL; mutex_unlock(&mapping->mutex); mutex_unlock(&function_mutex); return -ENOMEM; } + kref_init(&mapping->refcount); + mapping->device = get_device(device); + mapping->gasket_dev = gasket_dev; + mapping->attribute_count = 0; mutex_unlock(&mapping->mutex); mutex_unlock(&function_mutex); From dd9d1502feea3c23d412f289aad79e1d4e86d45d Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:36 -0700 Subject: [PATCH 704/903] staging: gasket: page table: hold references to device and pci_dev Hold references to the struct device and the pci_dev for the page table while the data structures contian pointers to these. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index b9304d221722..6b946a155ee3 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -345,8 +345,8 @@ int gasket_page_table_init( bar_data->virt_base[page_table_config->base_reg]); pg_tbl->extended_offset_reg = (u64 __iomem *)&( bar_data->virt_base[page_table_config->extended_reg]); - pg_tbl->device = device; - pg_tbl->pci_dev = pci_dev; + pg_tbl->device = get_device(device); + pg_tbl->pci_dev = pci_dev_get(pci_dev); dev_dbg(device, "Page table initialized successfully\n"); @@ -364,6 +364,8 @@ void gasket_page_table_cleanup(struct gasket_page_table *pg_tbl) vfree(pg_tbl->entries); pg_tbl->entries = NULL; + put_device(pg_tbl->device); + pci_dev_put(pg_tbl->pci_dev); kfree(pg_tbl); } From f9a4963019291b8ea7f2bb473b2caa7ff2238633 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:37 -0700 Subject: [PATCH 705/903] staging: gasket: core: allow root access based on user namespace Use user namespace to determine whether gasket device file opener is root, allowing root access to containers, if necessary. Reported-by: Dmitry Torokhov Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index b832a4f529f2..291cd6d074a2 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -13,13 +13,16 @@ #include "gasket_page_table.h" #include "gasket_sysfs.h" +#include #include #include #include #include #include #include +#include #include +#include #ifdef GASKET_KERNEL_TRACE_SUPPORT #define CREATE_TRACE_POINTS @@ -1064,7 +1067,8 @@ static int gasket_open(struct inode *inode, struct file *filp) char task_name[TASK_COMM_LEN]; struct gasket_cdev_info *dev_info = container_of(inode->i_cdev, struct gasket_cdev_info, cdev); - int is_root = capable(CAP_SYS_ADMIN); + struct pid_namespace *pid_ns = task_active_pid_ns(current); + int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; @@ -1147,6 +1151,8 @@ static int gasket_release(struct inode *inode, struct file *file) char task_name[TASK_COMM_LEN]; struct gasket_cdev_info *dev_info = container_of(inode->i_cdev, struct gasket_cdev_info, cdev); + struct pid_namespace *pid_ns = task_active_pid_ns(current); + int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; @@ -1158,7 +1164,7 @@ static int gasket_release(struct inode *inode, struct file *file) "Releasing device node. Call origin: tgid %u (%s) " "(f_mode: 0%03o, fmode_write: %d, is_root: %u)\n", current->tgid, task_name, file->f_mode, - (file->f_mode & FMODE_WRITE), capable(CAP_SYS_ADMIN)); + (file->f_mode & FMODE_WRITE), is_root); dev_dbg(gasket_dev->dev, "Current open count (owning tgid %u): %d\n", ownership->owner, ownership->write_open_count); From 904bb9ccf3a908840f3d5e88b4cd07f30c49959a Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:38 -0700 Subject: [PATCH 706/903] staging: gasket: apex: simplify comments for static functions Static functions don't need kernel doc formatting, can be simplified. Reformat comments that can be single-line. Remove extraneous text. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 64 +++++----------------------- 1 file changed, 10 insertions(+), 54 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index ab466d49608a..a75676475177 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -378,34 +378,20 @@ static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev) gasket_dev->dev_info.device, apex_sysfs_attrs); } -/* On device open, we want to perform a core reinit reset. */ +/* On device open, perform a core reinit reset. */ static int apex_device_open_cb(struct gasket_dev *gasket_dev) { return gasket_reset_nolock(gasket_dev, APEX_CHIP_REINIT_RESET); } -/** - * apex_get_status - Set device status. - * @dev: Apex device struct. - * - * Description: Check the device status registers and set the driver status - * to ALIVE or DEAD. - * - * Returns 0 if status is ALIVE, a negative error number otherwise. - */ +/* Check the device status registers and return device status ALIVE or DEAD. */ static int apex_get_status(struct gasket_dev *gasket_dev) { /* TODO: Check device status. */ return GASKET_STATUS_ALIVE; } -/** - * apex_device_cleanup - Clean up Apex HW after close. - * @gasket_dev: Gasket device pointer. - * - * Description: Resets the Apex hardware. Called on final close via - * device_close_cb. - */ +/* Reset the Apex hardware. Called on final close via device_close_cb. */ static int apex_device_cleanup(struct gasket_dev *gasket_dev) { u64 scalar_error; @@ -429,14 +415,7 @@ static int apex_device_cleanup(struct gasket_dev *gasket_dev) return ret; } -/** - * apex_reset - Quits reset. - * @gasket_dev: Gasket device pointer. - * - * Description: Resets the hardware, then quits reset. - * Called on device open. - * - */ +/* Reset the hardware, then quit reset. Called on device open. */ static int apex_reset(struct gasket_dev *gasket_dev, uint type) { int ret; @@ -459,9 +438,7 @@ static int apex_reset(struct gasket_dev *gasket_dev, uint type) return ret; } -/* - * Enters GCB reset state. - */ +/* Enter GCB reset state. */ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) { if (bypass_top_level) @@ -516,9 +493,7 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) return 0; } -/* - * Quits GCB reset state. - */ +/* Quit GCB reset state. */ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) { u32 val0, val1; @@ -601,9 +576,7 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) return 0; } -/* - * Determines if GCB is in reset state. - */ +/* Determine if GCB is in reset state. */ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) { u32 val = gasket_dev_read_32( @@ -615,9 +588,6 @@ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) /* * Check permissions for Apex ioctls. - * @file: File pointer from ioctl. - * @cmd: ioctl command. - * * Returns true if the current user may execute this ioctl, and false otherwise. */ static bool apex_ioctl_check_permissions(struct file *filp, uint cmd) @@ -625,9 +595,7 @@ static bool apex_ioctl_check_permissions(struct file *filp, uint cmd) return !!(filp->f_mode & FMODE_WRITE); } -/* - * Apex-specific ioctl handler. - */ +/* Apex-specific ioctl handler. */ static long apex_ioctl(struct file *filp, uint cmd, void __user *argp) { struct gasket_dev *gasket_dev = filp->private_data; @@ -643,11 +611,7 @@ static long apex_ioctl(struct file *filp, uint cmd, void __user *argp) } } -/* - * Gates or un-gates Apex clock. - * @gasket_dev: Gasket device pointer. - * @argp: User ioctl arg, pointer to a apex_gate_clock_ioctl struct. - */ +/* Gates or un-gates Apex clock. */ static long apex_clock_gating(struct gasket_dev *gasket_dev, struct apex_gate_clock_ioctl __user *argp) { @@ -681,15 +645,7 @@ static long apex_clock_gating(struct gasket_dev *gasket_dev, return 0; } -/* - * Display driver sysfs entries. - * @device: Kernel device structure. - * @attr: Attribute to display. - * @buf: Buffer to which to write output. - * - * Description: Looks up the driver data and file-specific attribute data (the - * type of the attribute), then fills "buf" accordingly. - */ +/* Display driver sysfs entries. */ static ssize_t sysfs_show( struct device *device, struct device_attribute *attr, char *buf) { From f975c995e76be54c14fd742b816bc1b2123e625d Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:39 -0700 Subject: [PATCH 707/903] staging: gasket: core: simplify comments for static functions Static functions don't need kernel doc formatting, can be simplified. Reformat comments that can be single-line. Remove extraneous text. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 151 ++++++--------------------- 1 file changed, 31 insertions(+), 120 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 291cd6d074a2..c00774059f9e 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -199,11 +199,7 @@ MODULE_AUTHOR("Rob Springer "); module_init(gasket_init); module_exit(gasket_exit); -/* - * Perform a standard Gasket callback. - * @gasket_dev: Device specific pointer to forward. - * @cb_function: Standard callback to perform. - */ +/* Perform a standard Gasket callback. */ static inline int check_and_invoke_callback( struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) { @@ -219,13 +215,7 @@ static inline int check_and_invoke_callback( return ret; } -/* - * Perform a standard Gasket callback - * without grabbing gasket_dev->mutex. - * @gasket_dev: Device specific pointer to forward. - * @cb_function: Standard callback to perform. - * - */ +/* Perform a standard Gasket callback without grabbing gasket_dev->mutex. */ static inline int gasket_check_and_invoke_callback_nolock( struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) { @@ -240,9 +230,8 @@ static inline int gasket_check_and_invoke_callback_nolock( } /* - * Returns nonzero if the gasket_cdev_info is owned by the current thread group + * Return nonzero if the gasket_cdev_info is owned by the current thread group * ID. - * @info: Device node info. */ static int gasket_owned_by_current_tgid(struct gasket_cdev_info *info) { @@ -410,14 +399,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) } EXPORT_SYMBOL(gasket_unregister_device); -/** - * Allocate a Gasket device. - * @internal_desc: Pointer to the internal data for the device driver. - * @pdev: Pointer to the Gasket device pointer, the allocated device. - * @kobj_name: PCIe name for the device - * - * Description: Allocates and initializes a Gasket device structure. - * Adds the device to the device list. +/* + * Allocate and initialize a Gasket device structure, add the device to the + * device list. * * Returns 0 if successful, a negative error code otherwise. */ @@ -476,13 +460,7 @@ static int gasket_alloc_dev( return 0; } -/* - * Free a Gasket device. - * @internal_dev: Gasket device pointer; the device to unregister and free. - * - * Description: Removes the device from the device list and frees - * the Gasket device structure. - */ +/* Free a Gasket device. */ static void gasket_free_dev(struct gasket_dev *gasket_dev) { struct gasket_internal_desc *internal_desc = gasket_dev->internal_desc; @@ -496,7 +474,7 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev) } /* - * Finds the next free gasket_internal_dev slot. + * Find the next free gasket_internal_dev slot. * * Returns the located slot number on success or a negative number on failure. */ @@ -533,10 +511,8 @@ static int gasket_find_dev_slot( return i; } -/** +/* * PCI subsystem probe function. - * @pci_dev: PCI device pointer to the new device. - * @id: PCI device id structure pointer, the vendor and device ids. * * Called when a Gasket device is found. Allocates device metadata, maps device * memory, and calls gasket_enable_dev to prepare the device for active use. @@ -641,7 +617,6 @@ fail1: /* * PCI subsystem remove function. - * @pci_dev: PCI device pointer; the device to remove. * * Called to remove a Gasket device. Finds the device in the device list and * cleans up metadata. @@ -694,8 +669,6 @@ static void gasket_pci_remove(struct pci_dev *pci_dev) /* * Setup PCI & set up memory mapping for the specified device. - * @pci_dev: pointer to the particular PCI device. - * @internal_dev: Corresponding Gasket device pointer. * * Enables the PCI device, reads the BAR registers and sets up pointers to the * device's memory mapped IO space. @@ -746,8 +719,6 @@ static void gasket_cleanup_pci(struct gasket_dev *gasket_dev) /* * Maps the specified bar into kernel space. - * @internal_dev: Device possessing the BAR to map. - * @bar_num: The BAR to map. * * Returns 0 on success, a negative error code otherwise. * A zero-sized BAR will not be mapped, but is not an error. @@ -824,7 +795,6 @@ fail: /* * Releases PCI BAR mapping. - * @internal_dev: Device possessing the BAR to unmap. * * A zero-sized or not-mapped BAR will not be unmapped, but is not an error. */ @@ -856,12 +826,7 @@ static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num) release_mem_region(base, bytes); } -/* - * Handle adding a char device and related info. - * @dev_info: Pointer to the dev_info struct for this device. - * @file_ops: The file operations for this device. - * @owner: The owning module for this device. - */ +/* Add a char device and related info. */ static int gasket_add_cdev( struct gasket_cdev_info *dev_info, const struct file_operations *file_ops, struct module *owner) @@ -881,14 +846,7 @@ static int gasket_add_cdev( return 0; } -/* - * Performs final init and marks the device as active. - * @internal_desc: Pointer to Gasket [internal] driver descriptor structure. - * @internal_dev: Pointer to Gasket [internal] device structure. - * - * Currently forwards all work to device-specific callback; a future phase will - * extract elements of character device registration here. - */ +/* Perform final init and marks the device as active. */ static int gasket_enable_dev( struct gasket_internal_desc *internal_desc, struct gasket_dev *gasket_dev) @@ -966,13 +924,7 @@ static int gasket_enable_dev( return 0; } -/* - * Disable device operations. - * @gasket_dev: Pointer to Gasket device structure. - * - * Currently forwards all work to device-specific callback; a future phase will - * extract elements of character device unregistration here. - */ +/* Disable device operations. */ static void gasket_disable_dev(struct gasket_dev *gasket_dev) { const struct gasket_driver_desc *driver_desc = @@ -997,7 +949,7 @@ static void gasket_disable_dev(struct gasket_dev *gasket_dev) check_and_invoke_callback(gasket_dev, driver_desc->disable_dev_cb); } -/** +/* * Registered descriptor lookup. * * Precondition: Called with g_mutex held (to avoid a race on return). @@ -1045,18 +997,15 @@ const char *gasket_num_name_lookup( } EXPORT_SYMBOL(gasket_num_name_lookup); -/** - * Opens the char device file. - * @inode: Inode structure pointer of the device file. - * @file: File structure pointer. +/* + * Open the char device file. * - * Description: Called on an open of the device file. If the open is for - * writing, and the device is not owned, this process becomes - * the owner. If the open is for writing and the device is - * already owned by some other process, it is an error. If - * this process is the owner, increment the open count. + * If the open is for writing, and the device is not owned, this process becomes + * the owner. If the open is for writing and the device is already owned by + * some other process, it is an error. If this process is the owner, increment + * the open count. * - * Returns 0 if successful, a negative error number otherwise. + * Returns 0 if successful, a negative error number otherwise. */ static int gasket_open(struct inode *inode, struct file *filp) { @@ -1130,17 +1079,12 @@ static int gasket_open(struct inode *inode, struct file *filp) return 0; } -/** - * gasket_release - Close of the char device file. - * @inode: Inode structure pointer of the device file. - * @file: File structure pointer. +/* + * Called on a close of the device file. If this process is the owner, + * decrement the open count. On last close by the owner, free up buffers and + * eventfd contexts, and release ownership. * - * Description: Called on a close of the device file. If this process - * is the owner, decrement the open count. On last close - * by the owner, free up buffers and eventfd contexts, and - * release ownership. - * - * Returns 0 if successful, a negative error number otherwise. + * Returns 0 if successful, a negative error number otherwise. */ static int gasket_release(struct inode *inode, struct file *file) { @@ -1199,10 +1143,6 @@ static int gasket_release(struct inode *inode, struct file *file) } /* - * Permission and validity checking for mmap ops. - * @gasket_dev: Gasket device information structure. - * @vma: Standard virtual memory area descriptor. - * * Verifies that the user has permissions to perform the requested mapping and * that the provided descriptor/range is of adequate size to hold the range to * be mapped. @@ -1246,11 +1186,6 @@ static bool gasket_mmap_has_permissions( } /* - * Checks if an address is within the region - * allocated for coherent buffer. - * @driver_desc: driver description. - * @address: offset of address to check. - * * Verifies that the input address is within the region allocated to coherent * buffer. */ @@ -1502,11 +1437,7 @@ static int gasket_mm_vma_bar_offset( return 0; } -/* - * Map a region of coherent memory. - * @gasket_dev: Gasket device handle. - * @vma: Virtual memory area descriptor with region to map. - */ +/* Map a region of coherent memory. */ static int gasket_mmap_coherent( struct gasket_dev *gasket_dev, struct vm_area_struct *vma) { @@ -1551,16 +1482,7 @@ static int gasket_mmap_coherent( return 0; } -/* - * Maps a device's BARs into user space. - * @filp: File structure pointer describing this node usage session. - * @vma: Standard virtual memory area descriptor. - * - * Maps the entirety of each of the device's BAR ranges into the user memory - * range specified by vma. - * - * Returns 0 on success, a negative errno on error. - */ +/* Map a device's BARs into user space. */ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) { int i, ret; @@ -1704,14 +1626,7 @@ fail: return ret; } -/* - * Determine the health of the Gasket device. - * @gasket_dev: Gasket device structure. - * - * Checks the underlying device health (via the device_status_cb) - * and the status of initialized Gasket code systems (currently - * only interrupts), then returns a gasket_status appropriately. - */ +/* Determine the health of the Gasket device. */ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) { int status; @@ -1750,14 +1665,10 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) /* * Gasket ioctl dispatch function. - * @filp: File structure pointer describing this node usage session. - * @cmd: ioctl number to handle. - * @arg: ioctl-specific data pointer. * - * First, checks if the ioctl is a generic ioctl. If not, it passes - * the ioctl to the ioctl_handler_cb registered in the driver description. - * If the ioctl is a generic ioctl, the function passes it to the - * gasket_ioctl_handler in gasket_ioctl.c. + * Check if the ioctl is a generic ioctl. If not, pass the ioctl to the + * ioctl_handler_cb registered in the driver description. + * If the ioctl is a generic ioctl, pass it to gasket_ioctl_handler. */ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) { From 73832cf08fdbd190782c011a5e34908f7acf0e71 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:40 -0700 Subject: [PATCH 708/903] staging: gasket: ioctl: simplify comments for static functions Static functions don't need kernel doc formatting, can be simplified. Reformat comments that can be single-line. Remove extraneous text. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 51 +++++---------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 78a132a60cc4..55bdd7bfac86 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -170,14 +170,7 @@ long gasket_is_supported_ioctl(uint cmd) } } -/* - * Permission checker for Gasket ioctls. - * @filp: File structure pointer describing this node usage session. - * @cmd: ioctl number to handle. - * - * Check permissions for Gasket ioctls. - * Returns true if the file opener may execute this ioctl, or false otherwise. - */ +/* Check permissions for Gasket ioctls. */ static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd) { bool alive; @@ -218,11 +211,7 @@ static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd) return false; /* unknown permissions */ } -/* - * Associate an eventfd with an interrupt. - * @gasket_dev: Pointer to the current gasket_dev we're using. - * @argp: Pointer to gasket_interrupt_eventfd struct in userspace. - */ +/* Associate an eventfd with an interrupt. */ static int gasket_set_event_fd(struct gasket_dev *gasket_dev, struct gasket_interrupt_eventfd __user *argp) { @@ -237,11 +226,7 @@ static int gasket_set_event_fd(struct gasket_dev *gasket_dev, gasket_dev->interrupt_data, die.interrupt, die.event_fd); } -/* - * Reads the size of the page table. - * @gasket_dev: Pointer to the current gasket_dev we're using. - * @argp: Pointer to gasket_page_table_ioctl struct in userspace. - */ +/* Read the size of the page table. */ static int gasket_read_page_table_size( struct gasket_dev *gasket_dev, struct gasket_page_table_ioctl __user *argp) @@ -268,11 +253,7 @@ static int gasket_read_page_table_size( return ret; } -/* - * Reads the size of the simple page table. - * @gasket_dev: Pointer to the current gasket_dev we're using. - * @argp: Pointer to gasket_page_table_ioctl struct in userspace. - */ +/* Read the size of the simple page table. */ static int gasket_read_simple_page_table_size( struct gasket_dev *gasket_dev, struct gasket_page_table_ioctl __user *argp) @@ -299,11 +280,7 @@ static int gasket_read_simple_page_table_size( return ret; } -/* - * Sets the boundary between the simple and extended page tables. - * @gasket_dev: Pointer to the current gasket_dev we're using. - * @argp: Pointer to gasket_page_table_ioctl struct in userspace. - */ +/* Set the boundary between the simple and extended page tables. */ static int gasket_partition_page_table( struct gasket_dev *gasket_dev, struct gasket_page_table_ioctl __user *argp) @@ -340,11 +317,7 @@ static int gasket_partition_page_table( return ret; } -/* - * Maps a userspace buffer to a device virtual address. - * @gasket_dev: Pointer to the current gasket_dev we're using. - * @argp: Pointer to a gasket_page_table_ioctl struct in userspace. - */ +/* Map a userspace buffer to a device virtual address. */ static int gasket_map_buffers(struct gasket_dev *gasket_dev, struct gasket_page_table_ioctl __user *argp) { @@ -370,11 +343,7 @@ static int gasket_map_buffers(struct gasket_dev *gasket_dev, ibuf.host_address, ibuf.device_address, ibuf.size / PAGE_SIZE); } -/* - * Unmaps a userspace buffer from a device virtual address. - * @gasket_dev: Pointer to the current gasket_dev we're using. - * @argp: Pointer to a gasket_page_table_ioctl struct in userspace. - */ +/* Unmap a userspace buffer from a device virtual address. */ static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, struct gasket_page_table_ioctl __user *argp) { @@ -402,10 +371,8 @@ static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, } /* - * Tell the driver to reserve structures for coherent allocation, and allocate - * or free the corresponding memory. - * @dev: Pointer to the current gasket_dev we're using. - * @argp: Pointer to a gasket_coherent_alloc_config_ioctl struct in userspace. + * Reserve structures for coherent allocation, and allocate or free the + * corresponding memory. */ static int gasket_config_coherent_allocator( struct gasket_dev *gasket_dev, From 480884860158a0942aa4147c40c56dc9a1d985af Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:41 -0700 Subject: [PATCH 709/903] staging: gasket: page table: simplify comments for static functions Static functions don't need kernel doc formatting, can be simplified. Reformat comments that can be single-line. Remove extraneous text. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 323 +++------------------ 1 file changed, 48 insertions(+), 275 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 6b946a155ee3..b42f6637b909 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -635,27 +635,9 @@ int gasket_page_table_system_status(struct gasket_page_table *page_table) return GASKET_STATUS_ALIVE; } -/* Internal functions */ - -/* Mapping functions */ /* * Allocate and map pages to simple addresses. - * @pg_tbl: Gasket page table pointer. - * @host_addr: Starting host virtual memory address of the pages. - * @dev_addr: Starting device address of the pages. - * @cnt: Count of the number of device pages to map. - * - * Description: gasket_map_simple_pages calls gasket_simple_alloc_pages() to - * allocate the page table slots, then calls - * gasket_perform_mapping() to actually do the work of mapping the - * pages into the the simple page table (device translation table - * registers). - * - * The sd_mutex must be held when gasket_map_simple_pages() is - * called. - * - * Returns 0 if successful or a non-zero error number otherwise. - * If there is an error, no pages are mapped. + * If there is an error, no pages are mapped. */ static int gasket_map_simple_pages( struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, @@ -685,22 +667,7 @@ static int gasket_map_simple_pages( /* * gasket_map_extended_pages - Get and map buffers to extended addresses. - * @pg_tbl: Gasket page table pointer. - * @host_addr: Starting host virtual memory address of the pages. - * @dev_addr: Starting device address of the pages. - * @num_pages: The number of device pages to map. - * - * Description: gasket_map_extended_buffers calls - * gasket_alloc_extended_entries() to allocate the page table - * slots, then loops over the level 0 page table entries, and for - * each calls gasket_perform_mapping() to map the buffers into the - * level 1 page table for that level 0 entry. - * - * The page table mutex must be held when - * gasket_map_extended_pages() is called. - * - * Returns 0 if successful or a non-zero error number otherwise. - * If there is an error, no pages are mapped. + * If there is an error, no pages are mapped. */ static int gasket_map_extended_pages( struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, @@ -756,32 +723,11 @@ static int gasket_map_extended_pages( /* * Get and map last level page table buffers. - * @pg_tbl: Gasket page table pointer. - * @ptes: Array of page table entries to describe this mapping, one per - * page to map. - * @slots: Location(s) to write device-mapped page address. If this is a simple - * mapping, these will be address translation registers. If this is - * an extended mapping, these will be within a second-level page table - * allocated by the host and so must have their __iomem attribute - * casted away. - * @host_addr: Starting [host] virtual memory address of the buffers. - * @num_pages: The number of device pages to map. - * @is_simple_mapping: 1 if this is a simple mapping, 0 otherwise. * - * Description: gasket_perform_mapping calls get_user_pages() to get pages - * of user memory and pin them. It then calls dma_map_page() to - * map them for DMA. Finally, the mapped DMA addresses are written - * into the page table. - * - * This function expects that the page table entries are - * already allocated. The level argument determines how the - * final page table entries are written: either into PCIe memory - * mapped space for a level 0 page table or into kernel memory - * for a level 1 page table. - * - * The page pointers are saved for later releasing the pages. - * - * Returns 0 if successful or a non-zero error number otherwise. + * slots is the location(s) to write device-mapped page address. If this is a + * simple mapping, these will be address translation registers. If this is + * an extended mapping, these will be within a second-level page table + * allocated by the host and so must have their __iomem attribute casted away. */ static int gasket_perform_mapping( struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, @@ -866,21 +812,9 @@ static int gasket_perform_mapping( return 0; } -/** +/* * Allocate page table entries in a simple table. - * @pg_tbl: Gasket page table pointer. - * @dev_addr: Starting device address for the (eventual) mappings. - * @num_pages: Count of pages to be mapped. - * - * Description: gasket_alloc_simple_entries checks to see if a range of page - * table slots are available. As long as the sd_mutex is - * held, the slots will be available. - * - * The page table mutex must be held when - * gasket_alloc_simple entries() is called. - * - * Returns 0 if successful, or non-zero if the requested device - * addresses are not available. + * The page table mutex must be held by the caller. */ static int gasket_alloc_simple_entries( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) @@ -893,29 +827,19 @@ static int gasket_alloc_simple_entries( return 0; } -/** - * Allocate slots in an extended page table. - * @pg_tbl: Gasket page table pointer. - * @dev_addr: Starting device address for the (eventual) mappings. - * @num_pages: Count of pages to be mapped. +/* + * Allocate slots in an extended page table. Check to see if a range of page + * table slots are available. If necessary, memory is allocated for second level + * page tables. * - * Description: gasket_alloc_extended_entries checks to see if a range of page - * table slots are available. If necessary, memory is allocated for - * second level page tables. + * Note that memory for second level page tables is allocated as needed, but + * that memory is only freed on the final close of the device file, when the + * page tables are repartitioned, or the the device is removed. If there is an + * error or if the full range of slots is not available, any memory + * allocated for second level page tables remains allocated until final close, + * repartition, or device removal. * - * Note that memory for second level page tables is allocated - * as needed, but that memory is only freed on the final close - * of the device file, when the page tables are repartitioned, - * or the the device is removed. If there is an error or if - * the full range of slots is not available, any memory - * allocated for second level page tables remains allocated - * until final close, repartition, or device removal. - * - * The page table mutex must be held when - * gasket_alloc_extended_entries() is called. - * - * Returns 0 if successful, or non-zero if the slots are - * not available. + * The page table mutex must be held by the caller. */ static int gasket_alloc_extended_entries( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries) @@ -958,21 +882,9 @@ static int gasket_alloc_extended_entries( return 0; } -/** +/* * Allocate a second level page table. - * @pg_tbl: Gasket page table pointer. - * @pte: Extended page table entry under/for which to allocate a second level. - * @slot: [Device] slot corresponding to pte. - * - * Description: Allocate the memory for a second level page table (subtable) at - * the given level 0 entry. Then call dma_map_page() to map the - * second level page table for DMA. Finally, write the - * mapped DMA address into the device page table. - * - * The page table mutex must be held when - * gasket_alloc_extended_subtable() is called. - * - * Returns 0 if successful, or a non-zero error otherwise. + * The page table mutex must be held by the caller. */ static int gasket_alloc_extended_subtable( struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, @@ -1017,15 +929,9 @@ static int gasket_alloc_extended_subtable( return 0; } -/* Unmapping functions */ /* * Non-locking entry to unmapping routines. - * @pg_tbl: Gasket page table structure. - * @dev_addr: Starting device address of the pages to unmap. - * @num_pages: The number of device pages to unmap. - * - * Description: Version of gasket_unmap_pages that assumes the page table lock - * is held. + * The page table mutex must be held by the caller. */ static void gasket_page_table_unmap_nolock( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) @@ -1041,14 +947,7 @@ static void gasket_page_table_unmap_nolock( /* * Unmap and release pages mapped to simple addresses. - * @pg_tbl: Gasket page table pointer. - * @dev_addr: Starting device address of the buffers. - * @num_pages: The number of device pages to unmap. - * - * Description: gasket_simple_unmap_pages calls gasket_perform_unmapping() to - * unmap and release the buffers in the level 0 page table. - * - * The sd_mutex must be held when gasket_unmap_simple_pages() is called. + * The page table mutex must be held by the caller. */ static void gasket_unmap_simple_pages( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) @@ -1059,20 +958,9 @@ static void gasket_unmap_simple_pages( pg_tbl->base_slot + slot, num_pages, 1); } -/** +/* * Unmap and release buffers to extended addresses. - * @pg_tbl: Gasket page table pointer. - * @dev_addr: Starting device address of the pages to unmap. - * @addr: Starting device address of the buffers. - * @num_pages: The number of device pages to unmap. - * - * Description: gasket_extended_unmap_pages loops over the level 0 page table - * entries, and for each calls gasket_perform_unmapping() to unmap - * the buffers from the level 1 page [sub]table for that level 0 - * entry. - * - * The page table mutex must be held when - * gasket_unmap_extended_pages() is called. + * The page table mutex must be held by the caller. */ static void gasket_unmap_extended_pages( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) @@ -1106,28 +994,7 @@ static void gasket_unmap_extended_pages( /* * Unmap and release mapped pages. - * @pg_tbl: Gasket page table pointer. - * @ptes: Array of page table entries to describe the mapped range, one per - * page to unmap. - * @slots: Device slots corresponding to the mappings described by "ptes". - * As with ptes, one element per page to unmap. - * If these are simple mappings, these will be address translation - * registers. If these are extended mappings, these will be witin a - * second-level page table allocated on the host, and so must have - * their __iomem attribute casted away. - * @num_pages: Number of pages to unmap. - * @is_simple_mapping: 1 if this is a simple mapping, 0 otherwise. - * - * Description: gasket_perform_unmapping() loops through the metadata entries - * in a last level page table (simple table or extended subtable), - * and for each page: - * - Unmaps the page from DMA space (dma_unmap_page), - * - Returns the page to the OS (gasket_release_page), - * The entry in the page table is written to 0. The metadata - * type is set to PTE_FREE and the metadata is all reset - * to 0. - * - * The page table mutex must be held when this function is called. + * The page table mutex must be held by the caller. */ static void gasket_perform_unmapping( struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, @@ -1165,17 +1032,6 @@ static void gasket_perform_unmapping( /* * Free a second level page [sub]table. - * @pg_tbl: Gasket page table pointer. - * @pte: Page table entry _pointing_to_ the subtable to free. - * @slot: Device slot holding a pointer to the sublevel's contents. - * - * Description: Safely deallocates a second-level [sub]table by: - * - Marking the containing first-level PTE as free - * - Setting the corresponding [extended] device slot as NULL - * - Unmapping the PTE from DMA space. - * - Freeing the subtable's memory. - * - Deallocating the page and clearing out the PTE. - * * The page table mutex must be held before this call. */ static void gasket_free_extended_subtable( @@ -1202,12 +1058,7 @@ static void gasket_free_extended_subtable( memset(pte, 0, sizeof(struct gasket_page_table_entry)); } -/* - * Safely return a page to the OS. - * @page: The page to return to the OS. - * Returns true if the page was released, false if it was - * ignored. - */ +/* Safely return a page to the OS. */ static bool gasket_release_page(struct page *page) { if (!page) @@ -1229,13 +1080,10 @@ static inline bool gasket_addr_is_simple( /* * Validity checking for simple addresses. - * @pg_tbl: Gasket page table pointer. - * @dev_addr: The device address to which the pages will be mapped. - * @num_pages: The number of pages in the range to consider. * - * Description: This call verifies that address translation commutes (from - * address to/from page + offset) and that the requested page range starts and - * ends within the set of currently-partitioned simple pages. + * Verify that address translation commutes (from address to/from page + offset) + * and that the requested page range starts and ends within the set of + * currently-partitioned simple pages. */ static bool gasket_is_simple_dev_addr_bad( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) @@ -1269,13 +1117,11 @@ static bool gasket_is_simple_dev_addr_bad( } /* - * Verifies that address translation commutes (from address to/from page + - * offset) and that the requested page range starts and ends within the set of - * currently-partitioned simple pages. + * Validity checking for extended addresses. * - * @pg_tbl: Gasket page table pointer. - * @dev_addr: The device address to which the pages will be mapped. - * @num_pages: The number of second-level/sub pages in the range to consider. + * Verify that address translation commutes (from address to/from page + + * offset) and that the requested page range starts and ends within the set of + * currently-partitioned extended pages. */ static bool gasket_is_extended_dev_addr_bad( struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) @@ -1331,15 +1177,8 @@ static bool gasket_is_extended_dev_addr_bad( } /* - * Checks if a range of PTEs is free. - * @ptes: The set of PTEs to check. - * @num_entries: The number of PTEs to check. - * - * Description: Iterates over the input PTEs to determine if all have been - * marked as FREE or if any are INUSE. In the former case, 1/true is returned. - * Otherwise, 0/false is returned. - * - * The page table mutex must be held before this call. + * Check if a range of PTEs is free. + * The page table mutex must be held by the caller. */ static bool gasket_is_pte_range_free( struct gasket_page_table_entry *ptes, uint num_entries) @@ -1356,10 +1195,7 @@ static bool gasket_is_pte_range_free( /* * Actually perform collection. - * @pg_tbl: Gasket page table structure. - * - * Description: Version of gasket_page_table_garbage_collect that assumes the - * page table lock is held. + * The page table mutex must be held by the caller. */ static void gasket_page_table_garbage_collect_nolock( struct gasket_page_table *pg_tbl) @@ -1384,14 +1220,7 @@ static void gasket_page_table_garbage_collect_nolock( } /* - * Converts components to a device address. - * @pg_tbl: Gasket page table structure. - * @is_simple: nonzero if this should be a simple entry, zero otherwise. - * @page_index: The page index into the respective table. - * @offset: The offset within the requested page. - * - * Simple utility function to convert (simple, page, offset) into a device - * address. + * Convert (simple, page, offset) into a device address. * Examples: * Simple page 0, offset 32: * Input (0, 0, 32), Output 0x20 @@ -1429,14 +1258,7 @@ static ulong gasket_components_to_dev_address( } /* - * Gets the index of the address' page in the simple table. - * @pg_tbl: Gasket page table structure. - * @dev_addr: The address whose page index to retrieve. - * - * Description: Treats the input address as a simple address and determines the - * index of its underlying page in the simple page table (i.e., device address - * translation registers. - * + * Return the index of the page for the address in the simple table. * Does not perform validity checking. */ static int gasket_simple_page_idx( @@ -1447,14 +1269,7 @@ static int gasket_simple_page_idx( } /* - * Gets the level 0 page index for the given address. - * @pg_tbl: Gasket page table structure. - * @dev_addr: The address whose page index to retrieve. - * - * Description: Treats the input address as an extended address and determines - * the index of its underlying page in the first-level extended page table - * (i.e., device extended address translation registers). - * + * Return the level 0 page index for the given address. * Does not perform validity checking. */ static ulong gasket_extended_lvl0_page_idx( @@ -1465,14 +1280,7 @@ static ulong gasket_extended_lvl0_page_idx( } /* - * Gets the level 1 page index for the given address. - * @pg_tbl: Gasket page table structure. - * @dev_addr: The address whose page index to retrieve. - * - * Description: Treats the input address as an extended address and determines - * the index of its underlying page in the second-level extended page table - * (i.e., host memory pointed to by a first-level page table entry). - * + * Return the level 1 page index for the given address. * Does not perform validity checking. */ static ulong gasket_extended_lvl1_page_idx( @@ -1483,13 +1291,10 @@ static ulong gasket_extended_lvl1_page_idx( } /* - * Determines whether a host buffer was mapped as coherent memory. - * @pg_tbl: gasket_page_table structure tracking the host buffer mapping - * @host_addr: user virtual address within a host buffer + * Return whether a host buffer was mapped as coherent memory. * - * Description: A Gasket page_table currently support one contiguous - * dma range, mapped to one contiguous virtual memory range. Check if the - * host_addr is within start of page 0, and end of last page, for that range. + * A Gasket page_table currently support one contiguous dma range, mapped to one + * contiguous virtual memory range. Check if the host_addr is within that range. */ static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr) { @@ -1505,16 +1310,7 @@ static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr) return min <= host_addr && host_addr < max; } -/* - * Records the host_addr to coherent dma memory mapping. - * @gasket_dev: Gasket Device. - * @size: Size of the virtual address range to map. - * @dma_address: Dma address within the coherent memory range. - * @vma: Virtual address we wish to map to coherent memory. - * - * Description: For each page in the virtual address range, record the - * coherent page mgasket_pretapping. - */ +/* Record the host_addr to coherent dma memory mapping. */ int gasket_set_user_virt( struct gasket_dev *gasket_dev, u64 size, dma_addr_t dma_address, ulong vma) @@ -1541,16 +1337,7 @@ int gasket_set_user_virt( return 0; } -/* - * Allocate a block of coherent memory. - * @gasket_dev: Gasket Device. - * @size: Size of the memory block. - * @dma_address: Dma address allocated by the kernel. - * @index: Index of the gasket_page_table within this Gasket device - * - * Description: Allocate a contiguous coherent memory block, DMA'ble - * by this device. - */ +/* Allocate a block of coherent memory. */ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, dma_addr_t *dma_address, u64 index) { @@ -1613,15 +1400,7 @@ nomem: return -ENOMEM; } -/* - * Free a block of coherent memory. - * @gasket_dev: Gasket Device. - * @size: Size of the memory block. - * @dma_address: Dma address allocated by the kernel. - * @index: Index of the gasket_page_table within this Gasket device - * - * Description: Release memory allocated thru gasket_alloc_coherent_memory. - */ +/* Free a block of coherent memory. */ int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size, dma_addr_t dma_address, u64 index) { @@ -1647,13 +1426,7 @@ int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size, return 0; } -/* - * Release all coherent memory. - * @gasket_dev: Gasket Device. - * @index: Index of the gasket_page_table within this Gasket device - * - * Description: Release all memory allocated thru gasket_alloc_coherent_memory. - */ +/* Release all coherent memory. */ void gasket_free_coherent_memory_all( struct gasket_dev *gasket_dev, u64 index) { From e4c4afa8db90155ad1ed5c597a1bf63994961ca9 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:42 -0700 Subject: [PATCH 710/903] staging: gasket: interrupt: simplify comments for static functions Static functions don't need kernel doc formatting, can be simplified. Reformat comments that can be single-line. Remove extraneous text. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 3be8e24c126d..27fde991edc6 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -87,13 +87,6 @@ static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = { GASKET_END_OF_ATTR_ARRAY, }; -/* - * Set up device registers for interrupt handling. - * @gasket_dev: The Gasket information structure for this device. - * - * Sets up the device registers with the correct indices for the relevant - * interrupts. - */ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev); /* MSIX init and cleanup. */ @@ -334,13 +327,7 @@ int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev) return 0; } -/* - * Set up device registers for interrupt handling. - * @gasket_dev: The Gasket information structure for this device. - * - * Sets up the device registers with the correct indices for the relevant - * interrupts. - */ +/* Set up device registers for interrupt handling. */ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) { int i; @@ -553,9 +540,6 @@ static ssize_t interrupt_sysfs_show( return ret; } -/* - * MSIX interrupt handler, used with PCI driver. - */ static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id) { struct eventfd_ctx *ctx; From cef7330217ac56d68b3658af84d1d5d9a5121316 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:43 -0700 Subject: [PATCH 711/903] staging: gasket: sysfs: simplify comments for static functions Static functions don't need kernel doc formatting, can be simplified. Reformat comments that can be single-line. Remove extraneous text. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 28 ++++----------------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index fde04658419b..ef4eca02afa6 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -47,22 +47,13 @@ struct gasket_sysfs_mapping { */ static struct gasket_sysfs_mapping dev_mappings[GASKET_SYSFS_NUM_MAPPINGS]; -/* - * Callback when a mapping's refcount goes to zero. - * @ref: The reference count of the containing sysfs mapping. - */ +/* Callback when a mapping's refcount goes to zero. */ static void release_entry(struct kref *ref) { /* All work is done after the return from kref_put. */ } -/* - * Looks up mapping information for the given device. - * @device: The device whose mapping to look for. - * - * Looks up the requested device and takes a reference and returns it if found, - * and returns NULL otherwise. - */ +/* Look up mapping information for the given device. */ static struct gasket_sysfs_mapping *get_mapping(struct device *device) { int i; @@ -82,17 +73,7 @@ static struct gasket_sysfs_mapping *get_mapping(struct device *device) return NULL; } -/* - * Returns a reference to a mapping. - * @mapping: The mapping we're returning. - * - * Decrements the refcount for the given mapping (if valid). If the refcount is - * zero, then it cleans up the mapping - in this function as opposed to the - * kref_put callback, due to a potential deadlock. - * - * Although put_mapping_n exists, this function is left here (as an implicit - * put_mapping_n(..., 1) for convenience. - */ +/* Put a reference to a mapping. */ static void put_mapping(struct gasket_sysfs_mapping *mapping) { int i; @@ -140,8 +121,7 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) } /* - * Returns a reference N times. - * @mapping: The mapping to return. + * Put a reference to a mapping N times. * * In higher-level resource acquire/release function pairs, the release function * will need to release a mapping 2x - once for the refcount taken in the From 8b8a93885d578d252bcf7d8cd1771b5991ffc7fc Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:44 -0700 Subject: [PATCH 712/903] staging: gasket: TODO: remove entry for static function kernel docs Remove the TODO entry for simplifying kernel doc style comments for static functions, now that this has been addressed. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO index fb71997fb561..7f4c13ce021b 100644 --- a/drivers/staging/gasket/TODO +++ b/drivers/staging/gasket/TODO @@ -5,7 +5,6 @@ staging directory. - Use misc interface instead of major number for driver version description. - Add descriptions of module_param's - apex_get_status() should actually check status. -- Static functions don't need kernel doc formatting, can be simplified. - Fix multi-line alignment formatting to look like: int ret = long_function_name(device, VARIABLE1, VARIABLE2, VARIABLE3, VARIABLE4); From c76b15fe7b7b8c74aa49960ecbe1d44c5c0104ab Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:45 -0700 Subject: [PATCH 713/903] staging: gasket: apex: remove static function forward declarations Remove forward declarations of static functions, move code to avoid forward references, for kernel style. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 416 ++++++++++++--------------- 1 file changed, 190 insertions(+), 226 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index a75676475177..f70fea0d80ec 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -123,55 +123,6 @@ static struct gasket_page_table_config apex_page_table_configs[NUM_NODES] = { }, }; -/* Function declarations */ -static int __init apex_init(void); -static void apex_exit(void); - -static int apex_add_dev_cb(struct gasket_dev *gasket_dev); - -static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev); - -static int apex_device_cleanup(struct gasket_dev *gasket_dev); - -static int apex_device_open_cb(struct gasket_dev *gasket_dev); - -static ssize_t sysfs_show( - struct device *device, struct device_attribute *attr, char *buf); - -static int apex_reset(struct gasket_dev *gasket_dev, uint type); - -static int apex_get_status(struct gasket_dev *gasket_dev); - -static bool apex_ioctl_check_permissions(struct file *file, uint cmd); - -static long apex_ioctl(struct file *file, uint cmd, void __user *argp); - -static long apex_clock_gating(struct gasket_dev *gasket_dev, - struct apex_gate_clock_ioctl __user *argp); - -static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type); - -static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type); - -static bool is_gcb_in_reset(struct gasket_dev *gasket_dev); - -/* Data definitions */ - -/* The data necessary to display this file's sysfs entries. */ -static struct gasket_sysfs_attribute apex_sysfs_attrs[] = { - GASKET_SYSFS_RO(node_0_page_table_entries, sysfs_show, - ATTR_KERNEL_HIB_PAGE_TABLE_SIZE), - GASKET_SYSFS_RO(node_0_simple_page_table_entries, sysfs_show, - ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE), - GASKET_SYSFS_RO(node_0_num_mapped_pages, sysfs_show, - ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES), - GASKET_END_OF_ATTR_ARRAY -}; - -static const struct pci_device_id apex_pci_ids[] = { - { PCI_DEVICE(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID) }, { 0 } -}; - /* The regions in the BAR2 space that can be mapped into user space. */ static const struct gasket_mappable_region mappable_regions[NUM_REGIONS] = { { 0x40000, 0x1000 }, @@ -251,65 +202,6 @@ static struct gasket_interrupt_desc apex_interrupts[] = { }, }; -static struct gasket_driver_desc apex_desc = { - .name = "apex", - .driver_version = APEX_DRIVER_VERSION, - .major = 120, - .minor = 0, - .module = THIS_MODULE, - .pci_id_table = apex_pci_ids, - - .num_page_tables = NUM_NODES, - .page_table_bar_index = APEX_BAR_INDEX, - .page_table_configs = apex_page_table_configs, - .page_table_extended_bit = APEX_EXTENDED_SHIFT, - - .bar_descriptions = { - GASKET_UNUSED_BAR, - GASKET_UNUSED_BAR, - { APEX_BAR_BYTES, (VM_WRITE | VM_READ), APEX_BAR_OFFSET, - NUM_REGIONS, mappable_regions, PCI_BAR }, - GASKET_UNUSED_BAR, - GASKET_UNUSED_BAR, - GASKET_UNUSED_BAR, - }, - .coherent_buffer_description = { - APEX_CH_MEM_BYTES, - (VM_WRITE | VM_READ), - APEX_CM_OFFSET, - }, - .interrupt_type = PCI_MSIX, - .interrupt_bar_index = APEX_BAR_INDEX, - .num_interrupts = APEX_INTERRUPT_COUNT, - .interrupts = apex_interrupts, - .interrupt_pack_width = 7, - - .add_dev_cb = apex_add_dev_cb, - .remove_dev_cb = NULL, - - .enable_dev_cb = NULL, - .disable_dev_cb = NULL, - - .sysfs_setup_cb = apex_sysfs_setup_cb, - .sysfs_cleanup_cb = NULL, - - .device_open_cb = apex_device_open_cb, - .device_close_cb = apex_device_cleanup, - - .ioctl_handler_cb = apex_ioctl, - .device_status_cb = apex_get_status, - .hardware_revision_cb = NULL, - .device_reset_cb = apex_reset, -}; - -/* Module registration boilerplate */ -MODULE_DESCRIPTION("Google Apex driver"); -MODULE_VERSION(APEX_DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("John Joseph "); -MODULE_DEVICE_TABLE(pci, apex_pci_ids); -module_init(apex_init); -module_exit(apex_exit); /* Allows device to enter power save upon driver close(). */ static int allow_power_save; @@ -329,61 +221,6 @@ module_param(allow_sw_clock_gating, int, 0644); module_param(allow_hw_clock_gating, int, 0644); module_param(bypass_top_level, int, 0644); -static int __init apex_init(void) -{ - return gasket_register_device(&apex_desc); -} - -static void apex_exit(void) -{ - gasket_unregister_device(&apex_desc); -} - -static int apex_add_dev_cb(struct gasket_dev *gasket_dev) -{ - ulong page_table_ready, msix_table_ready; - int retries = 0; - - apex_reset(gasket_dev, 0); - - while (retries < APEX_RESET_RETRY) { - page_table_ready = - gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT); - msix_table_ready = - gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT); - if (page_table_ready && msix_table_ready) - break; - schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY)); - retries++; - } - - if (retries == APEX_RESET_RETRY) { - if (!page_table_ready) - dev_err(gasket_dev->dev, "Page table init timed out\n"); - if (!msix_table_ready) - dev_err(gasket_dev->dev, "MSI-X table init timed out\n"); - return -ETIMEDOUT; - } - - return 0; -} - -static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev) -{ - return gasket_sysfs_create_entries( - gasket_dev->dev_info.device, apex_sysfs_attrs); -} - -/* On device open, perform a core reinit reset. */ -static int apex_device_open_cb(struct gasket_dev *gasket_dev) -{ - return gasket_reset_nolock(gasket_dev, APEX_CHIP_REINIT_RESET); -} - /* Check the device status registers and return device status ALIVE or DEAD. */ static int apex_get_status(struct gasket_dev *gasket_dev) { @@ -391,53 +228,6 @@ static int apex_get_status(struct gasket_dev *gasket_dev) return GASKET_STATUS_ALIVE; } -/* Reset the Apex hardware. Called on final close via device_close_cb. */ -static int apex_device_cleanup(struct gasket_dev *gasket_dev) -{ - u64 scalar_error; - u64 hib_error; - int ret = 0; - - hib_error = gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_USER_HIB_ERROR_STATUS); - scalar_error = gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS); - - dev_dbg(gasket_dev->dev, - "%s 0x%p hib_error 0x%llx scalar_error 0x%llx\n", - __func__, gasket_dev, hib_error, scalar_error); - - if (allow_power_save) - ret = apex_enter_reset(gasket_dev, APEX_CHIP_REINIT_RESET); - - return ret; -} - -/* Reset the hardware, then quit reset. Called on device open. */ -static int apex_reset(struct gasket_dev *gasket_dev, uint type) -{ - int ret; - - if (bypass_top_level) - return 0; - - if (!is_gcb_in_reset(gasket_dev)) { - /* We are not in reset - toggle the reset bit so as to force - * re-init of custom block - */ - dev_dbg(gasket_dev->dev, "%s: toggle reset\n", __func__); - - ret = apex_enter_reset(gasket_dev, type); - if (ret) - return ret; - } - ret = apex_quit_reset(gasket_dev, type); - - return ret; -} - /* Enter GCB reset state. */ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) { @@ -576,6 +366,30 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) return 0; } +/* Reset the Apex hardware. Called on final close via device_close_cb. */ +static int apex_device_cleanup(struct gasket_dev *gasket_dev) +{ + u64 scalar_error; + u64 hib_error; + int ret = 0; + + hib_error = gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_USER_HIB_ERROR_STATUS); + scalar_error = gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS); + + dev_dbg(gasket_dev->dev, + "%s 0x%p hib_error 0x%llx scalar_error 0x%llx\n", + __func__, gasket_dev, hib_error, scalar_error); + + if (allow_power_save) + ret = apex_enter_reset(gasket_dev, APEX_CHIP_REINIT_RESET); + + return ret; +} + /* Determine if GCB is in reset state. */ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) { @@ -586,6 +400,62 @@ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) return (val & SCU3_CUR_RST_GCB_BIT_MASK); } +/* Reset the hardware, then quit reset. Called on device open. */ +static int apex_reset(struct gasket_dev *gasket_dev, uint type) +{ + int ret; + + if (bypass_top_level) + return 0; + + if (!is_gcb_in_reset(gasket_dev)) { + /* We are not in reset - toggle the reset bit so as to force + * re-init of custom block + */ + dev_dbg(gasket_dev->dev, "%s: toggle reset\n", __func__); + + ret = apex_enter_reset(gasket_dev, type); + if (ret) + return ret; + } + ret = apex_quit_reset(gasket_dev, type); + + return ret; +} + +static int apex_add_dev_cb(struct gasket_dev *gasket_dev) +{ + ulong page_table_ready, msix_table_ready; + int retries = 0; + + apex_reset(gasket_dev, 0); + + while (retries < APEX_RESET_RETRY) { + page_table_ready = + gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT); + msix_table_ready = + gasket_dev_read_64( + gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT); + if (page_table_ready && msix_table_ready) + break; + schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY)); + retries++; + } + + if (retries == APEX_RESET_RETRY) { + if (!page_table_ready) + dev_err(gasket_dev->dev, "Page table init timed out\n"); + if (!msix_table_ready) + dev_err(gasket_dev->dev, "MSI-X table init timed out\n"); + return -ETIMEDOUT; + } + + return 0; +} + /* * Check permissions for Apex ioctls. * Returns true if the current user may execute this ioctl, and false otherwise. @@ -595,22 +465,6 @@ static bool apex_ioctl_check_permissions(struct file *filp, uint cmd) return !!(filp->f_mode & FMODE_WRITE); } -/* Apex-specific ioctl handler. */ -static long apex_ioctl(struct file *filp, uint cmd, void __user *argp) -{ - struct gasket_dev *gasket_dev = filp->private_data; - - if (!apex_ioctl_check_permissions(filp, cmd)) - return -EPERM; - - switch (cmd) { - case APEX_IOCTL_GATE_CLOCK: - return apex_clock_gating(gasket_dev, argp); - default: - return -ENOTTY; /* unknown command */ - } -} - /* Gates or un-gates Apex clock. */ static long apex_clock_gating(struct gasket_dev *gasket_dev, struct apex_gate_clock_ioctl __user *argp) @@ -645,6 +499,22 @@ static long apex_clock_gating(struct gasket_dev *gasket_dev, return 0; } +/* Apex-specific ioctl handler. */ +static long apex_ioctl(struct file *filp, uint cmd, void __user *argp) +{ + struct gasket_dev *gasket_dev = filp->private_data; + + if (!apex_ioctl_check_permissions(filp, cmd)) + return -EPERM; + + switch (cmd) { + case APEX_IOCTL_GATE_CLOCK: + return apex_clock_gating(gasket_dev, argp); + default: + return -ENOTTY; /* unknown command */ + } +} + /* Display driver sysfs entries. */ static ssize_t sysfs_show( struct device *device, struct device_attribute *attr, char *buf) @@ -696,9 +566,103 @@ static ssize_t sysfs_show( return ret; } +static struct gasket_sysfs_attribute apex_sysfs_attrs[] = { + GASKET_SYSFS_RO(node_0_page_table_entries, sysfs_show, + ATTR_KERNEL_HIB_PAGE_TABLE_SIZE), + GASKET_SYSFS_RO(node_0_simple_page_table_entries, sysfs_show, + ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE), + GASKET_SYSFS_RO(node_0_num_mapped_pages, sysfs_show, + ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES), + GASKET_END_OF_ATTR_ARRAY +}; + +static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev) +{ + return gasket_sysfs_create_entries( + gasket_dev->dev_info.device, apex_sysfs_attrs); +} + +/* On device open, perform a core reinit reset. */ +static int apex_device_open_cb(struct gasket_dev *gasket_dev) +{ + return gasket_reset_nolock(gasket_dev, APEX_CHIP_REINIT_RESET); +} + +static const struct pci_device_id apex_pci_ids[] = { + { PCI_DEVICE(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID) }, { 0 } +}; + static void apex_pci_fixup_class(struct pci_dev *pdev) { pdev->class = (PCI_CLASS_SYSTEM_OTHER << 8) | pdev->class; } DECLARE_PCI_FIXUP_CLASS_HEADER(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID, PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class); + +static struct gasket_driver_desc apex_desc = { + .name = "apex", + .driver_version = APEX_DRIVER_VERSION, + .major = 120, + .minor = 0, + .module = THIS_MODULE, + .pci_id_table = apex_pci_ids, + + .num_page_tables = NUM_NODES, + .page_table_bar_index = APEX_BAR_INDEX, + .page_table_configs = apex_page_table_configs, + .page_table_extended_bit = APEX_EXTENDED_SHIFT, + + .bar_descriptions = { + GASKET_UNUSED_BAR, + GASKET_UNUSED_BAR, + { APEX_BAR_BYTES, (VM_WRITE | VM_READ), APEX_BAR_OFFSET, + NUM_REGIONS, mappable_regions, PCI_BAR }, + GASKET_UNUSED_BAR, + GASKET_UNUSED_BAR, + GASKET_UNUSED_BAR, + }, + .coherent_buffer_description = { + APEX_CH_MEM_BYTES, + (VM_WRITE | VM_READ), + APEX_CM_OFFSET, + }, + .interrupt_type = PCI_MSIX, + .interrupt_bar_index = APEX_BAR_INDEX, + .num_interrupts = APEX_INTERRUPT_COUNT, + .interrupts = apex_interrupts, + .interrupt_pack_width = 7, + + .add_dev_cb = apex_add_dev_cb, + .remove_dev_cb = NULL, + + .enable_dev_cb = NULL, + .disable_dev_cb = NULL, + + .sysfs_setup_cb = apex_sysfs_setup_cb, + .sysfs_cleanup_cb = NULL, + + .device_open_cb = apex_device_open_cb, + .device_close_cb = apex_device_cleanup, + + .ioctl_handler_cb = apex_ioctl, + .device_status_cb = apex_get_status, + .hardware_revision_cb = NULL, + .device_reset_cb = apex_reset, +}; + +static int __init apex_init(void) +{ + return gasket_register_device(&apex_desc); +} + +static void apex_exit(void) +{ + gasket_unregister_device(&apex_desc); +} +MODULE_DESCRIPTION("Google Apex driver"); +MODULE_VERSION(APEX_DRIVER_VERSION); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("John Joseph "); +MODULE_DEVICE_TABLE(pci, apex_pci_ids); +module_init(apex_init); +module_exit(apex_exit); From 26fd80ead0fe4dec100d6c2f8ce28897f2e25f2c Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 29 Jul 2018 12:36:46 -0700 Subject: [PATCH 714/903] staging: gasket: apex: fix function param line continuation style Fix multi-line alignment formatting to look like: int ret = long_function_name(device, VARIABLE1, VARIABLE2, VARIABLE3, VARIABLE4); Many of these TODO items were previously cleaned up during the conversion to standard logging functions. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 119 +++++++++++++-------------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index f70fea0d80ec..c0d3922e1d7c 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -240,9 +240,9 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) * - Software force GCB idle * - Enable GCB idle */ - gasket_read_modify_write_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER, 0x0, 1, 32); + gasket_read_modify_write_64(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER, + 0x0, 1, 32); /* - Initiate DMA pause */ gasket_dev_write_64(gasket_dev, 1, APEX_BAR_INDEX, @@ -259,16 +259,16 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) } /* - Enable GCB reset (0x1 to rg_rst_gcb) */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x1, 2, 2); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_2, 0x1, 2, 2); /* - Enable GCB clock Gate (0x1 to rg_gated_gcb) */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x1, 2, 18); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_2, 0x1, 2, 18); /* - Enable GCB memory shut down (0x3 to rg_force_ram_sd) */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 0x3, 2, 14); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3, 0x3, 2, 14); /* - Wait for RAM shutdown. */ if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, @@ -297,24 +297,24 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) * - b00: Not forced (HW controlled) * - b1x: Force disable */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 0x0, 2, 14); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3, 0x0, 2, 14); /* * - Disable software clock gate: * - b00: Not forced (HW controlled) * - b1x: Force disable */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x0, 2, 18); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_2, 0x0, 2, 18); /* * - Disable GCB reset (rg_rst_gcb): * - b00: Not forced (HW controlled) * - b1x: Force disable = Force not Reset */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_2, 0x2, 2, 2); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_2, 0x2, 2, 2); /* - Wait for RAM enable. */ if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX, @@ -338,27 +338,28 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) } if (!allow_hw_clock_gating) { - val0 = gasket_dev_read_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + val0 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3); /* Inactive and Sleep mode are disabled. */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 0x3, - SCU3_RG_PWR_STATE_OVR_MASK_WIDTH, - SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); - val1 = gasket_dev_read_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + gasket_read_modify_write_32(gasket_dev, + APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3, 0x3, + SCU3_RG_PWR_STATE_OVR_MASK_WIDTH, + SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); + val1 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3); dev_dbg(gasket_dev->dev, "Disallow HW clock gating 0x%x -> 0x%x\n", val0, val1); } else { - val0 = gasket_dev_read_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + val0 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3); /* Inactive mode enabled - Sleep mode disabled. */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3, 2, - SCU3_RG_PWR_STATE_OVR_MASK_WIDTH, - SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); - val1 = gasket_dev_read_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3, 2, + SCU3_RG_PWR_STATE_OVR_MASK_WIDTH, + SCU3_RG_PWR_STATE_OVR_BIT_OFFSET); + val1 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3); dev_dbg(gasket_dev->dev, "Allow HW clock gating 0x%x -> 0x%x\n", val0, val1); } @@ -373,12 +374,10 @@ static int apex_device_cleanup(struct gasket_dev *gasket_dev) u64 hib_error; int ret = 0; - hib_error = gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_USER_HIB_ERROR_STATUS); - scalar_error = gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS); + hib_error = gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_USER_HIB_ERROR_STATUS); + scalar_error = gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS); dev_dbg(gasket_dev->dev, "%s 0x%p hib_error 0x%llx scalar_error 0x%llx\n", @@ -393,8 +392,8 @@ static int apex_device_cleanup(struct gasket_dev *gasket_dev) /* Determine if GCB is in reset state. */ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) { - u32 val = gasket_dev_read_32( - gasket_dev, APEX_BAR_INDEX, APEX_BAR2_REG_SCU_3); + u32 val = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_SCU_3); /* Masks rg_rst_gcb bit of SCU_CTRL_2 */ return (val & SCU3_CUR_RST_GCB_BIT_MASK); @@ -432,13 +431,11 @@ static int apex_add_dev_cb(struct gasket_dev *gasket_dev) while (retries < APEX_RESET_RETRY) { page_table_ready = - gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT); + gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT); msix_table_ready = - gasket_dev_read_64( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT); + gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT); if (page_table_ready && msix_table_ready) break; schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY)); @@ -481,20 +478,20 @@ static long apex_clock_gating(struct gasket_dev *gasket_dev, if (ibuf.enable) { /* Quiesce AXI, gate GCB clock. */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_AXI_QUIESCE, 0x1, 1, 16); - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_GCB_CLOCK_GATE, 0x1, 2, 18); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_AXI_QUIESCE, 0x1, 1, + 16); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_GCB_CLOCK_GATE, 0x1, + 2, 18); } else { /* Un-gate GCB clock, un-quiesce AXI. */ - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_GCB_CLOCK_GATE, 0x0, 2, 18); - gasket_read_modify_write_32( - gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_AXI_QUIESCE, 0x0, 1, 16); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_GCB_CLOCK_GATE, 0x0, + 2, 18); + gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_AXI_QUIESCE, 0x0, 1, + 16); } return 0; } @@ -516,8 +513,8 @@ static long apex_ioctl(struct file *filp, uint cmd, void __user *argp) } /* Display driver sysfs entries. */ -static ssize_t sysfs_show( - struct device *device, struct device_attribute *attr, char *buf) +static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, + char *buf) { int ret; struct gasket_dev *gasket_dev; @@ -578,8 +575,8 @@ static struct gasket_sysfs_attribute apex_sysfs_attrs[] = { static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev) { - return gasket_sysfs_create_entries( - gasket_dev->dev_info.device, apex_sysfs_attrs); + return gasket_sysfs_create_entries(gasket_dev->dev_info.device, + apex_sysfs_attrs); } /* On device open, perform a core reinit reset. */ From 0a837d1ba505c354fff1dfa8eef0c81e63fb38fb Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 29 Jul 2018 20:54:41 +0200 Subject: [PATCH 715/903] staging: rtl8188eu: remove unused dump_txrpt_ccx_88e() The function dump_txrpt_ccx_88e() is nerver used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c | 22 ------------------- .../staging/rtl8188eu/include/rtl8188e_xmit.h | 1 - 2 files changed, 23 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c index 6883746f3b8b..9b8a284544ac 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c @@ -10,28 +10,6 @@ #include #include -void dump_txrpt_ccx_88e(void *buf) -{ - struct txrpt_ccx_88e *txrpt_ccx = buf; - - DBG_88E("%s:\n" - "tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n" - "mac_id:%u, pkt_ok:%u, bmc:%u\n" - "retry_cnt:%u, lifetime_over:%u, retry_over:%u\n" - "ccx_qtime:%u\n" - "final_data_rate:0x%02x\n" - "qsel:%u, sw:0x%03x\n", - __func__, txrpt_ccx->tag1, txrpt_ccx->pkt_num, - txrpt_ccx->txdma_underflow, txrpt_ccx->int_bt, - txrpt_ccx->int_tri, txrpt_ccx->int_ccx, - txrpt_ccx->mac_id, txrpt_ccx->pkt_ok, txrpt_ccx->bmc, - txrpt_ccx->retry_cnt, txrpt_ccx->lifetime_over, - txrpt_ccx->retry_over, txrpt_ccx_qtime_88e(txrpt_ccx), - txrpt_ccx->final_data_rate, txrpt_ccx->qsel, - txrpt_ccx_sw_88e(txrpt_ccx) - ); -} - void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) { struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h index 17e7b3016674..20d35480dab8 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h @@ -152,7 +152,6 @@ void rtl8188eu_xmit_tasklet(void *priv); s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxmitpriv); -void dump_txrpt_ccx_88e(void *buf); void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, From 30622c87c38e8a64a6b5a4e44c65079f6f2629a0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 29 Jul 2018 20:54:42 +0200 Subject: [PATCH 716/903] staging: rtl8188eu: remove unused should_forbid_n_rate() The function should_forbid_n_rate() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_wlan_util.c | 35 ------------------- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 1 - 2 files changed, 36 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 0fe35e141926..b9406583e501 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1094,41 +1094,6 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) } } -unsigned int should_forbid_n_rate(struct adapter *padapter) -{ - u32 i; - struct ndis_802_11_var_ie *pIE; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; - - if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ie); i < cur_network->ie_length;) { - pIE = (struct ndis_802_11_var_ie *)(cur_network->ies + i); - - switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: - if (!memcmp(pIE->data, RTW_WPA_OUI, 4) && - ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) || - (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4)))) - return false; - break; - case _RSN_IE_2_: - if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || - (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) - return false; - default: - break; - } - - i += (pIE->Length + 2); - } - - return true; - } else { - return false; - } -} - unsigned int is_ap_in_wep(struct adapter *padapter) { u32 i; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index c072e1e25d61..ade68af15e04 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -534,7 +534,6 @@ unsigned char get_highest_rate_idx(u32 mask); int support_short_GI(struct adapter *padapter, struct ieee80211_ht_cap *caps); unsigned int is_ap_in_tkip(struct adapter *padapter); unsigned int is_ap_in_wep(struct adapter *padapter); -unsigned int should_forbid_n_rate(struct adapter *padapter); void report_join_res(struct adapter *padapter, int res); void report_survey_event(struct adapter *padapter, From 816f4a46e0b49b57da2c0e31e54a43cfd0afcd9f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 29 Jul 2018 20:54:44 +0200 Subject: [PATCH 717/903] staging: rtl8188eu: remove redundant includes Both osdep_service.h and drv_types.h are included from hal_intf.h, so remove the redundant includes from hal_intf.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index aaa1718ca603..0baf4e616b6a 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -6,8 +6,6 @@ ******************************************************************************/ #define _HAL_INTF_C_ -#include -#include #include uint rtw_hal_init(struct adapter *adapt) From 3da4a578ce610ffee188a765aca16a4be9ba2f94 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 29 Jul 2018 20:54:45 +0200 Subject: [PATCH 718/903] staging: rtl8188eu: replace tabs with spaces Replace tabs with spaces in function definition and variable declarations. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index 0baf4e616b6a..c43e7b438058 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -8,9 +8,9 @@ #define _HAL_INTF_C_ #include -uint rtw_hal_init(struct adapter *adapt) +uint rtw_hal_init(struct adapter *adapt) { - uint status = _SUCCESS; + uint status = _SUCCESS; adapt->hw_init_completed = false; @@ -34,7 +34,7 @@ uint rtw_hal_init(struct adapter *adapt) uint rtw_hal_deinit(struct adapter *adapt) { - uint status = _SUCCESS; + uint status = _SUCCESS; status = rtl8188eu_hal_deinit(adapt); From 47c8264e68e8a19de0d22ff4e336c4153a8717d4 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 29 Jul 2018 20:54:46 +0200 Subject: [PATCH 719/903] staging: rtl8188eu: fix comparsion to true Use if(x) instead of if(x == true). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index c43e7b438058..b21ba01abc57 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -50,7 +50,7 @@ void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) { struct mlme_priv *pmlmepriv = &(adapt->mlmepriv); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { #ifdef CONFIG_88EU_AP_MODE struct sta_info *psta = NULL; struct sta_priv *pstapriv = &adapt->stapriv; From 8d7430de9887c92847f2b7e608ba21a609254e47 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 29 Jul 2018 20:54:47 +0200 Subject: [PATCH 720/903] staging: rtl8188eu: remove unnecessary parentheses Remove unnecessary parentheses, also clears checkpatch issues about missing spaces around '-'. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index b21ba01abc57..b8fecc952cfc 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -48,15 +48,15 @@ uint rtw_hal_deinit(struct adapter *adapt) void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) { - struct mlme_priv *pmlmepriv = &(adapt->mlmepriv); + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { #ifdef CONFIG_88EU_AP_MODE struct sta_info *psta = NULL; struct sta_priv *pstapriv = &adapt->stapriv; - if ((mac_id-1) > 0) - psta = pstapriv->sta_aid[(mac_id-1) - 1]; + if (mac_id - 1 > 0) + psta = pstapriv->sta_aid[mac_id - 2]; if (psta) add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/ #endif From 2e8ce8efc9626cf1da0796df97d01fcb7b8b9ad2 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:45 +0100 Subject: [PATCH 721/903] staging:rtl8192u: Add spaces around operators - Style Add the required spaces around '+' and '*' operators. This is a coding style change to clear the checkpatch issue. There should be no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 8ee9370520f3..92afa9dc9663 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -7,7 +7,7 @@ #define AC_PARAM_SIZE 4 #define WMM_PARAM_ELE_BODY_LEN 18 -#define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE)) +#define WMM_PARAM_ELEMENT_SIZE (8 + (4 * AC_PARAM_SIZE)) // // ACI/AIFSN Field. From 4116ad1d993cc72f84f0c4cf370ac314ad9f799e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:46 +0100 Subject: [PATCH 722/903] staging:rtl8192u: Rename ACI_AIFSN - Style Rename the union ACI_AIFSN to aci_aifsn and remove the typedef directive. The removal of the typedef clears the checkpatch issue with defining new types. The renaming is to adhere to the coding style where types are name in lower case. These changes are coding style changes which should have no impact on runtime execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 6 +++--- drivers/staging/rtl8192u/r8192U_dm.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 92afa9dc9663..5856bf87c5dc 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -13,7 +13,7 @@ // ACI/AIFSN Field. // Ref: WMM spec 2.2.2: WME Parameter Element, p.12. // -typedef union _ACI_AIFSN { +union aci_aifsn { u8 charData; struct { @@ -22,7 +22,7 @@ typedef union _ACI_AIFSN { u8 ACI:2; u8 Reserved:1; } f; // Field -} ACI_AIFSN, *PACI_AIFSN; +}; // // ECWmin/ECWmax field. @@ -45,7 +45,7 @@ typedef union _AC_PARAM { u8 charData[4]; struct { - ACI_AIFSN AciAifsn; + union aci_aifsn AciAifsn; ECW Ecw; u16 TXOPLimit; } f; // Field diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index c4e4e3ba394b..04c08ca8a0bb 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2333,7 +2333,7 @@ static void dm_check_edca_turbo( { /* TODO: Modified this part and try to set acm control in only 1 IO processing!! */ - PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]); + union aci_aifsn *pAciAifsn = (union aci_aifsn *)&(qos_parameters->aifs[0]); u8 AcmCtrl; read_nic_byte(dev, AcmHwCtrl, &AcmCtrl); From a7f4a9e21bd1ef4f0b70fc4c861dbbfb2308a748 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:47 +0100 Subject: [PATCH 723/903] staging:rtl8192u: Rename member variables - Style Rename the member variables of union aci_aifsn, which should be named in lowercase. The only member variable, of this union, which is actually used is 'acm'. This are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 10 +++++----- drivers/staging/rtl8192u/r8192U_dm.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 5856bf87c5dc..901b85139d3b 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -14,13 +14,13 @@ // Ref: WMM spec 2.2.2: WME Parameter Element, p.12. // union aci_aifsn { - u8 charData; + u8 char_data; struct { - u8 AIFSN:4; - u8 ACM:1; - u8 ACI:2; - u8 Reserved:1; + u8 aifsn:4; + u8 acm:1; + u8 aci:2; + u8 reserved:1; } f; // Field }; diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 04c08ca8a0bb..7dc912dd53af 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2338,7 +2338,7 @@ static void dm_check_edca_turbo( read_nic_byte(dev, AcmHwCtrl, &AcmCtrl); - if (pAciAifsn->f.ACM) { /* ACM bit is 1. */ + if (pAciAifsn->f.acm) { /* acm bit is 1. */ AcmCtrl |= AcmHw_BeqEn; } else { /* ACM bit is 0. */ AcmCtrl &= (~AcmHw_BeqEn); From dd3c69e115a7637856ca6ba2396dbff1b811468a Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:48 +0100 Subject: [PATCH 724/903] staging:rtl8192u: Remove unused union AC_PARAM - Style The union ACM_PARAM is never actually used in code so removed. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 901b85139d3b..43edb830ad5d 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -36,21 +36,6 @@ typedef union _ECW { } f; // Field } ECW, *PECW; -// -// AC Parameters Record Format. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.12. -// -typedef union _AC_PARAM { - u32 longData; - u8 charData[4]; - - struct { - union aci_aifsn AciAifsn; - ECW Ecw; - u16 TXOPLimit; - } f; // Field -} AC_PARAM, *PAC_PARAM; - // // Direction Field Values. // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. From 15321170f7e2fa1d010f021589c8f7168c5d23fa Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:49 +0100 Subject: [PATCH 725/903] staging:rtl8192u: Remove unused union ECW -Style The union ECW is never used in code so has simply been removed. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 43edb830ad5d..65d7c9f4d840 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -24,18 +24,6 @@ union aci_aifsn { } f; // Field }; -// -// ECWmin/ECWmax field. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.13. -// -typedef union _ECW { - u8 charData; - struct { - u8 ECWmin:4; - u8 ECWmax:4; - } f; // Field -} ECW, *PECW; - // // Direction Field Values. // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. From 489d5cd8046e6cd7db4123df57108ca52c2e49fe Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:50 +0100 Subject: [PATCH 726/903] staging:rtl8192u: Rename enum DIRECTION_VALUE - Style The enumerated type DIRECTION_VALUE should be named in lowercase to comply with coding standard so is renamed to direction_value. In addition the 'typedef' directive has been removed to clear the checkpatch issue with defining new types. These changes are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 4 ++-- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 65d7c9f4d840..428a8c4cebf1 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -28,12 +28,12 @@ union aci_aifsn { // Direction Field Values. // Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. // -typedef enum _DIRECTION_VALUE { +enum direction_value { DIR_UP = 0, // 0x00 // UpLink DIR_DOWN = 1, // 0x01 // DownLink DIR_DIRECT = 2, // 0x10 // DirectLink DIR_BI_DIR = 3, // 0x11 // Bi-Direction -} DIRECTION_VALUE, *PDIRECTION_VALUE; +}; // diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index a44536d8cd42..2731e46556f4 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -366,7 +366,7 @@ bool GetTs( (&ieee->Tx_TS_Admit_List): (&ieee->Rx_TS_Admit_List); - DIRECTION_VALUE Dir = (ieee->iw_mode == IW_MODE_MASTER)? + enum direction_value Dir = (ieee->iw_mode == IW_MODE_MASTER)? ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); IEEE80211_DEBUG(IEEE80211_DL_TS, "to add Ts\n"); From 8e542c484c80ced3d849b2e5380deb8bc4329368 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:51 +0100 Subject: [PATCH 727/903] staging:rtl8192u: Rename union QOS_TSINFO - Style The union QOS_TSINFO, as a type, should have a lowercase name. The union has therefore been renamed to qos_tsinfo. Additionally the 'typedef' directive has been removed to clear the checkpatch issue with defining new types. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 428a8c4cebf1..17b676b0ed8b 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -42,7 +42,7 @@ enum direction_value { // 1. WMM spec 2.2.11: WME TSPEC Element, p.18. // 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h] // -typedef union _QOS_TSINFO { +union qos_tsinfo { u8 charData[3]; struct { u8 ucTrafficType:1; //WMM is reserved @@ -56,7 +56,7 @@ typedef union _QOS_TSINFO { u8 ucSchedule:1; //WMM is reserved u8 ucReserved:7; } field; -} QOS_TSINFO, *PQOS_TSINFO; +}; // // WMM TSPEC Body. @@ -66,7 +66,7 @@ typedef union _TSPEC_BODY { u8 charData[55]; struct { - QOS_TSINFO TSInfo; //u8 TSInfo[3]; + union qos_tsinfo TSInfo; //u8 TSInfo[3]; u16 NominalMSDUsize; u16 MaxMSDUsize; u32 MinServiceItv; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 2731e46556f4..c21bf3d3b242 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -355,7 +355,7 @@ bool GetTs( // For HCCA or WMMSA, TS cannot be addmit without negotiation. // TSPEC_BODY TSpec; - PQOS_TSINFO pTSInfo = &TSpec.f.TSInfo; + union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; struct list_head *pUnusedList = (TxRxSelect == TX_DIR)? (&ieee->Tx_TS_Unused_List): From 8f0edc1125dd49a0af27d8a42406226f3effb18a Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 00:14:52 +0100 Subject: [PATCH 728/903] staging:rtl8192u: Remove unused constants - Style Remove defined constants from code, since they are never actually used in code. This is a simple coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 17b676b0ed8b..810d81addcf6 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -2,13 +2,6 @@ #ifndef __INC_QOS_TYPE_H #define __INC_QOS_TYPE_H -#define MAX_WMMELE_LENGTH 64 - -#define AC_PARAM_SIZE 4 -#define WMM_PARAM_ELE_BODY_LEN 18 - -#define WMM_PARAM_ELEMENT_SIZE (8 + (4 * AC_PARAM_SIZE)) - // // ACI/AIFSN Field. // Ref: WMM spec 2.2.2: WME Parameter Element, p.12. From ac2028a77dfc8fa2add5c308f2eb6de773f6a607 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:33 +0100 Subject: [PATCH 729/903] staging:rtl8192u: Remove typedef of struct cmpk_txfb_t - Style Remove the typedef of the structure cmpk_txfb_t. This clears the checkpatch issue with defining new types. Additionally the type is renamed from cmpk_txfb_t to cmd_pkt_tx_feedback removing the '_t' as the typedef has been removed. These changes are purely coding style in nature and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 8 ++++---- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 3140b3413f91..630cf612f265 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -66,7 +66,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) * Overview: * * Input: PADAPTER pAdapter - * CMPK_TXFB_T *psTx_FB + * STRUCT CMD_PKT_TX_FEEDBACK *psTx_FB * * Output: NONE * @@ -78,7 +78,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) * *--------------------------------------------------------------------------- */ -static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) +static void cmpk_count_txstatistic(struct net_device *dev, struct cmd_pkt_tx_feedback *pstx_fb) { struct r8192_priv *priv = ieee80211_priv(dev); #ifdef ENABLE_PS @@ -163,7 +163,7 @@ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) { struct r8192_priv *priv = ieee80211_priv(dev); - cmpk_txfb_t rx_tx_fb; + struct cmd_pkt_tx_feedback rx_tx_fb; priv->stats.txfeedback++; @@ -173,7 +173,7 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) * endian type before copy the message copy. */ /* Use pointer to transfer structure memory. */ - memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); + memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(struct cmd_pkt_tx_feedback)); /* 2. Use tx feedback info to count TX statistics. */ cmpk_count_txstatistic(dev, &rx_tx_fb); /* Comment previous method for TX statistic function. */ diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 0eb6b2321c9c..756e08bd341a 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -2,7 +2,7 @@ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H /* Different command packet have dedicated message length and definition. */ -#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) /* 20 */ +#define CMPK_RX_TX_FB_SIZE sizeof(struct cmd_pkt_tx_feedback) /* 20 */ #define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ #define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) @@ -19,7 +19,7 @@ /*------------------------------Define structure----------------------------*/ /* Define different command packet structure. */ /* 1. RX side: TX feedback packet. */ -typedef struct tag_cmd_pkt_tx_feedback { +struct cmd_pkt_tx_feedback { /* DWORD 0 */ u8 element_id; /* Command packet type. */ u8 length; /* Command packet length. */ @@ -52,7 +52,7 @@ typedef struct tag_cmd_pkt_tx_feedback { /* DWORD 5 */ u16 reserve3; u16 duration; -} cmpk_txfb_t; +}; /* 2. RX side: Interrupt status packet. It includes Beacon State, * Beacon Timer Interrupt and other useful informations in MAC ISR Reg. From b14947da727c132878517f7387ccd6ee77acffec Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:34 +0100 Subject: [PATCH 730/903] staging:rtl8192u: Remove unused CMPK_TX_SET_CONFIG_SIZE - Style Remove the unused macro CMPK_TX_SET_CONFIG_SIZE. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 756e08bd341a..fab982668b44 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -3,7 +3,6 @@ #define R819XUSB_CMDPKT_H /* Different command packet have dedicated message length and definition. */ #define CMPK_RX_TX_FB_SIZE sizeof(struct cmd_pkt_tx_feedback) /* 20 */ -#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ #define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) #define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t) From 171b51a9b710d4d8e9c33aafbbc5b09408153be6 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:35 +0100 Subject: [PATCH 731/903] staging:rtl8192u: Removed unused CMPK_RX_DBG_MSG_SIZE - Style Remove the unused macro definition CMPK_RX_DBG_MSG_SIZE. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index fab982668b44..50218d9a406b 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -5,7 +5,6 @@ #define CMPK_RX_TX_FB_SIZE sizeof(struct cmd_pkt_tx_feedback) /* 20 */ #define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ #define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) -#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t) #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) /* 2008/05/08 amy For USB constant. */ From 9989b9d131a1dedd6d3a9c4371408fb35c224e92 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:36 +0100 Subject: [PATCH 732/903] staging:rtl8192u: Correct spelling in comments - style Correct the spelling of a number of comments, which cause a checkpatch issue. This is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 50218d9a406b..d2e07b0ff30b 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -53,7 +53,7 @@ struct cmd_pkt_tx_feedback { }; /* 2. RX side: Interrupt status packet. It includes Beacon State, - * Beacon Timer Interrupt and other useful informations in MAC ISR Reg. + * Beacon Timer Interrupt and other useful information in MAC ISR Reg. */ typedef struct tag_cmd_pkt_interrupt_status { u8 element_id; /* Command packet type. */ @@ -80,7 +80,7 @@ typedef struct tag_cmd_pkt_set_configuration { u32 mask; } cmpk_set_cfg_t; -/* 4. Both side : TX/RX query configuraton packet. The query structure is the +/* 4. Both side : TX/RX query configuration packet. The query structure is the * same as set configuration. */ #define cmpk_query_cfg_t cmpk_set_cfg_t From 17a16b769466e2c44dc8ee8ea22442ac8bafa5eb Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:37 +0100 Subject: [PATCH 733/903] staging:rtl8192u: Remove typedef of cmpk_intr_sta_t - Style Remove the typedef of struct cmpk_intr_sta_t, the name of the structure has been left as cmd_pkt_interrupt_status. This clears the checkpatch issue with creating new types in code. The change is purely a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 6 +++--- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 630cf612f265..c71fda0f13b2 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -225,7 +225,7 @@ static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) */ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) { - cmpk_intr_sta_t rx_intr_status; /* */ + struct cmd_pkt_interrupt_status rx_intr_status; /* */ struct r8192_priv *priv = ieee80211_priv(dev); DMESG("---> cmpk_Handle_Interrupt_Status()\n"); @@ -236,7 +236,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) * endian type before copy the message copy. */ rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) { + if (rx_intr_status.length != (sizeof(struct cmd_pkt_interrupt_status) - 2)) { DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); return; } @@ -528,7 +528,7 @@ u32 cmpk_message_handle_rx(struct net_device *dev, case RX_INTERRUPT_STATUS: cmpk_handle_interrupt_status(dev, pcmd_buff); - cmd_length = sizeof(cmpk_intr_sta_t); + cmd_length = sizeof(struct cmd_pkt_interrupt_status); break; case BOTH_QUERY_CONFIG: diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index d2e07b0ff30b..d2590b00fe98 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -55,12 +55,12 @@ struct cmd_pkt_tx_feedback { /* 2. RX side: Interrupt status packet. It includes Beacon State, * Beacon Timer Interrupt and other useful information in MAC ISR Reg. */ -typedef struct tag_cmd_pkt_interrupt_status { +struct cmd_pkt_interrupt_status { u8 element_id; /* Command packet type. */ u8 length; /* Command packet length. */ u16 reserve; u32 interrupt_status; /* Interrupt Status. */ -} cmpk_intr_sta_t; +}; /* 3. TX side: Set configuration packet. */ typedef struct tag_cmd_pkt_set_configuration { From e2102bc362a2ac518b5bddc5ef857f1e52103d79 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:38 +0100 Subject: [PATCH 734/903] staging:rtl8192u: Remove typedef of cmpk_set_cfg_t - Style Remove the typedef from cmpk_set_cfg_t, leaving the structure as struct cmd_pkt_set_configuration. This change clears the checkpatch issue with defining new types. The change is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +- drivers/staging/rtl8192u/r819xU_cmdpkt.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index c71fda0f13b2..d2293a335ed1 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -288,7 +288,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) */ static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) { - cmpk_query_cfg_t rx_query_cfg; + struct cmpk_query_cfg rx_query_cfg; /* 1. Extract TX feedback info from RFD to temp structure buffer. */ /* It seems that FW use big endian(MIPS) and DRV use little endian in diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index d2590b00fe98..be45cd609d67 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -3,7 +3,7 @@ #define R819XUSB_CMDPKT_H /* Different command packet have dedicated message length and definition. */ #define CMPK_RX_TX_FB_SIZE sizeof(struct cmd_pkt_tx_feedback) /* 20 */ -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ +#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmd_pkt_set_configuration) /* 16 */ #define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) @@ -63,7 +63,7 @@ struct cmd_pkt_interrupt_status { }; /* 3. TX side: Set configuration packet. */ -typedef struct tag_cmd_pkt_set_configuration { +struct cmd_pkt_set_configuration { u8 element_id; /* Command packet type. */ u8 length; /* Command packet length. */ u16 reserve1; @@ -78,12 +78,12 @@ typedef struct tag_cmd_pkt_set_configuration { u8 cfg_offset; u32 value; u32 mask; -} cmpk_set_cfg_t; +}; /* 4. Both side : TX/RX query configuration packet. The query structure is the * same as set configuration. */ -#define cmpk_query_cfg_t cmpk_set_cfg_t +#define cmpk_query_cfg cmd_pkt_set_configuration /* 5. Multi packet feedback status. */ typedef struct tag_tx_stats_feedback { From e0043d14fcb500c9feedb14aa83fe425a4d1d699 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:39 +0100 Subject: [PATCH 735/903] staging:rtl8192u: Refactor use of enum dm_dig_sta_e - Style Refactor the use of the enumerated type dm_dig_sta_e, which is not actually used for type checking by the compiler. The typedef of dm_dig_sta_e is removed to clear the checkpatch issue with defining new types, and the enumerated type is left with the name enum dynamic_init_gain_state The enumerated type defines values for the enumeration, which are used by both dig_state and dig_highpwr_state, (members of the struct dig). Both of those variables were defined as being of type u8. This negates any usefulness of the use of the enumeration, (compiler type checking). To make use of the compiler's type-checking the two member variables, dig_state and dig_highpwr_state have been changed to being of type enum dynamic_init_gain_state. The enumerated type has been moved above the struct dig definition so that the enumeration is already defined when the compiler reaches the two types using the enumerated type. These changes, whilst convoluted, are purely coding style in nature and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index e86dda99c223..078770a8c7bf 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -64,6 +64,13 @@ /*------------------------------Define structure----------------------------*/ + +enum dynamic_init_gain_state { + DM_STA_DIG_OFF = 0, + DM_STA_DIG_ON, + DM_STA_DIG_MAX +}; + /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ struct dig { u8 dig_enable_flag; @@ -77,8 +84,8 @@ struct dig { long rssi_high_power_lowthresh; long rssi_high_power_highthresh; - u8 dig_state; - u8 dig_highpwr_state; + enum dynamic_init_gain_state dig_state; + enum dynamic_init_gain_state dig_highpwr_state; u8 cur_connect_state; u8 pre_connect_state; @@ -98,13 +105,6 @@ struct dig { long rssi_val; }; -typedef enum tag_dynamic_init_gain_state_definition { - DM_STA_DIG_OFF = 0, - DM_STA_DIG_ON, - DM_STA_DIG_MAX -} dm_dig_sta_e; - - /* 2007/10/08 MH Define RATR state. */ typedef enum tag_dynamic_ratr_state_definition { DM_RATR_STA_HIGH = 0, From 06761ce4290ebf3c4e770f7f5a9caec675697204 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:40 +0100 Subject: [PATCH 736/903] staging:rtl8192u: Refactor enum dm_ratr_sta_e usage - Style The enumerated type dm_ratr_sta_e was defined in the file drivers/staging/rtl8192u/r8192U_dm.h but never actually used in that file. The only variable which uses this enumerated type is 'ratr_state', a member variable of the _rate_adaptive structure defined in the file drivers/staging/rtl8192u/r8192U.h. To clarify and place the enumerated type close to where it is used the type was moved to the drivers/staging/rtl8192u/r8192U.h file. In addition the member variable 'ratr_state' which uses the enumerated constants was declared as being of type 'u8'. This negates any advantage of the enumerated type, compiler type-checking, so that member variable's type has been changed to being of the enumerated type. The typedef from the enumerated type has been removed to clear the checkpatch issue with defining new types. Additionally the name of the type has been left as enum dynamic_ratr_state This is a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 10 +++++++++- drivers/staging/rtl8192u/r8192U_dm.h | 8 -------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index e615d9b3f6b1..94a148994069 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -662,9 +662,17 @@ typedef enum _RT_RF_TYPE_819xU { RF_PSEUDO_11N = 4, } RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU; +/* 2007/10/08 MH Define RATR state. */ +enum dynamic_ratr_state { + DM_RATR_STA_HIGH = 0, + DM_RATR_STA_MIDDLE = 1, + DM_RATR_STA_LOW = 2, + DM_RATR_STA_MAX +}; + typedef struct _rate_adaptive { u8 rate_adaptive_disabled; - u8 ratr_state; + enum dynamic_ratr_state ratr_state; u16 reserve; u32 high_rssi_thresh_for_ra; diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 078770a8c7bf..d7bd257a7e93 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -105,14 +105,6 @@ struct dig { long rssi_val; }; -/* 2007/10/08 MH Define RATR state. */ -typedef enum tag_dynamic_ratr_state_definition { - DM_RATR_STA_HIGH = 0, - DM_RATR_STA_MIDDLE = 1, - DM_RATR_STA_LOW = 2, - DM_RATR_STA_MAX -} dm_ratr_sta_e; - /* 2007/10/11 MH Define DIG operation type. */ typedef enum tag_dynamic_init_gain_operation_type_definition { DIG_TYPE_THRESH_HIGH = 0, From fb2a2729720f91866ed255dc19402a5ef1d561ad Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:41 +0100 Subject: [PATCH 737/903] staging:rtl8192u: Remove enum dm_dig_op_e - Style Remove the enumerated type dm_dig_op_e. The type is only used as a parameter to the function dm_change_dynamic_initgain_thresh(), but that function is never referenced in the code at all. I would consider this to be a coding style change as the function is never referenced and as a result the enumeration is never used. In any case there should be no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 91 ---------------------------- drivers/staging/rtl8192u/r8192U_dm.h | 20 ------ 2 files changed, 111 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 7dc912dd53af..92ba1fdd9831 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1613,97 +1613,6 @@ static void dm_bb_initialgain_backup(struct net_device *dev) } /* dm_BBInitialGainBakcup */ #endif -/*----------------------------------------------------------------------------- - * Function: dm_change_dynamic_initgain_thresh() - * - * Overview: - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 05/29/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ - -void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type, - u32 dm_value) -{ - switch (dm_type) { - case DIG_TYPE_THRESH_HIGH: - dm_digtable.rssi_high_thresh = dm_value; - break; - - case DIG_TYPE_THRESH_LOW: - dm_digtable.rssi_low_thresh = dm_value; - break; - - case DIG_TYPE_THRESH_HIGHPWR_HIGH: - dm_digtable.rssi_high_power_highthresh = dm_value; - break; - - case DIG_TYPE_THRESH_HIGHPWR_LOW: - dm_digtable.rssi_high_power_lowthresh = dm_value; - break; - - case DIG_TYPE_ENABLE: - dm_digtable.dig_state = DM_STA_DIG_MAX; - dm_digtable.dig_enable_flag = true; - break; - - case DIG_TYPE_DISABLE: - dm_digtable.dig_state = DM_STA_DIG_MAX; - dm_digtable.dig_enable_flag = false; - break; - - case DIG_TYPE_DBG_MODE: - if (dm_value >= DM_DBG_MAX) - dm_value = DM_DBG_OFF; - dm_digtable.dbg_mode = (u8)dm_value; - break; - - case DIG_TYPE_RSSI: - if (dm_value > 100) - dm_value = 30; - dm_digtable.rssi_val = (long)dm_value; - break; - - case DIG_TYPE_ALGORITHM: - if (dm_value >= DIG_ALGO_MAX) - dm_value = DIG_ALGO_BY_FALSE_ALARM; - if (dm_digtable.dig_algorithm != (u8)dm_value) - dm_digtable.dig_algorithm_switch = 1; - dm_digtable.dig_algorithm = (u8)dm_value; - break; - - case DIG_TYPE_BACKOFF: - if (dm_value > 30) - dm_value = 30; - dm_digtable.backoff_val = (u8)dm_value; - break; - - case DIG_TYPE_RX_GAIN_MIN: - if (dm_value == 0) - dm_value = 0x1; - dm_digtable.rx_gain_range_min = (u8)dm_value; - break; - - case DIG_TYPE_RX_GAIN_MAX: - if (dm_value > 0x50) - dm_value = 0x50; - dm_digtable.rx_gain_range_max = (u8)dm_value; - break; - - default: - break; - } - -} /* DM_ChangeDynamicInitGainThresh */ - /*----------------------------------------------------------------------------- * Function: dm_dig_init() * diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index d7bd257a7e93..471609819e08 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -105,24 +105,6 @@ struct dig { long rssi_val; }; -/* 2007/10/11 MH Define DIG operation type. */ -typedef enum tag_dynamic_init_gain_operation_type_definition { - DIG_TYPE_THRESH_HIGH = 0, - DIG_TYPE_THRESH_LOW = 1, - DIG_TYPE_THRESH_HIGHPWR_HIGH = 2, - DIG_TYPE_THRESH_HIGHPWR_LOW = 3, - DIG_TYPE_DBG_MODE = 4, - DIG_TYPE_RSSI = 5, - DIG_TYPE_ALGORITHM = 6, - DIG_TYPE_BACKOFF = 7, - DIG_TYPE_PWDB_FACTOR = 8, - DIG_TYPE_RX_GAIN_MIN = 9, - DIG_TYPE_RX_GAIN_MAX = 10, - DIG_TYPE_ENABLE = 20, - DIG_TYPE_DISABLE = 30, - DIG_OP_TYPE_MAX -} dm_dig_op_e; - typedef enum tag_dig_algorithm_definition { DIG_ALGO_BY_FALSE_ALARM = 0, DIG_ALGO_BY_RSSI = 1, @@ -209,8 +191,6 @@ void init_rate_adaptive(struct net_device *dev); void dm_txpower_trackingcallback(struct work_struct *work); void dm_restore_dynamic_mechanism_state(struct net_device *dev); void dm_backup_dynamic_mechanism_state(struct net_device *dev); -void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, u32 dm_value); void dm_force_tx_fw_info(struct net_device *dev, u32 force_type, u32 force_value); void dm_init_edca_turbo(struct net_device *dev); From ebd0dcbd93b58bca8a07710eb8f2f4bc29b67e2e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:42 +0100 Subject: [PATCH 738/903] staging:rtl8192u: Refactor enum dm_dig_alg_e - Style The enumerated type dm_dig_alg_e is only used by one variable in the code, 'dig_algorithm', a member variable of the structure dig. That member variable was defined to be of type 'u8' thus negating any advantage of the use of an enumerated type, (compiler type-checking). The type of the variable 'dig_algorithm' has been change to reflect its use of the enumeration and the enumerated type moved in the file so that it appears before it is used in the file. Additionally the 'typedef' has been removed to clear the checkpatch issue with defining new types, and the type renamed to enum dig_algorithm. The enumerated constant DIG_ALGO_MAX has been removed from the type since it is never used in the code. These changes are all coding style in nature and as such should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 471609819e08..9cea9b818843 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -65,6 +65,11 @@ /*------------------------------Define structure----------------------------*/ +enum dig_algorithm { + DIG_ALGO_BY_FALSE_ALARM = 0, + DIG_ALGO_BY_RSSI = 1, +}; + enum dynamic_init_gain_state { DM_STA_DIG_OFF = 0, DM_STA_DIG_ON, @@ -74,7 +79,7 @@ enum dynamic_init_gain_state { /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ struct dig { u8 dig_enable_flag; - u8 dig_algorithm; + enum dig_algorithm dig_algorithm; u8 dbg_mode; u8 dig_algorithm_switch; @@ -105,12 +110,6 @@ struct dig { long rssi_val; }; -typedef enum tag_dig_algorithm_definition { - DIG_ALGO_BY_FALSE_ALARM = 0, - DIG_ALGO_BY_RSSI = 1, - DIG_ALGO_MAX -} dm_dig_alg_e; - typedef enum tag_dig_dbgmode_definition { DIG_DBG_OFF = 0, DIG_DBG_ON = 1, From 9888151133c8e6c9e5eefc62cd72239ed1a94454 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:43 +0100 Subject: [PATCH 739/903] staging:rtl8192u: Remove unused enum dm_dig_dbg_e - Style The enumerated type dm_dig_dbg_e is never used in code so has simply been removed from the source code. this is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 9cea9b818843..c15faa428b1d 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -110,12 +110,6 @@ struct dig { long rssi_val; }; -typedef enum tag_dig_dbgmode_definition { - DIG_DBG_OFF = 0, - DIG_DBG_ON = 1, - DIG_DBG_MAX -} dm_dig_dbg_e; - typedef enum tag_dig_connect_definition { DIG_DISCONNECT = 0, DIG_CONNECT = 1, From c3575c7c564a89405d9c2632a74f89cc3aaa3973 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:44 +0100 Subject: [PATCH 740/903] staging:rtl8192u: Refactor dm_dig_connect_e - Style The enumerated type dm_dig_connect_e is only used to group constant values, as the actual type is never used as the type for the variables which use the defined constants (cur_connect_state and pre_connect_state). These two member variables have had there defined types changed to properly reflect there usage and to permit compiler type checks to be performed. In addition the definition of the enumerated type has been moved above the structure which uses the type. The typedef of the enumerated type has been removed to clear the checkpatch issue with defining new types and the enumerated value DIG_CONNECT_MAX has been removed since it is never used in code. The resulting changes are all coding style in nature and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index c15faa428b1d..8de6d15fb659 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -76,6 +76,11 @@ enum dynamic_init_gain_state { DM_STA_DIG_MAX }; +enum dig_connect { + DIG_DISCONNECT = 0, + DIG_CONNECT = 1, +}; + /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ struct dig { u8 dig_enable_flag; @@ -91,8 +96,8 @@ struct dig { enum dynamic_init_gain_state dig_state; enum dynamic_init_gain_state dig_highpwr_state; - u8 cur_connect_state; - u8 pre_connect_state; + enum dig_connect cur_connect_state; + enum dig_connect pre_connect_state; u8 curpd_thstate; u8 prepd_thstate; @@ -110,12 +115,6 @@ struct dig { long rssi_val; }; -typedef enum tag_dig_connect_definition { - DIG_DISCONNECT = 0, - DIG_CONNECT = 1, - DIG_CONNECT_MAX -} dm_dig_connect_e; - typedef enum tag_dig_packetdetection_threshold_definition { DIG_PD_AT_LOW_POWER = 0, DIG_PD_AT_NORMAL_POWER = 1, From a48aa566becb1f15e123db3450289c7cdb9b1d5d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:45 +0100 Subject: [PATCH 741/903] staging:rtl8192u: Refactor enum dm_dig_pd_th_e - Style The enumerated type dm_dig_pd_th_e is never actually used as the type for the two variables which use the constants, which the enumeration defines. This omission removes the possibility of taking advantage of compiler type checking. To correct this the two member variables, (curpd_thstate & prepd_thstate) have been changed to use the type enum dig_pkt_detection_threshold rather then u8. Additionally the enum's declaration has been moved above the dig structure, where the type is used, the 'typedef' has been removed to clear the checkpatch issue with defining new types, and the value 'DIG_PD_MAX' has been removed from the enumeration, since it is never used in code. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 8de6d15fb659..f9d75ad9eaee 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -81,6 +81,12 @@ enum dig_connect { DIG_CONNECT = 1, }; +enum dig_pkt_detection_threshold { + DIG_PD_AT_LOW_POWER = 0, + DIG_PD_AT_NORMAL_POWER = 1, + DIG_PD_AT_HIGH_POWER = 2, +}; + /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ struct dig { u8 dig_enable_flag; @@ -99,8 +105,8 @@ struct dig { enum dig_connect cur_connect_state; enum dig_connect pre_connect_state; - u8 curpd_thstate; - u8 prepd_thstate; + enum dig_pkt_detection_threshold curpd_thstate; + enum dig_pkt_detection_threshold prepd_thstate; u8 curcs_ratio_state; u8 precs_ratio_state; @@ -115,13 +121,6 @@ struct dig { long rssi_val; }; -typedef enum tag_dig_packetdetection_threshold_definition { - DIG_PD_AT_LOW_POWER = 0, - DIG_PD_AT_NORMAL_POWER = 1, - DIG_PD_AT_HIGH_POWER = 2, - DIG_PD_MAX -} dm_dig_pd_th_e; - typedef enum tag_dig_cck_cs_ratio_state_definition { DIG_CS_RATIO_LOWER = 0, DIG_CS_RATIO_HIGHER = 1, From cff3d470010a74b96efc7790a7acc2e908761e64 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:46 +0100 Subject: [PATCH 742/903] staging:rtl8192u: Refactor enum dm_dig_cs_ratio_e - Style The enumerated type dm_dig_cs_ratio_e is never actually used as a type, but only as a collection of related constants. This is because the variables, which use the defined constant values, are defined as being of type u8 rather then tne enumerated type. This omission negates the possibility of taking advantage of compiler type checking. To enable the use of compiler type checking of the enumeration the two variables, (curcs_ratio_state & precs_ratio_state), which use the type's constants have their types changed from u8 to enum dig_cck_cs_ratio_state. Additionally the types declaration has been moved above the dig structure, where the type is used. The 'typedef' keyword has been removed from the type to clear the checkpatch issue with defining new types. And the constant DIG_CS_MAX has been removed since this is never used in the code. These changes are purely coding style changes and should not impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index f9d75ad9eaee..f0e259ddea5d 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -87,6 +87,11 @@ enum dig_pkt_detection_threshold { DIG_PD_AT_HIGH_POWER = 2, }; +enum dig_cck_cs_ratio_state { + DIG_CS_RATIO_LOWER = 0, + DIG_CS_RATIO_HIGHER = 1, +}; + /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ struct dig { u8 dig_enable_flag; @@ -107,8 +112,8 @@ struct dig { enum dig_pkt_detection_threshold curpd_thstate; enum dig_pkt_detection_threshold prepd_thstate; - u8 curcs_ratio_state; - u8 precs_ratio_state; + enum dig_cck_cs_ratio_state curcs_ratio_state; + enum dig_cck_cs_ratio_state precs_ratio_state; u32 pre_ig_value; u32 cur_ig_value; @@ -121,11 +126,6 @@ struct dig { long rssi_val; }; -typedef enum tag_dig_cck_cs_ratio_state_definition { - DIG_CS_RATIO_LOWER = 0, - DIG_CS_RATIO_HIGHER = 1, - DIG_CS_MAX -} dm_dig_cs_ratio_e; struct dynamic_rx_path_sel { u8 Enable; u8 DbgMode; From 1c58e9cc5b56d43b6121792c4b7f81b8dc4463cc Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sun, 29 Jul 2018 22:07:47 +0100 Subject: [PATCH 743/903] staging:rtl8192u: Refactor enum DM_CCK_Rx_Path_Method - Style The enumerated type DM_CCK_Rx_Path_Method is used as a container for constant definitions, rather then an enumerated type enabling compiler type checking. To correct this, the variable which uses the constants, defined by the enumeration, has had its type changed from a u8 to the enumeration. Additionally the type has been moved above the structure where the type is used, to avoid compiler error. The typedef has been removed from the enumerated type to clear the checkpatch issue with defining new types. The name of the type has been changed to cck_rx_path_method to clear the checkpatch issue with CamelCase naming. And the enumerated constant CCK_Rx_Version_MAX has been removed, since it is never used in code. The changes are all coding style in nature and so should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index f0e259ddea5d..2ba6a4208870 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -126,10 +126,15 @@ struct dig { long rssi_val; }; +enum cck_rx_path_method { + CCK_Rx_Version_1 = 0, + CCK_Rx_Version_2 = 1, +}; + struct dynamic_rx_path_sel { u8 Enable; u8 DbgMode; - u8 cck_method; + enum cck_rx_path_method cck_method; u8 cck_Rx_path; u8 SS_TH_low; @@ -142,12 +147,6 @@ struct dynamic_rx_path_sel { long cck_pwdb_sta[4]; }; -typedef enum tag_CCK_Rx_Path_Method_Definition { - CCK_Rx_Version_1 = 0, - CCK_Rx_Version_2 = 1, - CCK_Rx_Version_MAX -} DM_CCK_Rx_Path_Method; - typedef enum tag_DM_DbgMode_Definition { DM_DBG_OFF = 0, DM_DBG_ON = 1, From 1e96e93a3569fd7a4d3199d9d912345ad3b8ce4c Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 30 Jul 2018 13:59:18 +0100 Subject: [PATCH 744/903] iio: light: si1133 fix test for val being not zero or not one. The current check on val always results in true and so the call to sii1133_update_adcsens never gets called. Fix this check so it returns with -EINVAL only when val is not zero and not one. Detected by CoverityScan, CID#1472099 ("Logically dead code") Fixes: e01e7eaf37d8 ("iio: light: introduce si1133") Signed-off-by: Colin Ian King Signed-off-by: Jonathan Cameron --- drivers/iio/light/si1133.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c index d3fbeb3bc463..5ac22c46da1f 100644 --- a/drivers/iio/light/si1133.c +++ b/drivers/iio/light/si1133.c @@ -838,7 +838,7 @@ static int si1133_write_raw(struct iio_dev *iio_dev, switch (chan->type) { case IIO_INTENSITY: case IIO_UVINDEX: - if (val != 0 || val != 1) + if (val != 0 && val != 1) return -EINVAL; return si1133_update_adcsens(data, From fc6152f4650394ee8d1afa32492f510d54f62e02 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 1 Aug 2018 17:36:54 +0800 Subject: [PATCH 745/903] staging: erofs: add the missing break in z_erofs_map_blocks_iter This patch adds a missing break after adding the default case. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index bd2d7a8d5085..1030ca5c2dc3 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1599,6 +1599,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: if (ofs_rem >= logical_cluster_ofs) map->m_flags ^= EROFS_MAP_ZIPPED; + /* fallthrough */ case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: if (ofs_rem == logical_cluster_ofs) { pcn = le32_to_cpu(di->di_u.blkaddr); @@ -1619,11 +1620,13 @@ int z_erofs_map_blocks_iter(struct inode *inode, goto unmap_out; } end = (lcn-- * clustersize) | logical_cluster_ofs; + /* fallthrough */ case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: /* get the correspoinding first chunk */ ofs = vle_get_logical_extent_head(inode, mpage_ret, &kaddr, lcn, &pcn, &map->m_flags); mpage = *mpage_ret; + break; default: errln("unknown cluster type %u at offset %llu of nid %llu", cluster_type, ofs, EROFS_V(inode)->nid); From 24daf6a3c97457174f5cc075e5a210d634cfa04f Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 1 Aug 2018 14:38:31 +0800 Subject: [PATCH 746/903] staging: erofs: remove a redundant marco in xattr There is no need to '#if CONFIG_EROFS_FS_XATTR' in xattr.c, let's remove it. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/xattr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c index b74b314a2e3a..6b9685fa601c 100644 --- a/drivers/staging/erofs/xattr.c +++ b/drivers/staging/erofs/xattr.c @@ -420,7 +420,6 @@ const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { }; #endif -#ifdef CONFIG_EROFS_FS_XATTR const struct xattr_handler *erofs_xattr_handlers[] = { &erofs_xattr_user_handler, #ifdef CONFIG_EROFS_FS_POSIX_ACL @@ -433,7 +432,6 @@ const struct xattr_handler *erofs_xattr_handlers[] = { #endif NULL, }; -#endif struct listxattr_iter { struct xattr_iter it; From 500cc548c8ebe7494ba37673c3ec1faa342858c3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 1 Aug 2018 19:56:17 +0200 Subject: [PATCH 747/903] staging: comedi: drop serial2002 driver There's not been any work on this driver since it was originally merged, and it really needs to be rewritten to use the serdev layer instead if people really need/want it. Reported-by: Christoph Hellwig Cc: Ian Abbott Cc: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 8 - drivers/staging/comedi/drivers/Makefile | 1 - drivers/staging/comedi/drivers/serial2002.c | 778 -------------------- 3 files changed, 787 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/serial2002.c diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 4218fc0e17f1..583bce9bb18e 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -75,14 +75,6 @@ config COMEDI_PARPORT To compile this driver as a module, choose M here: the module will be called comedi_parport. -config COMEDI_SERIAL2002 - tristate "Driver for serial connected hardware" - ---help--- - Enable support for serial connected hardware - - To compile this driver as a module, choose M here: the module will be - called serial2002. - config COMEDI_SSV_DNP tristate "SSV Embedded Systems DIL/Net-PC support" depends on X86_32 || COMPILE_TEST diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 736e7e55219d..98b42b47dfe1 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -11,7 +11,6 @@ obj-$(CONFIG_COMEDI_ISADMA) += comedi_isadma.o obj-$(CONFIG_COMEDI_BOND) += comedi_bond.o obj-$(CONFIG_COMEDI_TEST) += comedi_test.o obj-$(CONFIG_COMEDI_PARPORT) += comedi_parport.o -obj-$(CONFIG_COMEDI_SERIAL2002) += serial2002.o # Comedi ISA drivers obj-$(CONFIG_COMEDI_AMPLC_DIO200_ISA) += amplc_dio200.o diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c deleted file mode 100644 index 5471b2212a62..000000000000 --- a/drivers/staging/comedi/drivers/serial2002.c +++ /dev/null @@ -1,778 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * serial2002.c - * Comedi driver for serial connected hardware - * - * COMEDI - Linux Control and Measurement Device Interface - * Copyright (C) 2002 Anders Blomdell - */ - -/* - * Driver: serial2002 - * Description: Driver for serial connected hardware - * Devices: - * Author: Anders Blomdell - * Updated: Fri, 7 Jun 2002 12:56:45 -0700 - * Status: in development - */ - -#include -#include "../comedidev.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -struct serial2002_range_table_t { - /* HACK... */ - int length; - struct comedi_krange range; -}; - -struct serial2002_private { - int port; /* /dev/ttyS */ - int speed; /* baudrate */ - struct file *tty; - unsigned int ao_readback[32]; - unsigned char digital_in_mapping[32]; - unsigned char digital_out_mapping[32]; - unsigned char analog_in_mapping[32]; - unsigned char analog_out_mapping[32]; - unsigned char encoder_in_mapping[32]; - struct serial2002_range_table_t in_range[32], out_range[32]; -}; - -struct serial_data { - enum { is_invalid, is_digital, is_channel } kind; - int index; - unsigned long value; -}; - -/* - * The configuration serial_data.value read from the device is - * a bitmask that defines specific options of a channel: - * - * 4:0 - the channel to configure - * 7:5 - the kind of channel - * 9:8 - the command used to configure the channel - * - * The remaining bits vary in use depending on the command: - * - * BITS 15:10 - the channel bits (maxdata) - * MIN/MAX 12:10 - the units multiplier for the scale - * 13 - the sign of the scale - * 33:14 - the base value for the range - */ -#define S2002_CFG_CHAN(x) ((x) & 0x1f) -#define S2002_CFG_KIND(x) (((x) >> 5) & 0x7) -#define S2002_CFG_KIND_INVALID 0 -#define S2002_CFG_KIND_DIGITAL_IN 1 -#define S2002_CFG_KIND_DIGITAL_OUT 2 -#define S2002_CFG_KIND_ANALOG_IN 3 -#define S2002_CFG_KIND_ANALOG_OUT 4 -#define S2002_CFG_KIND_ENCODER_IN 5 -#define S2002_CFG_CMD(x) (((x) >> 8) & 0x3) -#define S2002_CFG_CMD_BITS 0 -#define S2002_CFG_CMD_MIN 1 -#define S2002_CFG_CMD_MAX 2 -#define S2002_CFG_BITS(x) (((x) >> 10) & 0x3f) -#define S2002_CFG_UNITS(x) (((x) >> 10) & 0x7) -#define S2002_CFG_SIGN(x) (((x) >> 13) & 0x1) -#define S2002_CFG_BASE(x) (((x) >> 14) & 0xfffff) - -static long serial2002_tty_ioctl(struct file *f, unsigned int op, - unsigned long param) -{ - if (f->f_op->unlocked_ioctl) - return f->f_op->unlocked_ioctl(f, op, param); - - return -ENOTTY; -} - -static int serial2002_tty_write(struct file *f, unsigned char *buf, int count) -{ - loff_t pos = 0; - - return kernel_write(f, buf, count, &pos); -} - -static void serial2002_tty_read_poll_wait(struct file *f, int timeout) -{ - struct poll_wqueues table; - ktime_t start, now; - - start = ktime_get(); - poll_initwait(&table); - while (1) { - long elapsed; - __poll_t mask; - - mask = vfs_poll(f, &table.pt); - if (mask & (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | - EPOLLHUP | EPOLLERR)) { - break; - } - now = ktime_get(); - elapsed = ktime_us_delta(now, start); - if (elapsed > timeout) - break; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(((timeout - elapsed) * HZ) / 10000); - } - poll_freewait(&table); -} - -static int serial2002_tty_read(struct file *f, int timeout) -{ - unsigned char ch; - int result; - loff_t pos = 0; - - result = -1; - if (!IS_ERR(f)) { - if (file_can_poll(f)) { - serial2002_tty_read_poll_wait(f, timeout); - - if (kernel_read(f, &ch, 1, &pos) == 1) - result = ch; - } else { - /* Device does not support poll, busy wait */ - int retries = 0; - - while (1) { - retries++; - if (retries >= timeout) - break; - - if (kernel_read(f, &ch, 1, &pos) == 1) { - result = ch; - break; - } - usleep_range(100, 1000); - } - } - } - return result; -} - -static void serial2002_tty_setspeed(struct file *f, int speed) -{ - struct termios termios; - struct serial_struct serial; - mm_segment_t oldfs; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - - /* Set speed */ - serial2002_tty_ioctl(f, TCGETS, (unsigned long)&termios); - termios.c_iflag = 0; - termios.c_oflag = 0; - termios.c_lflag = 0; - termios.c_cflag = CLOCAL | CS8 | CREAD; - termios.c_cc[VMIN] = 0; - termios.c_cc[VTIME] = 0; - switch (speed) { - case 2400: - termios.c_cflag |= B2400; - break; - case 4800: - termios.c_cflag |= B4800; - break; - case 9600: - termios.c_cflag |= B9600; - break; - case 19200: - termios.c_cflag |= B19200; - break; - case 38400: - termios.c_cflag |= B38400; - break; - case 57600: - termios.c_cflag |= B57600; - break; - case 115200: - termios.c_cflag |= B115200; - break; - default: - termios.c_cflag |= B9600; - break; - } - serial2002_tty_ioctl(f, TCSETS, (unsigned long)&termios); - - /* Set low latency */ - serial2002_tty_ioctl(f, TIOCGSERIAL, (unsigned long)&serial); - serial.flags |= ASYNC_LOW_LATENCY; - serial2002_tty_ioctl(f, TIOCSSERIAL, (unsigned long)&serial); - - set_fs(oldfs); -} - -static void serial2002_poll_digital(struct file *f, int channel) -{ - char cmd; - - cmd = 0x40 | (channel & 0x1f); - serial2002_tty_write(f, &cmd, 1); -} - -static void serial2002_poll_channel(struct file *f, int channel) -{ - char cmd; - - cmd = 0x60 | (channel & 0x1f); - serial2002_tty_write(f, &cmd, 1); -} - -static struct serial_data serial2002_read(struct file *f, int timeout) -{ - struct serial_data result; - int length; - - result.kind = is_invalid; - result.index = 0; - result.value = 0; - length = 0; - while (1) { - int data = serial2002_tty_read(f, timeout); - - length++; - if (data < 0) { - break; - } else if (data & 0x80) { - result.value = (result.value << 7) | (data & 0x7f); - } else { - if (length == 1) { - switch ((data >> 5) & 0x03) { - case 0: - result.value = 0; - result.kind = is_digital; - break; - case 1: - result.value = 1; - result.kind = is_digital; - break; - } - } else { - result.value = - (result.value << 2) | ((data & 0x60) >> 5); - result.kind = is_channel; - } - result.index = data & 0x1f; - break; - } - } - return result; -} - -static void serial2002_write(struct file *f, struct serial_data data) -{ - if (data.kind == is_digital) { - unsigned char ch = - ((data.value << 5) & 0x20) | (data.index & 0x1f); - serial2002_tty_write(f, &ch, 1); - } else { - unsigned char ch[6]; - int i = 0; - - if (data.value >= (1L << 30)) { - ch[i] = 0x80 | ((data.value >> 30) & 0x03); - i++; - } - if (data.value >= (1L << 23)) { - ch[i] = 0x80 | ((data.value >> 23) & 0x7f); - i++; - } - if (data.value >= (1L << 16)) { - ch[i] = 0x80 | ((data.value >> 16) & 0x7f); - i++; - } - if (data.value >= (1L << 9)) { - ch[i] = 0x80 | ((data.value >> 9) & 0x7f); - i++; - } - ch[i] = 0x80 | ((data.value >> 2) & 0x7f); - i++; - ch[i] = ((data.value << 5) & 0x60) | (data.index & 0x1f); - i++; - serial2002_tty_write(f, ch, i); - } -} - -struct config_t { - short int kind; - short int bits; - int min; - int max; -}; - -static int serial2002_setup_subdevice(struct comedi_subdevice *s, - struct config_t *cfg, - struct serial2002_range_table_t *range, - unsigned char *mapping, - int kind) -{ - const struct comedi_lrange **range_table_list = NULL; - unsigned int *maxdata_list; - int j, chan; - - for (chan = 0, j = 0; j < 32; j++) { - if (cfg[j].kind == kind) - chan++; - } - s->n_chan = chan; - s->maxdata = 0; - kfree(s->maxdata_list); - maxdata_list = kmalloc_array(s->n_chan, sizeof(unsigned int), - GFP_KERNEL); - if (!maxdata_list) - return -ENOMEM; - s->maxdata_list = maxdata_list; - kfree(s->range_table_list); - s->range_table = NULL; - s->range_table_list = NULL; - if (kind == 1 || kind == 2) { - s->range_table = &range_digital; - } else if (range) { - range_table_list = kmalloc_array(s->n_chan, sizeof(*range), - GFP_KERNEL); - if (!range_table_list) - return -ENOMEM; - s->range_table_list = range_table_list; - } - for (chan = 0, j = 0; j < 32; j++) { - if (cfg[j].kind == kind) { - if (mapping) - mapping[chan] = j; - if (range && range_table_list) { - range[j].length = 1; - range[j].range.min = cfg[j].min; - range[j].range.max = cfg[j].max; - range_table_list[chan] = - (const struct comedi_lrange *)&range[j]; - } - if (cfg[j].bits < 32) - maxdata_list[chan] = (1u << cfg[j].bits) - 1; - else - maxdata_list[chan] = 0xffffffff; - chan++; - } - } - return 0; -} - -static int serial2002_setup_subdevs(struct comedi_device *dev) -{ - struct serial2002_private *devpriv = dev->private; - struct config_t *di_cfg; - struct config_t *do_cfg; - struct config_t *ai_cfg; - struct config_t *ao_cfg; - struct config_t *cfg; - struct comedi_subdevice *s; - int result = 0; - int i; - - /* Allocate the temporary structs to hold the configuration data */ - di_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL); - do_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL); - ai_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL); - ao_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL); - if (!di_cfg || !do_cfg || !ai_cfg || !ao_cfg) { - result = -ENOMEM; - goto err_alloc_configs; - } - - /* Read the configuration from the connected device */ - serial2002_tty_setspeed(devpriv->tty, devpriv->speed); - serial2002_poll_channel(devpriv->tty, 31); - while (1) { - struct serial_data data = serial2002_read(devpriv->tty, 1000); - int kind = S2002_CFG_KIND(data.value); - int channel = S2002_CFG_CHAN(data.value); - int range = S2002_CFG_BASE(data.value); - int cmd = S2002_CFG_CMD(data.value); - - if (data.kind != is_channel || data.index != 31 || - kind == S2002_CFG_KIND_INVALID) - break; - - switch (kind) { - case S2002_CFG_KIND_DIGITAL_IN: - cfg = di_cfg; - break; - case S2002_CFG_KIND_DIGITAL_OUT: - cfg = do_cfg; - break; - case S2002_CFG_KIND_ANALOG_IN: - cfg = ai_cfg; - break; - case S2002_CFG_KIND_ANALOG_OUT: - cfg = ao_cfg; - break; - case S2002_CFG_KIND_ENCODER_IN: - cfg = ai_cfg; - break; - default: - cfg = NULL; - break; - } - if (!cfg) - continue; /* unknown kind, skip it */ - - cfg[channel].kind = kind; - - switch (cmd) { - case S2002_CFG_CMD_BITS: - cfg[channel].bits = S2002_CFG_BITS(data.value); - break; - case S2002_CFG_CMD_MIN: - case S2002_CFG_CMD_MAX: - switch (S2002_CFG_UNITS(data.value)) { - case 0: - range *= 1000000; - break; - case 1: - range *= 1000; - break; - case 2: - range *= 1; - break; - } - if (S2002_CFG_SIGN(data.value)) - range = -range; - if (cmd == S2002_CFG_CMD_MIN) - cfg[channel].min = range; - else - cfg[channel].max = range; - break; - } - } - - /* Fill in subdevice data */ - for (i = 0; i <= 4; i++) { - unsigned char *mapping = NULL; - struct serial2002_range_table_t *range = NULL; - int kind = 0; - - s = &dev->subdevices[i]; - - switch (i) { - case 0: - cfg = di_cfg; - mapping = devpriv->digital_in_mapping; - kind = S2002_CFG_KIND_DIGITAL_IN; - break; - case 1: - cfg = do_cfg; - mapping = devpriv->digital_out_mapping; - kind = S2002_CFG_KIND_DIGITAL_OUT; - break; - case 2: - cfg = ai_cfg; - mapping = devpriv->analog_in_mapping; - range = devpriv->in_range; - kind = S2002_CFG_KIND_ANALOG_IN; - break; - case 3: - cfg = ao_cfg; - mapping = devpriv->analog_out_mapping; - range = devpriv->out_range; - kind = S2002_CFG_KIND_ANALOG_OUT; - break; - case 4: - cfg = ai_cfg; - mapping = devpriv->encoder_in_mapping; - range = devpriv->in_range; - kind = S2002_CFG_KIND_ENCODER_IN; - break; - } - - if (serial2002_setup_subdevice(s, cfg, range, mapping, kind)) - break; /* err handled below */ - } - if (i <= 4) { - /* - * Failed to allocate maxdata_list or range_table_list - * for a subdevice that needed it. - */ - result = -ENOMEM; - for (i = 0; i <= 4; i++) { - s = &dev->subdevices[i]; - kfree(s->maxdata_list); - s->maxdata_list = NULL; - kfree(s->range_table_list); - s->range_table_list = NULL; - } - } - -err_alloc_configs: - kfree(di_cfg); - kfree(do_cfg); - kfree(ai_cfg); - kfree(ao_cfg); - - if (result) { - if (devpriv->tty) { - filp_close(devpriv->tty, NULL); - devpriv->tty = NULL; - } - } - - return result; -} - -static int serial2002_open(struct comedi_device *dev) -{ - struct serial2002_private *devpriv = dev->private; - int result; - char port[20]; - - sprintf(port, "/dev/ttyS%d", devpriv->port); - devpriv->tty = filp_open(port, O_RDWR, 0); - if (IS_ERR(devpriv->tty)) { - result = (int)PTR_ERR(devpriv->tty); - dev_err(dev->class_dev, "file open error = %d\n", result); - } else { - result = serial2002_setup_subdevs(dev); - } - return result; -} - -static void serial2002_close(struct comedi_device *dev) -{ - struct serial2002_private *devpriv = dev->private; - - if (!IS_ERR(devpriv->tty) && devpriv->tty) - filp_close(devpriv->tty, NULL); -} - -static int serial2002_di_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct serial2002_private *devpriv = dev->private; - int n; - int chan; - - chan = devpriv->digital_in_mapping[CR_CHAN(insn->chanspec)]; - for (n = 0; n < insn->n; n++) { - struct serial_data read; - - serial2002_poll_digital(devpriv->tty, chan); - while (1) { - read = serial2002_read(devpriv->tty, 1000); - if (read.kind != is_digital || read.index == chan) - break; - } - data[n] = read.value; - } - return n; -} - -static int serial2002_do_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct serial2002_private *devpriv = dev->private; - int n; - int chan; - - chan = devpriv->digital_out_mapping[CR_CHAN(insn->chanspec)]; - for (n = 0; n < insn->n; n++) { - struct serial_data write; - - write.kind = is_digital; - write.index = chan; - write.value = data[n]; - serial2002_write(devpriv->tty, write); - } - return n; -} - -static int serial2002_ai_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct serial2002_private *devpriv = dev->private; - int n; - int chan; - - chan = devpriv->analog_in_mapping[CR_CHAN(insn->chanspec)]; - for (n = 0; n < insn->n; n++) { - struct serial_data read; - - serial2002_poll_channel(devpriv->tty, chan); - while (1) { - read = serial2002_read(devpriv->tty, 1000); - if (read.kind != is_channel || read.index == chan) - break; - } - data[n] = read.value; - } - return n; -} - -static int serial2002_ao_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct serial2002_private *devpriv = dev->private; - int n; - int chan; - - chan = devpriv->analog_out_mapping[CR_CHAN(insn->chanspec)]; - for (n = 0; n < insn->n; n++) { - struct serial_data write; - - write.kind = is_channel; - write.index = chan; - write.value = data[n]; - serial2002_write(devpriv->tty, write); - devpriv->ao_readback[chan] = data[n]; - } - return n; -} - -static int serial2002_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct serial2002_private *devpriv = dev->private; - int n; - int chan = CR_CHAN(insn->chanspec); - - for (n = 0; n < insn->n; n++) - data[n] = devpriv->ao_readback[chan]; - - return n; -} - -static int serial2002_encoder_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct serial2002_private *devpriv = dev->private; - int n; - int chan; - - chan = devpriv->encoder_in_mapping[CR_CHAN(insn->chanspec)]; - for (n = 0; n < insn->n; n++) { - struct serial_data read; - - serial2002_poll_channel(devpriv->tty, chan); - while (1) { - read = serial2002_read(devpriv->tty, 1000); - if (read.kind != is_channel || read.index == chan) - break; - } - data[n] = read.value; - } - return n; -} - -static int serial2002_attach(struct comedi_device *dev, - struct comedi_devconfig *it) -{ - struct serial2002_private *devpriv; - struct comedi_subdevice *s; - int ret; - - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - - devpriv->port = it->options[0]; - devpriv->speed = it->options[1]; - - ret = comedi_alloc_subdevices(dev, 5); - if (ret) - return ret; - - /* digital input subdevice */ - s = &dev->subdevices[0]; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = 0; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_read = serial2002_di_insn_read; - - /* digital output subdevice */ - s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 0; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_write = serial2002_do_insn_write; - - /* analog input subdevice */ - s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_GROUND; - s->n_chan = 0; - s->maxdata = 1; - s->range_table = NULL; - s->insn_read = serial2002_ai_insn_read; - - /* analog output subdevice */ - s = &dev->subdevices[3]; - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 0; - s->maxdata = 1; - s->range_table = NULL; - s->insn_write = serial2002_ao_insn_write; - s->insn_read = serial2002_ao_insn_read; - - /* encoder input subdevice */ - s = &dev->subdevices[4]; - s->type = COMEDI_SUBD_COUNTER; - s->subdev_flags = SDF_READABLE | SDF_LSAMPL; - s->n_chan = 0; - s->maxdata = 1; - s->range_table = NULL; - s->insn_read = serial2002_encoder_insn_read; - - dev->open = serial2002_open; - dev->close = serial2002_close; - - return 0; -} - -static void serial2002_detach(struct comedi_device *dev) -{ - struct comedi_subdevice *s; - int i; - - for (i = 0; i < dev->n_subdevices; i++) { - s = &dev->subdevices[i]; - kfree(s->maxdata_list); - kfree(s->range_table_list); - } -} - -static struct comedi_driver serial2002_driver = { - .driver_name = "serial2002", - .module = THIS_MODULE, - .attach = serial2002_attach, - .detach = serial2002_detach, -}; -module_comedi_driver(serial2002_driver); - -MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); -MODULE_LICENSE("GPL"); From 5298ff58c93e0d7b7d67b8525e7c18a9478cbd8d Mon Sep 17 00:00:00 2001 From: zhong jiang Date: Wed, 1 Aug 2018 22:10:15 +0800 Subject: [PATCH 748/903] drivers/staging/mt7621-eth: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset we prefer to use dma_zalloc_coherent rather than dam_alloc_coherent+memset Signed-off-by: zhong jiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-eth/mtk_eth_soc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c index f9b593ca2bcf..713507558568 100644 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c +++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c @@ -1396,14 +1396,13 @@ static int mtk_qdma_tx_alloc_tx(struct mtk_eth *eth) if (!ring->tx_buf) goto no_tx_mem; - ring->tx_dma = dma_alloc_coherent(eth->dev, + ring->tx_dma = dma_zalloc_coherent(eth->dev, ring->tx_ring_size * sz, &ring->tx_phys, GFP_ATOMIC | __GFP_ZERO); if (!ring->tx_dma) goto no_tx_mem; - memset(ring->tx_dma, 0, ring->tx_ring_size * sz); for (i = 0; i < ring->tx_ring_size; i++) { int next = (i + 1) % ring->tx_ring_size; u32 next_ptr = ring->tx_phys + next * sz; From 496fb59e1274086d0c67681fb1369e9941660dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Roussin-B=C3=A9langer?= Date: Tue, 31 Jul 2018 16:13:21 -0400 Subject: [PATCH 749/903] iio: light: si1133: fix uninitialized resp variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Read response register to detect any error. Signed-off-by: Maxime Roussin-Bélanger Reported-by: Dan Carpenter Signed-off-by: Jonathan Cameron --- drivers/iio/light/si1133.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c index 5ac22c46da1f..015a21f0c2ef 100644 --- a/drivers/iio/light/si1133.c +++ b/drivers/iio/light/si1133.c @@ -409,6 +409,9 @@ static int si1133_command(struct si1133_data *data, u8 cmd) err = -ETIMEDOUT; goto out; } + err = regmap_read(data->regmap, SI1133_REG_RESPONSE0, &resp); + if (err) + goto out; } else { err = regmap_read_poll_timeout(data->regmap, SI1133_REG_RESPONSE0, resp, From 80666096eb78f0eb54abb1991c23488a276fa1c6 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:34 -0700 Subject: [PATCH 750/903] staging: gasket: core: remove static function forward declarations Remove forward declarations of static functions, move code to avoid forward references, for kernel style. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 1818 +++++++++++++------------- 1 file changed, 881 insertions(+), 937 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index c00774059f9e..b5a7254fbfb3 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -67,61 +67,6 @@ enum do_map_region_status { DO_MAP_REGION_INVALID, }; -/* Function declarations; comments are with definitions. */ -static int __init gasket_init(void); -static void __exit gasket_exit(void); - -static int gasket_pci_probe( - struct pci_dev *pci_dev, const struct pci_device_id *id); -static void gasket_pci_remove(struct pci_dev *pci_dev); - -static int gasket_setup_pci(struct pci_dev *pci_dev, struct gasket_dev *dev); -static void gasket_cleanup_pci(struct gasket_dev *dev); - -static int gasket_map_pci_bar(struct gasket_dev *dev, int bar_num); -static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num); - -static int gasket_alloc_dev( - struct gasket_internal_desc *internal_desc, struct device *dev, - struct gasket_dev **pdev, const char *kobj_name); -static void gasket_free_dev(struct gasket_dev *dev); - -static int gasket_find_dev_slot( - struct gasket_internal_desc *internal_desc, const char *kobj_name); - -static int gasket_add_cdev( - struct gasket_cdev_info *dev_info, - const struct file_operations *file_ops, struct module *owner); - -static int gasket_enable_dev( - struct gasket_internal_desc *internal_desc, - struct gasket_dev *gasket_dev); -static void gasket_disable_dev(struct gasket_dev *gasket_dev); - -static struct gasket_internal_desc *lookup_internal_desc( - struct pci_dev *pci_dev); - -static ssize_t gasket_sysfs_data_show( - struct device *device, struct device_attribute *attr, char *buf); - -static int gasket_mmap(struct file *filp, struct vm_area_struct *vma); -static int gasket_open(struct inode *inode, struct file *file); -static int gasket_release(struct inode *inode, struct file *file); -static long gasket_ioctl(struct file *filp, uint cmd, ulong arg); - -static int gasket_mm_vma_bar_offset( - const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, - ulong *bar_offset); -static bool gasket_mm_get_mapping_addrs( - const struct gasket_mappable_region *region, ulong bar_offset, - ulong requested_length, struct gasket_mappable_region *mappable_region, - ulong *virt_offset); -static enum do_map_region_status do_map_region( - const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, - struct gasket_mappable_region *map_region); - -static int gasket_get_hw_status(struct gasket_dev *gasket_dev); - /* Global data definitions. */ /* Mutex - only for framework-wide data. Other data should be protected by * finer-grained locks. @@ -157,48 +102,6 @@ enum gasket_sysfs_attribute_type { ATTR_USER_MEM_RANGES }; -/* File operations for all Gasket devices. */ -static const struct file_operations gasket_file_ops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .mmap = gasket_mmap, - .open = gasket_open, - .release = gasket_release, - .unlocked_ioctl = gasket_ioctl, -}; - -/* These attributes apply to all Gasket driver instances. */ -static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = { - GASKET_SYSFS_RO(bar_offsets, gasket_sysfs_data_show, ATTR_BAR_OFFSETS), - GASKET_SYSFS_RO(bar_sizes, gasket_sysfs_data_show, ATTR_BAR_SIZES), - GASKET_SYSFS_RO(driver_version, gasket_sysfs_data_show, - ATTR_DRIVER_VERSION), - GASKET_SYSFS_RO(framework_version, gasket_sysfs_data_show, - ATTR_FRAMEWORK_VERSION), - GASKET_SYSFS_RO(device_type, gasket_sysfs_data_show, ATTR_DEVICE_TYPE), - GASKET_SYSFS_RO(revision, gasket_sysfs_data_show, - ATTR_HARDWARE_REVISION), - GASKET_SYSFS_RO(pci_address, gasket_sysfs_data_show, ATTR_PCI_ADDRESS), - GASKET_SYSFS_RO(status, gasket_sysfs_data_show, ATTR_STATUS), - GASKET_SYSFS_RO(is_device_owned, gasket_sysfs_data_show, - ATTR_IS_DEVICE_OWNED), - GASKET_SYSFS_RO(device_owner, gasket_sysfs_data_show, - ATTR_DEVICE_OWNER), - GASKET_SYSFS_RO(write_open_count, gasket_sysfs_data_show, - ATTR_WRITE_OPEN_COUNT), - GASKET_SYSFS_RO(reset_count, gasket_sysfs_data_show, ATTR_RESET_COUNT), - GASKET_SYSFS_RO(user_mem_ranges, gasket_sysfs_data_show, - ATTR_USER_MEM_RANGES), - GASKET_END_OF_ATTR_ARRAY -}; - -MODULE_DESCRIPTION("Google Gasket driver framework"); -MODULE_VERSION(GASKET_FRAMEWORK_VERSION); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Rob Springer "); -module_init(gasket_init); -module_exit(gasket_exit); - /* Perform a standard Gasket callback. */ static inline int check_and_invoke_callback( struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) @@ -239,165 +142,43 @@ static int gasket_owned_by_current_tgid(struct gasket_cdev_info *info) (info->ownership.owner == current->tgid)); } -static int __init gasket_init(void) +/* + * Find the next free gasket_internal_dev slot. + * + * Returns the located slot number on success or a negative number on failure. + */ +static int gasket_find_dev_slot( + struct gasket_internal_desc *internal_desc, const char *kobj_name) { int i; - pr_info("Performing one-time init of the Gasket framework.\n"); - /* Check for duplicates and find a free slot. */ - mutex_lock(&g_mutex); - for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { - g_descs[i].driver_desc = NULL; - mutex_init(&g_descs[i].mutex); - } + mutex_lock(&internal_desc->mutex); - gasket_sysfs_init(); - - mutex_unlock(&g_mutex); - return 0; -} - -static void __exit gasket_exit(void) -{ - /* No deinit/dealloc needed at present. */ - pr_info("Removing Gasket framework module.\n"); -} - -/* See gasket_core.h for description. */ -int gasket_register_device(const struct gasket_driver_desc *driver_desc) -{ - int i, ret; - int desc_idx = -1; - struct gasket_internal_desc *internal; - - pr_info("Initializing Gasket framework device\n"); - /* Check for duplicates and find a free slot. */ - mutex_lock(&g_mutex); - - for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { - if (g_descs[i].driver_desc == driver_desc) { - pr_err("%s driver already loaded/registered\n", - driver_desc->name); - mutex_unlock(&g_mutex); + /* Search for a previous instance of this device. */ + for (i = 0; i < GASKET_DEV_MAX; i++) { + if (internal_desc->devs[i] && + strcmp(internal_desc->devs[i]->kobj_name, kobj_name) == 0) { + pr_err("Duplicate device %s\n", kobj_name); + mutex_unlock(&internal_desc->mutex); return -EBUSY; } } - /* This and the above loop could be combined, but this reads easier. */ - for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { - if (!g_descs[i].driver_desc) { - g_descs[i].driver_desc = driver_desc; - desc_idx = i; + /* Find a free device slot. */ + for (i = 0; i < GASKET_DEV_MAX; i++) { + if (!internal_desc->devs[i]) break; - } } - mutex_unlock(&g_mutex); - pr_info("Loaded %s driver, framework version %s\n", - driver_desc->name, GASKET_FRAMEWORK_VERSION); - - if (desc_idx == -1) { - pr_err("Too many Gasket drivers loaded: %d\n", - GASKET_FRAMEWORK_DESC_MAX); + if (i == GASKET_DEV_MAX) { + pr_err("Too many registered devices; max %d\n", GASKET_DEV_MAX); + mutex_unlock(&internal_desc->mutex); return -EBUSY; } - /* Internal structure setup. */ - pr_debug("Performing initial internal structure setup.\n"); - internal = &g_descs[desc_idx]; - mutex_init(&internal->mutex); - memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX); - memset(&internal->pci, 0, sizeof(internal->pci)); - internal->pci.name = driver_desc->name; - internal->pci.id_table = driver_desc->pci_id_table; - internal->pci.probe = gasket_pci_probe; - internal->pci.remove = gasket_pci_remove; - internal->class = - class_create(driver_desc->module, driver_desc->name); - - if (IS_ERR(internal->class)) { - pr_err("Cannot register %s class [ret=%ld]\n", - driver_desc->name, PTR_ERR(internal->class)); - ret = PTR_ERR(internal->class); - goto unregister_gasket_driver; - } - - /* - * Not using pci_register_driver() (without underscores), as it - * depends on KBUILD_MODNAME, and this is a shared file. - */ - pr_debug("Registering PCI driver.\n"); - ret = __pci_register_driver( - &internal->pci, driver_desc->module, driver_desc->name); - if (ret) { - pr_err("cannot register pci driver [ret=%d]\n", ret); - goto fail1; - } - - pr_debug("Registering char driver.\n"); - ret = register_chrdev_region( - MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, - driver_desc->name); - if (ret) { - pr_err("cannot register char driver [ret=%d]\n", ret); - goto fail2; - } - - pr_info("Driver registered successfully.\n"); - return 0; - -fail2: - pci_unregister_driver(&internal->pci); - -fail1: - class_destroy(internal->class); - -unregister_gasket_driver: - mutex_lock(&g_mutex); - g_descs[desc_idx].driver_desc = NULL; - mutex_unlock(&g_mutex); - return ret; + mutex_unlock(&internal_desc->mutex); + return i; } -EXPORT_SYMBOL(gasket_register_device); - -/* See gasket_core.h for description. */ -void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) -{ - int i, desc_idx; - struct gasket_internal_desc *internal_desc = NULL; - - mutex_lock(&g_mutex); - for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { - if (g_descs[i].driver_desc == driver_desc) { - internal_desc = &g_descs[i]; - desc_idx = i; - break; - } - } - mutex_unlock(&g_mutex); - - if (!internal_desc) { - pr_err("request to unregister unknown desc: %s, %d:%d\n", - driver_desc->name, driver_desc->major, - driver_desc->minor); - return; - } - - unregister_chrdev_region( - MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX); - - pci_unregister_driver(&internal_desc->pci); - - class_destroy(internal_desc->class); - - /* Finally, effectively "remove" the driver. */ - mutex_lock(&g_mutex); - g_descs[desc_idx].driver_desc = NULL; - mutex_unlock(&g_mutex); - - pr_info("removed %s driver\n", driver_desc->name); -} -EXPORT_SYMBOL(gasket_unregister_device); /* * Allocate and initialize a Gasket device structure, add the device to the @@ -473,250 +254,6 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev) kfree(gasket_dev); } -/* - * Find the next free gasket_internal_dev slot. - * - * Returns the located slot number on success or a negative number on failure. - */ -static int gasket_find_dev_slot( - struct gasket_internal_desc *internal_desc, const char *kobj_name) -{ - int i; - - mutex_lock(&internal_desc->mutex); - - /* Search for a previous instance of this device. */ - for (i = 0; i < GASKET_DEV_MAX; i++) { - if (internal_desc->devs[i] && - strcmp(internal_desc->devs[i]->kobj_name, kobj_name) == 0) { - pr_err("Duplicate device %s\n", kobj_name); - mutex_unlock(&internal_desc->mutex); - return -EBUSY; - } - } - - /* Find a free device slot. */ - for (i = 0; i < GASKET_DEV_MAX; i++) { - if (!internal_desc->devs[i]) - break; - } - - if (i == GASKET_DEV_MAX) { - pr_err("Too many registered devices; max %d\n", GASKET_DEV_MAX); - mutex_unlock(&internal_desc->mutex); - return -EBUSY; - } - - mutex_unlock(&internal_desc->mutex); - return i; -} - -/* - * PCI subsystem probe function. - * - * Called when a Gasket device is found. Allocates device metadata, maps device - * memory, and calls gasket_enable_dev to prepare the device for active use. - * - * Returns 0 if successful and a negative value otherwise. - */ -static int gasket_pci_probe( - struct pci_dev *pci_dev, const struct pci_device_id *id) -{ - int ret; - const char *kobj_name = dev_name(&pci_dev->dev); - struct gasket_internal_desc *internal_desc; - struct gasket_dev *gasket_dev; - const struct gasket_driver_desc *driver_desc; - struct device *parent; - - pr_info("Add Gasket device %s\n", kobj_name); - - mutex_lock(&g_mutex); - internal_desc = lookup_internal_desc(pci_dev); - mutex_unlock(&g_mutex); - if (!internal_desc) { - pr_err("PCI probe called for unknown driver type\n"); - return -ENODEV; - } - - driver_desc = internal_desc->driver_desc; - - parent = &pci_dev->dev; - ret = gasket_alloc_dev(internal_desc, parent, &gasket_dev, kobj_name); - if (ret) - return ret; - gasket_dev->pci_dev = pci_dev_get(pci_dev); - if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) { - pr_err("Cannot create %s device %s [ret = %ld]\n", - driver_desc->name, gasket_dev->dev_info.name, - PTR_ERR(gasket_dev->dev_info.device)); - ret = -ENODEV; - goto fail1; - } - - ret = gasket_setup_pci(pci_dev, gasket_dev); - if (ret) - goto fail2; - - ret = check_and_invoke_callback(gasket_dev, driver_desc->add_dev_cb); - if (ret) { - dev_err(gasket_dev->dev, "Error in add device cb: %d\n", ret); - goto fail2; - } - - ret = gasket_sysfs_create_mapping( - gasket_dev->dev_info.device, gasket_dev); - if (ret) - goto fail3; - - /* - * Once we've created the mapping structures successfully, attempt to - * create a symlink to the pci directory of this object. - */ - ret = sysfs_create_link(&gasket_dev->dev_info.device->kobj, - &pci_dev->dev.kobj, dev_name(&pci_dev->dev)); - if (ret) { - dev_err(gasket_dev->dev, - "Cannot create sysfs pci link: %d\n", ret); - goto fail3; - } - ret = gasket_sysfs_create_entries( - gasket_dev->dev_info.device, gasket_sysfs_generic_attrs); - if (ret) - goto fail4; - - ret = check_and_invoke_callback( - gasket_dev, driver_desc->sysfs_setup_cb); - if (ret) { - dev_err(gasket_dev->dev, "Error in sysfs setup cb: %d\n", ret); - goto fail5; - } - - ret = gasket_enable_dev(internal_desc, gasket_dev); - if (ret) { - pr_err("cannot setup %s device\n", driver_desc->name); - gasket_disable_dev(gasket_dev); - goto fail5; - } - - return 0; - -fail5: - check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); -fail4: -fail3: - gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); -fail2: - gasket_cleanup_pci(gasket_dev); - check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); - device_destroy(internal_desc->class, gasket_dev->dev_info.devt); -fail1: - gasket_free_dev(gasket_dev); - return ret; -} - -/* - * PCI subsystem remove function. - * - * Called to remove a Gasket device. Finds the device in the device list and - * cleans up metadata. - */ -static void gasket_pci_remove(struct pci_dev *pci_dev) -{ - int i; - struct gasket_internal_desc *internal_desc; - struct gasket_dev *gasket_dev = NULL; - const struct gasket_driver_desc *driver_desc; - /* Find the device desc. */ - mutex_lock(&g_mutex); - internal_desc = lookup_internal_desc(pci_dev); - if (!internal_desc) { - mutex_unlock(&g_mutex); - return; - } - mutex_unlock(&g_mutex); - - driver_desc = internal_desc->driver_desc; - - /* Now find the specific device */ - mutex_lock(&internal_desc->mutex); - for (i = 0; i < GASKET_DEV_MAX; i++) { - if (internal_desc->devs[i] && - internal_desc->devs[i]->pci_dev == pci_dev) { - gasket_dev = internal_desc->devs[i]; - break; - } - } - mutex_unlock(&internal_desc->mutex); - - if (!gasket_dev) - return; - - pr_info("remove %s device %s\n", internal_desc->driver_desc->name, - gasket_dev->kobj_name); - - gasket_disable_dev(gasket_dev); - gasket_cleanup_pci(gasket_dev); - - check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); - gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); - - check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); - - device_destroy(internal_desc->class, gasket_dev->dev_info.devt); - gasket_free_dev(gasket_dev); -} - -/* - * Setup PCI & set up memory mapping for the specified device. - * - * Enables the PCI device, reads the BAR registers and sets up pointers to the - * device's memory mapped IO space. - * - * Returns 0 on success and a negative value otherwise. - */ -static int gasket_setup_pci( - struct pci_dev *pci_dev, struct gasket_dev *gasket_dev) -{ - int i, mapped_bars, ret; - - ret = pci_enable_device(pci_dev); - if (ret) { - dev_err(gasket_dev->dev, "cannot enable PCI device\n"); - return ret; - } - - pci_set_master(pci_dev); - - for (i = 0; i < GASKET_NUM_BARS; i++) { - ret = gasket_map_pci_bar(gasket_dev, i); - if (ret) { - mapped_bars = i; - goto fail; - } - } - - return 0; - -fail: - for (i = 0; i < mapped_bars; i++) - gasket_unmap_pci_bar(gasket_dev, i); - - pci_disable_device(pci_dev); - return -ENOMEM; -} - -/* Unmaps memory and cleans up PCI for the specified device. */ -static void gasket_cleanup_pci(struct gasket_dev *gasket_dev) -{ - int i; - - for (i = 0; i < GASKET_NUM_BARS; i++) - gasket_unmap_pci_bar(gasket_dev, i); - - pci_disable_device(gasket_dev->pci_dev); -} - /* * Maps the specified bar into kernel space. * @@ -826,6 +363,264 @@ static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num) release_mem_region(base, bytes); } +/* + * Setup PCI & set up memory mapping for the specified device. + * + * Enables the PCI device, reads the BAR registers and sets up pointers to the + * device's memory mapped IO space. + * + * Returns 0 on success and a negative value otherwise. + */ +static int gasket_setup_pci( + struct pci_dev *pci_dev, struct gasket_dev *gasket_dev) +{ + int i, mapped_bars, ret; + + ret = pci_enable_device(pci_dev); + if (ret) { + dev_err(gasket_dev->dev, "cannot enable PCI device\n"); + return ret; + } + + pci_set_master(pci_dev); + + for (i = 0; i < GASKET_NUM_BARS; i++) { + ret = gasket_map_pci_bar(gasket_dev, i); + if (ret) { + mapped_bars = i; + goto fail; + } + } + + return 0; + +fail: + for (i = 0; i < mapped_bars; i++) + gasket_unmap_pci_bar(gasket_dev, i); + + pci_disable_device(pci_dev); + return -ENOMEM; +} + +/* Unmaps memory and cleans up PCI for the specified device. */ +static void gasket_cleanup_pci(struct gasket_dev *gasket_dev) +{ + int i; + + for (i = 0; i < GASKET_NUM_BARS; i++) + gasket_unmap_pci_bar(gasket_dev, i); + + pci_disable_device(gasket_dev->pci_dev); +} + +/* Determine the health of the Gasket device. */ +static int gasket_get_hw_status(struct gasket_dev *gasket_dev) +{ + int status; + int i; + const struct gasket_driver_desc *driver_desc = + gasket_dev->internal_desc->driver_desc; + + status = gasket_check_and_invoke_callback_nolock( + gasket_dev, driver_desc->device_status_cb); + if (status != GASKET_STATUS_ALIVE) { + dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n", + status); + return status; + } + + status = gasket_interrupt_system_status(gasket_dev); + if (status != GASKET_STATUS_ALIVE) { + dev_dbg(gasket_dev->dev, + "Interrupt system reported status %d.\n", status); + return status; + } + + for (i = 0; i < driver_desc->num_page_tables; ++i) { + status = gasket_page_table_system_status( + gasket_dev->page_table[i]); + if (status != GASKET_STATUS_ALIVE) { + dev_dbg(gasket_dev->dev, + "Page table %d reported status %d.\n", + i, status); + return status; + } + } + + return GASKET_STATUS_ALIVE; +} + +static ssize_t gasket_write_mappable_regions( + char *buf, const struct gasket_driver_desc *driver_desc, int bar_index) +{ + int i; + ssize_t written; + ssize_t total_written = 0; + ulong min_addr, max_addr; + struct gasket_bar_desc bar_desc = + driver_desc->bar_descriptions[bar_index]; + + if (bar_desc.permissions == GASKET_NOMAP) + return 0; + for (i = 0; + i < bar_desc.num_mappable_regions && total_written < PAGE_SIZE; + i++) { + min_addr = bar_desc.mappable_regions[i].start - + driver_desc->legacy_mmap_address_offset; + max_addr = bar_desc.mappable_regions[i].start - + driver_desc->legacy_mmap_address_offset + + bar_desc.mappable_regions[i].length_bytes; + written = scnprintf(buf, PAGE_SIZE - total_written, + "0x%08lx-0x%08lx\n", min_addr, max_addr); + total_written += written; + buf += written; + } + return total_written; +} + +static ssize_t gasket_sysfs_data_show( + struct device *device, struct device_attribute *attr, char *buf) +{ + int i, ret = 0; + ssize_t current_written = 0; + const struct gasket_driver_desc *driver_desc; + struct gasket_dev *gasket_dev; + struct gasket_sysfs_attribute *gasket_attr; + const struct gasket_bar_desc *bar_desc; + enum gasket_sysfs_attribute_type sysfs_type; + + gasket_dev = gasket_sysfs_get_device_data(device); + if (!gasket_dev) { + dev_err(device, "No sysfs mapping found for device\n"); + return 0; + } + + gasket_attr = gasket_sysfs_get_attr(device, attr); + if (!gasket_attr) { + dev_err(device, "No sysfs attr found for device\n"); + gasket_sysfs_put_device_data(device, gasket_dev); + return 0; + } + + driver_desc = gasket_dev->internal_desc->driver_desc; + + sysfs_type = + (enum gasket_sysfs_attribute_type)gasket_attr->data.attr_type; + switch (sysfs_type) { + case ATTR_BAR_OFFSETS: + for (i = 0; i < GASKET_NUM_BARS; i++) { + bar_desc = &driver_desc->bar_descriptions[i]; + if (bar_desc->size == 0) + continue; + current_written = + snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i, + (ulong)bar_desc->base); + buf += current_written; + ret += current_written; + } + break; + case ATTR_BAR_SIZES: + for (i = 0; i < GASKET_NUM_BARS; i++) { + bar_desc = &driver_desc->bar_descriptions[i]; + if (bar_desc->size == 0) + continue; + current_written = + snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i, + (ulong)bar_desc->size); + buf += current_written; + ret += current_written; + } + break; + case ATTR_DRIVER_VERSION: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", + gasket_dev->internal_desc->driver_desc->driver_version); + break; + case ATTR_FRAMEWORK_VERSION: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", GASKET_FRAMEWORK_VERSION); + break; + case ATTR_DEVICE_TYPE: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", + gasket_dev->internal_desc->driver_desc->name); + break; + case ATTR_HARDWARE_REVISION: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", gasket_dev->hardware_revision); + break; + case ATTR_PCI_ADDRESS: + ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name); + break; + case ATTR_STATUS: + ret = snprintf( + buf, PAGE_SIZE, "%s\n", + gasket_num_name_lookup( + gasket_dev->status, gasket_status_name_table)); + break; + case ATTR_IS_DEVICE_OWNED: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.is_owned); + break; + case ATTR_DEVICE_OWNER: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.owner); + break; + case ATTR_WRITE_OPEN_COUNT: + ret = snprintf( + buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.write_open_count); + break; + case ATTR_RESET_COUNT: + ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count); + break; + case ATTR_USER_MEM_RANGES: + for (i = 0; i < GASKET_NUM_BARS; ++i) { + current_written = gasket_write_mappable_regions( + buf, driver_desc, i); + buf += current_written; + ret += current_written; + } + break; + default: + dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", + attr->attr.name); + ret = 0; + break; + } + + gasket_sysfs_put_attr(device, gasket_attr); + gasket_sysfs_put_device_data(device, gasket_dev); + return ret; +} + +/* These attributes apply to all Gasket driver instances. */ +static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = { + GASKET_SYSFS_RO(bar_offsets, gasket_sysfs_data_show, ATTR_BAR_OFFSETS), + GASKET_SYSFS_RO(bar_sizes, gasket_sysfs_data_show, ATTR_BAR_SIZES), + GASKET_SYSFS_RO(driver_version, gasket_sysfs_data_show, + ATTR_DRIVER_VERSION), + GASKET_SYSFS_RO(framework_version, gasket_sysfs_data_show, + ATTR_FRAMEWORK_VERSION), + GASKET_SYSFS_RO(device_type, gasket_sysfs_data_show, ATTR_DEVICE_TYPE), + GASKET_SYSFS_RO(revision, gasket_sysfs_data_show, + ATTR_HARDWARE_REVISION), + GASKET_SYSFS_RO(pci_address, gasket_sysfs_data_show, ATTR_PCI_ADDRESS), + GASKET_SYSFS_RO(status, gasket_sysfs_data_show, ATTR_STATUS), + GASKET_SYSFS_RO(is_device_owned, gasket_sysfs_data_show, + ATTR_IS_DEVICE_OWNED), + GASKET_SYSFS_RO(device_owner, gasket_sysfs_data_show, + ATTR_DEVICE_OWNER), + GASKET_SYSFS_RO(write_open_count, gasket_sysfs_data_show, + ATTR_WRITE_OPEN_COUNT), + GASKET_SYSFS_RO(reset_count, gasket_sysfs_data_show, ATTR_RESET_COUNT), + GASKET_SYSFS_RO(user_mem_ranges, gasket_sysfs_data_show, + ATTR_USER_MEM_RANGES), + GASKET_END_OF_ATTR_ARRAY +}; + /* Add a char device and related info. */ static int gasket_add_cdev( struct gasket_cdev_info *dev_info, @@ -846,84 +641,6 @@ static int gasket_add_cdev( return 0; } -/* Perform final init and marks the device as active. */ -static int gasket_enable_dev( - struct gasket_internal_desc *internal_desc, - struct gasket_dev *gasket_dev) -{ - int tbl_idx; - int ret; - const struct gasket_driver_desc *driver_desc = - internal_desc->driver_desc; - - ret = gasket_interrupt_init( - gasket_dev, driver_desc->name, - driver_desc->interrupt_type, driver_desc->interrupts, - driver_desc->num_interrupts, driver_desc->interrupt_pack_width, - driver_desc->interrupt_bar_index, - driver_desc->wire_interrupt_offsets); - if (ret) { - dev_err(gasket_dev->dev, - "Critical failure to allocate interrupts: %d\n", ret); - gasket_interrupt_cleanup(gasket_dev); - return ret; - } - - for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { - dev_dbg(gasket_dev->dev, "Initializing page table %d.\n", - tbl_idx); - ret = gasket_page_table_init( - &gasket_dev->page_table[tbl_idx], - &gasket_dev->bar_data[ - driver_desc->page_table_bar_index], - &driver_desc->page_table_configs[tbl_idx], - gasket_dev->dev, gasket_dev->pci_dev); - if (ret) { - dev_err(gasket_dev->dev, - "Couldn't init page table %d: %d\n", - tbl_idx, ret); - return ret; - } - /* - * Make sure that the page table is clear and set to simple - * addresses. - */ - gasket_page_table_reset(gasket_dev->page_table[tbl_idx]); - } - - /* - * hardware_revision_cb returns a positive integer (the rev) if - * successful.) - */ - ret = check_and_invoke_callback( - gasket_dev, driver_desc->hardware_revision_cb); - if (ret < 0) { - dev_err(gasket_dev->dev, - "Error getting hardware revision: %d\n", ret); - return ret; - } - gasket_dev->hardware_revision = ret; - - ret = check_and_invoke_callback(gasket_dev, driver_desc->enable_dev_cb); - if (ret) { - dev_err(gasket_dev->dev, "Error in enable device cb: %d\n", - ret); - return ret; - } - - /* device_status_cb returns a device status, not an error code. */ - gasket_dev->status = gasket_get_hw_status(gasket_dev); - if (gasket_dev->status == GASKET_STATUS_DEAD) - dev_err(gasket_dev->dev, "Device reported as unhealthy.\n"); - - ret = gasket_add_cdev( - &gasket_dev->dev_info, &gasket_file_ops, driver_desc->module); - if (ret) - return ret; - - return 0; -} - /* Disable device operations. */ static void gasket_disable_dev(struct gasket_dev *gasket_dev) { @@ -971,177 +688,6 @@ static struct gasket_internal_desc *lookup_internal_desc( return NULL; } -/** - * Lookup a name by number in a num_name table. - * @num: Number to lookup. - * @table: Array of num_name structures, the table for the lookup. - * - * Description: Searches for num in the table. If found, the - * corresponding name is returned; otherwise NULL - * is returned. - * - * The table must have a NULL name pointer at the end. - */ -const char *gasket_num_name_lookup( - uint num, const struct gasket_num_name *table) -{ - uint i = 0; - - while (table[i].snn_name) { - if (num == table[i].snn_num) - break; - ++i; - } - - return table[i].snn_name; -} -EXPORT_SYMBOL(gasket_num_name_lookup); - -/* - * Open the char device file. - * - * If the open is for writing, and the device is not owned, this process becomes - * the owner. If the open is for writing and the device is already owned by - * some other process, it is an error. If this process is the owner, increment - * the open count. - * - * Returns 0 if successful, a negative error number otherwise. - */ -static int gasket_open(struct inode *inode, struct file *filp) -{ - int ret; - struct gasket_dev *gasket_dev; - const struct gasket_driver_desc *driver_desc; - struct gasket_ownership *ownership; - char task_name[TASK_COMM_LEN]; - struct gasket_cdev_info *dev_info = - container_of(inode->i_cdev, struct gasket_cdev_info, cdev); - struct pid_namespace *pid_ns = task_active_pid_ns(current); - int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); - - gasket_dev = dev_info->gasket_dev_ptr; - driver_desc = gasket_dev->internal_desc->driver_desc; - ownership = &dev_info->ownership; - get_task_comm(task_name, current); - filp->private_data = gasket_dev; - inode->i_size = 0; - - dev_dbg(gasket_dev->dev, - "Attempting to open with tgid %u (%s) (f_mode: 0%03o, " - "fmode_write: %d is_root: %u)\n", - current->tgid, task_name, filp->f_mode, - (filp->f_mode & FMODE_WRITE), is_root); - - /* Always allow non-writing accesses. */ - if (!(filp->f_mode & FMODE_WRITE)) { - dev_dbg(gasket_dev->dev, "Allowing read-only opening.\n"); - return 0; - } - - mutex_lock(&gasket_dev->mutex); - - dev_dbg(gasket_dev->dev, - "Current owner open count (owning tgid %u): %d.\n", - ownership->owner, ownership->write_open_count); - - /* Opening a node owned by another TGID is an error (unless root) */ - if (ownership->is_owned && ownership->owner != current->tgid && - !is_root) { - dev_err(gasket_dev->dev, - "Process %u is opening a node held by %u.\n", - current->tgid, ownership->owner); - mutex_unlock(&gasket_dev->mutex); - return -EPERM; - } - - /* If the node is not owned, assign it to the current TGID. */ - if (!ownership->is_owned) { - ret = gasket_check_and_invoke_callback_nolock( - gasket_dev, driver_desc->device_open_cb); - if (ret) { - dev_err(gasket_dev->dev, - "Error in device open cb: %d\n", ret); - mutex_unlock(&gasket_dev->mutex); - return ret; - } - ownership->is_owned = 1; - ownership->owner = current->tgid; - dev_dbg(gasket_dev->dev, "Device owner is now tgid %u\n", - ownership->owner); - } - - ownership->write_open_count++; - - dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n", - ownership->owner, ownership->write_open_count); - - mutex_unlock(&gasket_dev->mutex); - return 0; -} - -/* - * Called on a close of the device file. If this process is the owner, - * decrement the open count. On last close by the owner, free up buffers and - * eventfd contexts, and release ownership. - * - * Returns 0 if successful, a negative error number otherwise. - */ -static int gasket_release(struct inode *inode, struct file *file) -{ - int i; - struct gasket_dev *gasket_dev; - struct gasket_ownership *ownership; - const struct gasket_driver_desc *driver_desc; - char task_name[TASK_COMM_LEN]; - struct gasket_cdev_info *dev_info = - container_of(inode->i_cdev, struct gasket_cdev_info, cdev); - struct pid_namespace *pid_ns = task_active_pid_ns(current); - int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); - - gasket_dev = dev_info->gasket_dev_ptr; - driver_desc = gasket_dev->internal_desc->driver_desc; - ownership = &dev_info->ownership; - get_task_comm(task_name, current); - mutex_lock(&gasket_dev->mutex); - - dev_dbg(gasket_dev->dev, - "Releasing device node. Call origin: tgid %u (%s) " - "(f_mode: 0%03o, fmode_write: %d, is_root: %u)\n", - current->tgid, task_name, file->f_mode, - (file->f_mode & FMODE_WRITE), is_root); - dev_dbg(gasket_dev->dev, "Current open count (owning tgid %u): %d\n", - ownership->owner, ownership->write_open_count); - - if (file->f_mode & FMODE_WRITE) { - ownership->write_open_count--; - if (ownership->write_open_count == 0) { - dev_dbg(gasket_dev->dev, "Device is now free\n"); - ownership->is_owned = 0; - ownership->owner = 0; - - /* Forces chip reset before we unmap the page tables. */ - driver_desc->device_reset_cb(gasket_dev, 0); - - for (i = 0; i < driver_desc->num_page_tables; ++i) { - gasket_page_table_unmap_all( - gasket_dev->page_table[i]); - gasket_page_table_garbage_collect( - gasket_dev->page_table[i]); - gasket_free_coherent_memory_all(gasket_dev, i); - } - - /* Closes device, enters power save. */ - gasket_check_and_invoke_callback_nolock( - gasket_dev, driver_desc->device_close_cb); - } - } - - dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n", - ownership->owner, ownership->write_open_count); - mutex_unlock(&gasket_dev->mutex); - return 0; -} - /* * Verifies that the user has permissions to perform the requested mapping and * that the provided descriptor/range is of adequate size to hold the range to @@ -1301,6 +847,36 @@ static bool gasket_mm_get_mapping_addrs( return false; } +/* + * Calculates the offset where the VMA range begins in its containing BAR. + * The offset is written into bar_offset on success. + * Returns zero on success, anything else on error. + */ +static int gasket_mm_vma_bar_offset( + const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, + ulong *bar_offset) +{ + ulong raw_offset; + int bar_index; + const struct gasket_driver_desc *driver_desc = + gasket_dev->internal_desc->driver_desc; + + raw_offset = (vma->vm_pgoff << PAGE_SHIFT) + + driver_desc->legacy_mmap_address_offset; + bar_index = gasket_get_bar_index(gasket_dev, raw_offset); + if (bar_index < 0) { + dev_err(gasket_dev->dev, + "Unable to find matching bar for address 0x%lx\n", + raw_offset); + trace_gasket_mmap_exit(bar_index); + return bar_index; + } + *bar_offset = + raw_offset - driver_desc->bar_descriptions[bar_index].base; + + return 0; +} + int gasket_mm_unmap_region( const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, const struct gasket_mappable_region *map_region) @@ -1407,36 +983,6 @@ fail: return DO_MAP_REGION_FAILURE; } -/* - * Calculates the offset where the VMA range begins in its containing BAR. - * The offset is written into bar_offset on success. - * Returns zero on success, anything else on error. - */ -static int gasket_mm_vma_bar_offset( - const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, - ulong *bar_offset) -{ - ulong raw_offset; - int bar_index; - const struct gasket_driver_desc *driver_desc = - gasket_dev->internal_desc->driver_desc; - - raw_offset = (vma->vm_pgoff << PAGE_SHIFT) + - driver_desc->legacy_mmap_address_offset; - bar_index = gasket_get_bar_index(gasket_dev, raw_offset); - if (bar_index < 0) { - dev_err(gasket_dev->dev, - "Unable to find matching bar for address 0x%lx\n", - raw_offset); - trace_gasket_mmap_exit(bar_index); - return bar_index; - } - *bar_offset = - raw_offset - driver_desc->bar_descriptions[bar_index].base; - - return 0; -} - /* Map a region of coherent memory. */ static int gasket_mmap_coherent( struct gasket_dev *gasket_dev, struct vm_area_struct *vma) @@ -1626,41 +1172,149 @@ fail: return ret; } -/* Determine the health of the Gasket device. */ -static int gasket_get_hw_status(struct gasket_dev *gasket_dev) +/* + * Open the char device file. + * + * If the open is for writing, and the device is not owned, this process becomes + * the owner. If the open is for writing and the device is already owned by + * some other process, it is an error. If this process is the owner, increment + * the open count. + * + * Returns 0 if successful, a negative error number otherwise. + */ +static int gasket_open(struct inode *inode, struct file *filp) +{ + int ret; + struct gasket_dev *gasket_dev; + const struct gasket_driver_desc *driver_desc; + struct gasket_ownership *ownership; + char task_name[TASK_COMM_LEN]; + struct gasket_cdev_info *dev_info = + container_of(inode->i_cdev, struct gasket_cdev_info, cdev); + struct pid_namespace *pid_ns = task_active_pid_ns(current); + int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); + + gasket_dev = dev_info->gasket_dev_ptr; + driver_desc = gasket_dev->internal_desc->driver_desc; + ownership = &dev_info->ownership; + get_task_comm(task_name, current); + filp->private_data = gasket_dev; + inode->i_size = 0; + + dev_dbg(gasket_dev->dev, + "Attempting to open with tgid %u (%s) (f_mode: 0%03o, " + "fmode_write: %d is_root: %u)\n", + current->tgid, task_name, filp->f_mode, + (filp->f_mode & FMODE_WRITE), is_root); + + /* Always allow non-writing accesses. */ + if (!(filp->f_mode & FMODE_WRITE)) { + dev_dbg(gasket_dev->dev, "Allowing read-only opening.\n"); + return 0; + } + + mutex_lock(&gasket_dev->mutex); + + dev_dbg(gasket_dev->dev, + "Current owner open count (owning tgid %u): %d.\n", + ownership->owner, ownership->write_open_count); + + /* Opening a node owned by another TGID is an error (unless root) */ + if (ownership->is_owned && ownership->owner != current->tgid && + !is_root) { + dev_err(gasket_dev->dev, + "Process %u is opening a node held by %u.\n", + current->tgid, ownership->owner); + mutex_unlock(&gasket_dev->mutex); + return -EPERM; + } + + /* If the node is not owned, assign it to the current TGID. */ + if (!ownership->is_owned) { + ret = gasket_check_and_invoke_callback_nolock( + gasket_dev, driver_desc->device_open_cb); + if (ret) { + dev_err(gasket_dev->dev, + "Error in device open cb: %d\n", ret); + mutex_unlock(&gasket_dev->mutex); + return ret; + } + ownership->is_owned = 1; + ownership->owner = current->tgid; + dev_dbg(gasket_dev->dev, "Device owner is now tgid %u\n", + ownership->owner); + } + + ownership->write_open_count++; + + dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n", + ownership->owner, ownership->write_open_count); + + mutex_unlock(&gasket_dev->mutex); + return 0; +} + +/* + * Called on a close of the device file. If this process is the owner, + * decrement the open count. On last close by the owner, free up buffers and + * eventfd contexts, and release ownership. + * + * Returns 0 if successful, a negative error number otherwise. + */ +static int gasket_release(struct inode *inode, struct file *file) { - int status; int i; - const struct gasket_driver_desc *driver_desc = - gasket_dev->internal_desc->driver_desc; + struct gasket_dev *gasket_dev; + struct gasket_ownership *ownership; + const struct gasket_driver_desc *driver_desc; + char task_name[TASK_COMM_LEN]; + struct gasket_cdev_info *dev_info = + container_of(inode->i_cdev, struct gasket_cdev_info, cdev); + struct pid_namespace *pid_ns = task_active_pid_ns(current); + int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); - status = gasket_check_and_invoke_callback_nolock( - gasket_dev, driver_desc->device_status_cb); - if (status != GASKET_STATUS_ALIVE) { - dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n", - status); - return status; - } + gasket_dev = dev_info->gasket_dev_ptr; + driver_desc = gasket_dev->internal_desc->driver_desc; + ownership = &dev_info->ownership; + get_task_comm(task_name, current); + mutex_lock(&gasket_dev->mutex); - status = gasket_interrupt_system_status(gasket_dev); - if (status != GASKET_STATUS_ALIVE) { - dev_dbg(gasket_dev->dev, - "Interrupt system reported status %d.\n", status); - return status; - } + dev_dbg(gasket_dev->dev, + "Releasing device node. Call origin: tgid %u (%s) " + "(f_mode: 0%03o, fmode_write: %d, is_root: %u)\n", + current->tgid, task_name, file->f_mode, + (file->f_mode & FMODE_WRITE), is_root); + dev_dbg(gasket_dev->dev, "Current open count (owning tgid %u): %d\n", + ownership->owner, ownership->write_open_count); - for (i = 0; i < driver_desc->num_page_tables; ++i) { - status = gasket_page_table_system_status( - gasket_dev->page_table[i]); - if (status != GASKET_STATUS_ALIVE) { - dev_dbg(gasket_dev->dev, - "Page table %d reported status %d.\n", - i, status); - return status; + if (file->f_mode & FMODE_WRITE) { + ownership->write_open_count--; + if (ownership->write_open_count == 0) { + dev_dbg(gasket_dev->dev, "Device is now free\n"); + ownership->is_owned = 0; + ownership->owner = 0; + + /* Forces chip reset before we unmap the page tables. */ + driver_desc->device_reset_cb(gasket_dev, 0); + + for (i = 0; i < driver_desc->num_page_tables; ++i) { + gasket_page_table_unmap_all( + gasket_dev->page_table[i]); + gasket_page_table_garbage_collect( + gasket_dev->page_table[i]); + gasket_free_coherent_memory_all(gasket_dev, i); + } + + /* Closes device, enters power save. */ + gasket_check_and_invoke_callback_nolock( + gasket_dev, driver_desc->device_close_cb); } } - return GASKET_STATUS_ALIVE; + dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n", + ownership->owner, ownership->write_open_count); + mutex_unlock(&gasket_dev->mutex); + return 0; } /* @@ -1702,6 +1356,276 @@ static long gasket_ioctl(struct file *filp, uint cmd, ulong arg) return gasket_handle_ioctl(filp, cmd, argp); } +/* File operations for all Gasket devices. */ +static const struct file_operations gasket_file_ops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .mmap = gasket_mmap, + .open = gasket_open, + .release = gasket_release, + .unlocked_ioctl = gasket_ioctl, +}; + +/* Perform final init and marks the device as active. */ +static int gasket_enable_dev( + struct gasket_internal_desc *internal_desc, + struct gasket_dev *gasket_dev) +{ + int tbl_idx; + int ret; + const struct gasket_driver_desc *driver_desc = + internal_desc->driver_desc; + + ret = gasket_interrupt_init( + gasket_dev, driver_desc->name, + driver_desc->interrupt_type, driver_desc->interrupts, + driver_desc->num_interrupts, driver_desc->interrupt_pack_width, + driver_desc->interrupt_bar_index, + driver_desc->wire_interrupt_offsets); + if (ret) { + dev_err(gasket_dev->dev, + "Critical failure to allocate interrupts: %d\n", ret); + gasket_interrupt_cleanup(gasket_dev); + return ret; + } + + for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { + dev_dbg(gasket_dev->dev, "Initializing page table %d.\n", + tbl_idx); + ret = gasket_page_table_init( + &gasket_dev->page_table[tbl_idx], + &gasket_dev->bar_data[ + driver_desc->page_table_bar_index], + &driver_desc->page_table_configs[tbl_idx], + gasket_dev->dev, gasket_dev->pci_dev); + if (ret) { + dev_err(gasket_dev->dev, + "Couldn't init page table %d: %d\n", + tbl_idx, ret); + return ret; + } + /* + * Make sure that the page table is clear and set to simple + * addresses. + */ + gasket_page_table_reset(gasket_dev->page_table[tbl_idx]); + } + + /* + * hardware_revision_cb returns a positive integer (the rev) if + * successful.) + */ + ret = check_and_invoke_callback( + gasket_dev, driver_desc->hardware_revision_cb); + if (ret < 0) { + dev_err(gasket_dev->dev, + "Error getting hardware revision: %d\n", ret); + return ret; + } + gasket_dev->hardware_revision = ret; + + ret = check_and_invoke_callback(gasket_dev, driver_desc->enable_dev_cb); + if (ret) { + dev_err(gasket_dev->dev, "Error in enable device cb: %d\n", + ret); + return ret; + } + + /* device_status_cb returns a device status, not an error code. */ + gasket_dev->status = gasket_get_hw_status(gasket_dev); + if (gasket_dev->status == GASKET_STATUS_DEAD) + dev_err(gasket_dev->dev, "Device reported as unhealthy.\n"); + + ret = gasket_add_cdev( + &gasket_dev->dev_info, &gasket_file_ops, driver_desc->module); + if (ret) + return ret; + + return 0; +} + +/* + * PCI subsystem probe function. + * + * Called when a Gasket device is found. Allocates device metadata, maps device + * memory, and calls gasket_enable_dev to prepare the device for active use. + * + * Returns 0 if successful and a negative value otherwise. + */ +static int gasket_pci_probe( + struct pci_dev *pci_dev, const struct pci_device_id *id) +{ + int ret; + const char *kobj_name = dev_name(&pci_dev->dev); + struct gasket_internal_desc *internal_desc; + struct gasket_dev *gasket_dev; + const struct gasket_driver_desc *driver_desc; + struct device *parent; + + pr_info("Add Gasket device %s\n", kobj_name); + + mutex_lock(&g_mutex); + internal_desc = lookup_internal_desc(pci_dev); + mutex_unlock(&g_mutex); + if (!internal_desc) { + pr_err("PCI probe called for unknown driver type\n"); + return -ENODEV; + } + + driver_desc = internal_desc->driver_desc; + + parent = &pci_dev->dev; + ret = gasket_alloc_dev(internal_desc, parent, &gasket_dev, kobj_name); + if (ret) + return ret; + gasket_dev->pci_dev = pci_dev_get(pci_dev); + if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) { + pr_err("Cannot create %s device %s [ret = %ld]\n", + driver_desc->name, gasket_dev->dev_info.name, + PTR_ERR(gasket_dev->dev_info.device)); + ret = -ENODEV; + goto fail1; + } + + ret = gasket_setup_pci(pci_dev, gasket_dev); + if (ret) + goto fail2; + + ret = check_and_invoke_callback(gasket_dev, driver_desc->add_dev_cb); + if (ret) { + dev_err(gasket_dev->dev, "Error in add device cb: %d\n", ret); + goto fail2; + } + + ret = gasket_sysfs_create_mapping( + gasket_dev->dev_info.device, gasket_dev); + if (ret) + goto fail3; + + /* + * Once we've created the mapping structures successfully, attempt to + * create a symlink to the pci directory of this object. + */ + ret = sysfs_create_link(&gasket_dev->dev_info.device->kobj, + &pci_dev->dev.kobj, dev_name(&pci_dev->dev)); + if (ret) { + dev_err(gasket_dev->dev, + "Cannot create sysfs pci link: %d\n", ret); + goto fail3; + } + ret = gasket_sysfs_create_entries( + gasket_dev->dev_info.device, gasket_sysfs_generic_attrs); + if (ret) + goto fail4; + + ret = check_and_invoke_callback( + gasket_dev, driver_desc->sysfs_setup_cb); + if (ret) { + dev_err(gasket_dev->dev, "Error in sysfs setup cb: %d\n", ret); + goto fail5; + } + + ret = gasket_enable_dev(internal_desc, gasket_dev); + if (ret) { + pr_err("cannot setup %s device\n", driver_desc->name); + gasket_disable_dev(gasket_dev); + goto fail5; + } + + return 0; + +fail5: + check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); +fail4: +fail3: + gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); +fail2: + gasket_cleanup_pci(gasket_dev); + check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); + device_destroy(internal_desc->class, gasket_dev->dev_info.devt); +fail1: + gasket_free_dev(gasket_dev); + return ret; +} + +/* + * PCI subsystem remove function. + * + * Called to remove a Gasket device. Finds the device in the device list and + * cleans up metadata. + */ +static void gasket_pci_remove(struct pci_dev *pci_dev) +{ + int i; + struct gasket_internal_desc *internal_desc; + struct gasket_dev *gasket_dev = NULL; + const struct gasket_driver_desc *driver_desc; + /* Find the device desc. */ + mutex_lock(&g_mutex); + internal_desc = lookup_internal_desc(pci_dev); + if (!internal_desc) { + mutex_unlock(&g_mutex); + return; + } + mutex_unlock(&g_mutex); + + driver_desc = internal_desc->driver_desc; + + /* Now find the specific device */ + mutex_lock(&internal_desc->mutex); + for (i = 0; i < GASKET_DEV_MAX; i++) { + if (internal_desc->devs[i] && + internal_desc->devs[i]->pci_dev == pci_dev) { + gasket_dev = internal_desc->devs[i]; + break; + } + } + mutex_unlock(&internal_desc->mutex); + + if (!gasket_dev) + return; + + pr_info("remove %s device %s\n", internal_desc->driver_desc->name, + gasket_dev->kobj_name); + + gasket_disable_dev(gasket_dev); + gasket_cleanup_pci(gasket_dev); + + check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); + gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); + + check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); + + device_destroy(internal_desc->class, gasket_dev->dev_info.devt); + gasket_free_dev(gasket_dev); +} + +/** + * Lookup a name by number in a num_name table. + * @num: Number to lookup. + * @table: Array of num_name structures, the table for the lookup. + * + * Description: Searches for num in the table. If found, the + * corresponding name is returned; otherwise NULL + * is returned. + * + * The table must have a NULL name pointer at the end. + */ +const char *gasket_num_name_lookup( + uint num, const struct gasket_num_name *table) +{ + uint i = 0; + + while (table[i].snn_name) { + if (num == table[i].snn_num) + break; + ++i; + } + + return table[i].snn_name; +} +EXPORT_SYMBOL(gasket_num_name_lookup); + int gasket_reset(struct gasket_dev *gasket_dev, uint reset_type) { int ret; @@ -1760,152 +1684,6 @@ gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( } EXPORT_SYMBOL(gasket_get_ioctl_permissions_cb); -static ssize_t gasket_write_mappable_regions( - char *buf, const struct gasket_driver_desc *driver_desc, int bar_index) -{ - int i; - ssize_t written; - ssize_t total_written = 0; - ulong min_addr, max_addr; - struct gasket_bar_desc bar_desc = - driver_desc->bar_descriptions[bar_index]; - - if (bar_desc.permissions == GASKET_NOMAP) - return 0; - for (i = 0; - i < bar_desc.num_mappable_regions && total_written < PAGE_SIZE; - i++) { - min_addr = bar_desc.mappable_regions[i].start - - driver_desc->legacy_mmap_address_offset; - max_addr = bar_desc.mappable_regions[i].start - - driver_desc->legacy_mmap_address_offset + - bar_desc.mappable_regions[i].length_bytes; - written = scnprintf(buf, PAGE_SIZE - total_written, - "0x%08lx-0x%08lx\n", min_addr, max_addr); - total_written += written; - buf += written; - } - return total_written; -} - -static ssize_t gasket_sysfs_data_show( - struct device *device, struct device_attribute *attr, char *buf) -{ - int i, ret = 0; - ssize_t current_written = 0; - const struct gasket_driver_desc *driver_desc; - struct gasket_dev *gasket_dev; - struct gasket_sysfs_attribute *gasket_attr; - const struct gasket_bar_desc *bar_desc; - enum gasket_sysfs_attribute_type sysfs_type; - - gasket_dev = gasket_sysfs_get_device_data(device); - if (!gasket_dev) { - dev_err(device, "No sysfs mapping found for device\n"); - return 0; - } - - gasket_attr = gasket_sysfs_get_attr(device, attr); - if (!gasket_attr) { - dev_err(device, "No sysfs attr found for device\n"); - gasket_sysfs_put_device_data(device, gasket_dev); - return 0; - } - - driver_desc = gasket_dev->internal_desc->driver_desc; - - sysfs_type = - (enum gasket_sysfs_attribute_type)gasket_attr->data.attr_type; - switch (sysfs_type) { - case ATTR_BAR_OFFSETS: - for (i = 0; i < GASKET_NUM_BARS; i++) { - bar_desc = &driver_desc->bar_descriptions[i]; - if (bar_desc->size == 0) - continue; - current_written = - snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i, - (ulong)bar_desc->base); - buf += current_written; - ret += current_written; - } - break; - case ATTR_BAR_SIZES: - for (i = 0; i < GASKET_NUM_BARS; i++) { - bar_desc = &driver_desc->bar_descriptions[i]; - if (bar_desc->size == 0) - continue; - current_written = - snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i, - (ulong)bar_desc->size); - buf += current_written; - ret += current_written; - } - break; - case ATTR_DRIVER_VERSION: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", - gasket_dev->internal_desc->driver_desc->driver_version); - break; - case ATTR_FRAMEWORK_VERSION: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", GASKET_FRAMEWORK_VERSION); - break; - case ATTR_DEVICE_TYPE: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", - gasket_dev->internal_desc->driver_desc->name); - break; - case ATTR_HARDWARE_REVISION: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", gasket_dev->hardware_revision); - break; - case ATTR_PCI_ADDRESS: - ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name); - break; - case ATTR_STATUS: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", - gasket_num_name_lookup( - gasket_dev->status, gasket_status_name_table)); - break; - case ATTR_IS_DEVICE_OWNED: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", - gasket_dev->dev_info.ownership.is_owned); - break; - case ATTR_DEVICE_OWNER: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", - gasket_dev->dev_info.ownership.owner); - break; - case ATTR_WRITE_OPEN_COUNT: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", - gasket_dev->dev_info.ownership.write_open_count); - break; - case ATTR_RESET_COUNT: - ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count); - break; - case ATTR_USER_MEM_RANGES: - for (i = 0; i < GASKET_NUM_BARS; ++i) { - current_written = gasket_write_mappable_regions( - buf, driver_desc, i); - buf += current_written; - ret += current_written; - } - break; - default: - dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", - attr->attr.name); - ret = 0; - break; - } - - gasket_sysfs_put_attr(device, gasket_attr); - gasket_sysfs_put_device_data(device, gasket_dev); - return ret; -} - /* Get the driver structure for a given gasket_dev. * @dev: pointer to gasket_dev, implementing the requested driver. */ @@ -1954,3 +1732,169 @@ int gasket_wait_with_reschedule( return -ETIMEDOUT; } EXPORT_SYMBOL(gasket_wait_with_reschedule); + +/* See gasket_core.h for description. */ +int gasket_register_device(const struct gasket_driver_desc *driver_desc) +{ + int i, ret; + int desc_idx = -1; + struct gasket_internal_desc *internal; + + pr_info("Initializing Gasket framework device\n"); + /* Check for duplicates and find a free slot. */ + mutex_lock(&g_mutex); + + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + if (g_descs[i].driver_desc == driver_desc) { + pr_err("%s driver already loaded/registered\n", + driver_desc->name); + mutex_unlock(&g_mutex); + return -EBUSY; + } + } + + /* This and the above loop could be combined, but this reads easier. */ + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + if (!g_descs[i].driver_desc) { + g_descs[i].driver_desc = driver_desc; + desc_idx = i; + break; + } + } + mutex_unlock(&g_mutex); + + pr_info("Loaded %s driver, framework version %s\n", + driver_desc->name, GASKET_FRAMEWORK_VERSION); + + if (desc_idx == -1) { + pr_err("Too many Gasket drivers loaded: %d\n", + GASKET_FRAMEWORK_DESC_MAX); + return -EBUSY; + } + + /* Internal structure setup. */ + pr_debug("Performing initial internal structure setup.\n"); + internal = &g_descs[desc_idx]; + mutex_init(&internal->mutex); + memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX); + memset(&internal->pci, 0, sizeof(internal->pci)); + internal->pci.name = driver_desc->name; + internal->pci.id_table = driver_desc->pci_id_table; + internal->pci.probe = gasket_pci_probe; + internal->pci.remove = gasket_pci_remove; + internal->class = + class_create(driver_desc->module, driver_desc->name); + + if (IS_ERR(internal->class)) { + pr_err("Cannot register %s class [ret=%ld]\n", + driver_desc->name, PTR_ERR(internal->class)); + ret = PTR_ERR(internal->class); + goto unregister_gasket_driver; + } + + /* + * Not using pci_register_driver() (without underscores), as it + * depends on KBUILD_MODNAME, and this is a shared file. + */ + pr_debug("Registering PCI driver.\n"); + ret = __pci_register_driver( + &internal->pci, driver_desc->module, driver_desc->name); + if (ret) { + pr_err("cannot register pci driver [ret=%d]\n", ret); + goto fail1; + } + + pr_debug("Registering char driver.\n"); + ret = register_chrdev_region( + MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, + driver_desc->name); + if (ret) { + pr_err("cannot register char driver [ret=%d]\n", ret); + goto fail2; + } + + pr_info("Driver registered successfully.\n"); + return 0; + +fail2: + pci_unregister_driver(&internal->pci); + +fail1: + class_destroy(internal->class); + +unregister_gasket_driver: + mutex_lock(&g_mutex); + g_descs[desc_idx].driver_desc = NULL; + mutex_unlock(&g_mutex); + return ret; +} +EXPORT_SYMBOL(gasket_register_device); + +/* See gasket_core.h for description. */ +void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) +{ + int i, desc_idx; + struct gasket_internal_desc *internal_desc = NULL; + + mutex_lock(&g_mutex); + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + if (g_descs[i].driver_desc == driver_desc) { + internal_desc = &g_descs[i]; + desc_idx = i; + break; + } + } + mutex_unlock(&g_mutex); + + if (!internal_desc) { + pr_err("request to unregister unknown desc: %s, %d:%d\n", + driver_desc->name, driver_desc->major, + driver_desc->minor); + return; + } + + unregister_chrdev_region( + MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX); + + pci_unregister_driver(&internal_desc->pci); + + class_destroy(internal_desc->class); + + /* Finally, effectively "remove" the driver. */ + mutex_lock(&g_mutex); + g_descs[desc_idx].driver_desc = NULL; + mutex_unlock(&g_mutex); + + pr_info("removed %s driver\n", driver_desc->name); +} +EXPORT_SYMBOL(gasket_unregister_device); + +static int __init gasket_init(void) +{ + int i; + + pr_info("Performing one-time init of the Gasket framework.\n"); + /* Check for duplicates and find a free slot. */ + mutex_lock(&g_mutex); + for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { + g_descs[i].driver_desc = NULL; + mutex_init(&g_descs[i].mutex); + } + + gasket_sysfs_init(); + + mutex_unlock(&g_mutex); + return 0; +} + +static void __exit gasket_exit(void) +{ + /* No deinit/dealloc needed at present. */ + pr_info("Removing Gasket framework module.\n"); +} +MODULE_DESCRIPTION("Google Gasket driver framework"); +MODULE_VERSION(GASKET_FRAMEWORK_VERSION); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Rob Springer "); +module_init(gasket_init); +module_exit(gasket_exit); From ea174ccd2a1144c6bc02943220a916e4a556f5ff Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:35 -0700 Subject: [PATCH 751/903] staging: gasket: ioctl: remove static function forward declarations Remove forward declarations of static functions, move code to avoid forward references, for kernel style. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 356 ++++++++++++-------------- 1 file changed, 168 insertions(+), 188 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 55bdd7bfac86..134d45a281ac 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -23,194 +23,6 @@ #define trace_gasket_ioctl_config_coherent_allocator(x, ...) #endif -static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd); -static int gasket_set_event_fd(struct gasket_dev *dev, - struct gasket_interrupt_eventfd __user *argp); -static int gasket_read_page_table_size( - struct gasket_dev *gasket_dev, - struct gasket_page_table_ioctl __user *argp); -static int gasket_read_simple_page_table_size( - struct gasket_dev *gasket_dev, - struct gasket_page_table_ioctl __user *argp); -static int gasket_partition_page_table( - struct gasket_dev *gasket_dev, - struct gasket_page_table_ioctl __user *argp); -static int gasket_map_buffers(struct gasket_dev *gasket_dev, - struct gasket_page_table_ioctl __user *argp); -static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, - struct gasket_page_table_ioctl __user *argp); -static int gasket_config_coherent_allocator( - struct gasket_dev *gasket_dev, - struct gasket_coherent_alloc_config_ioctl __user *argp); - -/* - * standard ioctl dispatch function. - * @filp: File structure pointer describing this node usage session. - * @cmd: ioctl number to handle. - * @argp: ioctl-specific data pointer. - * - * Standard ioctl dispatcher; forwards operations to individual handlers. - */ -long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) -{ - struct gasket_dev *gasket_dev; - unsigned long arg = (unsigned long)argp; - gasket_ioctl_permissions_cb_t ioctl_permissions_cb; - int retval; - - gasket_dev = (struct gasket_dev *)filp->private_data; - trace_gasket_ioctl_entry(gasket_dev->dev_info.name, cmd); - - ioctl_permissions_cb = gasket_get_ioctl_permissions_cb(gasket_dev); - if (ioctl_permissions_cb) { - retval = ioctl_permissions_cb(filp, cmd, argp); - if (retval < 0) { - trace_gasket_ioctl_exit(retval); - return retval; - } else if (retval == 0) { - trace_gasket_ioctl_exit(-EPERM); - return -EPERM; - } - } else if (!gasket_ioctl_check_permissions(filp, cmd)) { - trace_gasket_ioctl_exit(-EPERM); - dev_dbg(gasket_dev->dev, "ioctl cmd=%x noperm\n", cmd); - return -EPERM; - } - - /* Tracing happens in this switch statement for all ioctls with - * an integer argrument, but ioctls with a struct argument - * that needs copying and decoding, that tracing is done within - * the handler call. - */ - switch (cmd) { - case GASKET_IOCTL_RESET: - trace_gasket_ioctl_integer_data(arg); - retval = gasket_reset(gasket_dev, arg); - break; - case GASKET_IOCTL_SET_EVENTFD: - retval = gasket_set_event_fd(gasket_dev, argp); - break; - case GASKET_IOCTL_CLEAR_EVENTFD: - trace_gasket_ioctl_integer_data(arg); - retval = gasket_interrupt_clear_eventfd( - gasket_dev->interrupt_data, (int)arg); - break; - case GASKET_IOCTL_PARTITION_PAGE_TABLE: - trace_gasket_ioctl_integer_data(arg); - retval = gasket_partition_page_table(gasket_dev, argp); - break; - case GASKET_IOCTL_NUMBER_PAGE_TABLES: - trace_gasket_ioctl_integer_data(gasket_dev->num_page_tables); - if (copy_to_user(argp, &gasket_dev->num_page_tables, - sizeof(uint64_t))) - retval = -EFAULT; - else - retval = 0; - break; - case GASKET_IOCTL_PAGE_TABLE_SIZE: - retval = gasket_read_page_table_size(gasket_dev, argp); - break; - case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: - retval = gasket_read_simple_page_table_size(gasket_dev, argp); - break; - case GASKET_IOCTL_MAP_BUFFER: - retval = gasket_map_buffers(gasket_dev, argp); - break; - case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: - retval = gasket_config_coherent_allocator(gasket_dev, argp); - break; - case GASKET_IOCTL_UNMAP_BUFFER: - retval = gasket_unmap_buffers(gasket_dev, argp); - break; - case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: - /* Clear interrupt counts doesn't take an arg, so use 0. */ - trace_gasket_ioctl_integer_data(0); - retval = gasket_interrupt_reset_counts(gasket_dev); - break; - default: - /* If we don't understand the ioctl, the best we can do is trace - * the arg. - */ - trace_gasket_ioctl_integer_data(arg); - dev_dbg(gasket_dev->dev, - "Unknown ioctl cmd=0x%x not caught by " - "gasket_is_supported_ioctl\n", - cmd); - retval = -EINVAL; - break; - } - - trace_gasket_ioctl_exit(retval); - return retval; -} - -/* - * Determines if an ioctl is part of the standard Gasket framework. - * @cmd: The ioctl number to handle. - * - * Returns 1 if the ioctl is supported and 0 otherwise. - */ -long gasket_is_supported_ioctl(uint cmd) -{ - switch (cmd) { - case GASKET_IOCTL_RESET: - case GASKET_IOCTL_SET_EVENTFD: - case GASKET_IOCTL_CLEAR_EVENTFD: - case GASKET_IOCTL_PARTITION_PAGE_TABLE: - case GASKET_IOCTL_NUMBER_PAGE_TABLES: - case GASKET_IOCTL_PAGE_TABLE_SIZE: - case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: - case GASKET_IOCTL_MAP_BUFFER: - case GASKET_IOCTL_UNMAP_BUFFER: - case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: - case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: - return 1; - default: - return 0; - } -} - -/* Check permissions for Gasket ioctls. */ -static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd) -{ - bool alive; - bool read, write; - struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data; - - alive = (gasket_dev->status == GASKET_STATUS_ALIVE); - if (!alive) - dev_dbg(gasket_dev->dev, "%s alive %d status %d\n", - __func__, alive, gasket_dev->status); - - read = !!(filp->f_mode & FMODE_READ); - write = !!(filp->f_mode & FMODE_WRITE); - - switch (cmd) { - case GASKET_IOCTL_RESET: - case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: - return write; - - case GASKET_IOCTL_PAGE_TABLE_SIZE: - case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: - case GASKET_IOCTL_NUMBER_PAGE_TABLES: - return read; - - case GASKET_IOCTL_PARTITION_PAGE_TABLE: - case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: - return alive && write; - - case GASKET_IOCTL_MAP_BUFFER: - case GASKET_IOCTL_UNMAP_BUFFER: - return alive && write; - - case GASKET_IOCTL_CLEAR_EVENTFD: - case GASKET_IOCTL_SET_EVENTFD: - return alive && write; - } - - return false; /* unknown permissions */ -} - /* Associate an eventfd with an interrupt. */ static int gasket_set_event_fd(struct gasket_dev *gasket_dev, struct gasket_interrupt_eventfd __user *argp) @@ -410,3 +222,171 @@ static int gasket_config_coherent_allocator( return 0; } + +/* Check permissions for Gasket ioctls. */ +static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd) +{ + bool alive; + bool read, write; + struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data; + + alive = (gasket_dev->status == GASKET_STATUS_ALIVE); + if (!alive) + dev_dbg(gasket_dev->dev, "%s alive %d status %d\n", + __func__, alive, gasket_dev->status); + + read = !!(filp->f_mode & FMODE_READ); + write = !!(filp->f_mode & FMODE_WRITE); + + switch (cmd) { + case GASKET_IOCTL_RESET: + case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: + return write; + + case GASKET_IOCTL_PAGE_TABLE_SIZE: + case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: + case GASKET_IOCTL_NUMBER_PAGE_TABLES: + return read; + + case GASKET_IOCTL_PARTITION_PAGE_TABLE: + case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: + return alive && write; + + case GASKET_IOCTL_MAP_BUFFER: + case GASKET_IOCTL_UNMAP_BUFFER: + return alive && write; + + case GASKET_IOCTL_CLEAR_EVENTFD: + case GASKET_IOCTL_SET_EVENTFD: + return alive && write; + } + + return false; /* unknown permissions */ +} + +/* + * standard ioctl dispatch function. + * @filp: File structure pointer describing this node usage session. + * @cmd: ioctl number to handle. + * @argp: ioctl-specific data pointer. + * + * Standard ioctl dispatcher; forwards operations to individual handlers. + */ +long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) +{ + struct gasket_dev *gasket_dev; + unsigned long arg = (unsigned long)argp; + gasket_ioctl_permissions_cb_t ioctl_permissions_cb; + int retval; + + gasket_dev = (struct gasket_dev *)filp->private_data; + trace_gasket_ioctl_entry(gasket_dev->dev_info.name, cmd); + + ioctl_permissions_cb = gasket_get_ioctl_permissions_cb(gasket_dev); + if (ioctl_permissions_cb) { + retval = ioctl_permissions_cb(filp, cmd, argp); + if (retval < 0) { + trace_gasket_ioctl_exit(retval); + return retval; + } else if (retval == 0) { + trace_gasket_ioctl_exit(-EPERM); + return -EPERM; + } + } else if (!gasket_ioctl_check_permissions(filp, cmd)) { + trace_gasket_ioctl_exit(-EPERM); + dev_dbg(gasket_dev->dev, "ioctl cmd=%x noperm\n", cmd); + return -EPERM; + } + + /* Tracing happens in this switch statement for all ioctls with + * an integer argrument, but ioctls with a struct argument + * that needs copying and decoding, that tracing is done within + * the handler call. + */ + switch (cmd) { + case GASKET_IOCTL_RESET: + trace_gasket_ioctl_integer_data(arg); + retval = gasket_reset(gasket_dev, arg); + break; + case GASKET_IOCTL_SET_EVENTFD: + retval = gasket_set_event_fd(gasket_dev, argp); + break; + case GASKET_IOCTL_CLEAR_EVENTFD: + trace_gasket_ioctl_integer_data(arg); + retval = gasket_interrupt_clear_eventfd( + gasket_dev->interrupt_data, (int)arg); + break; + case GASKET_IOCTL_PARTITION_PAGE_TABLE: + trace_gasket_ioctl_integer_data(arg); + retval = gasket_partition_page_table(gasket_dev, argp); + break; + case GASKET_IOCTL_NUMBER_PAGE_TABLES: + trace_gasket_ioctl_integer_data(gasket_dev->num_page_tables); + if (copy_to_user(argp, &gasket_dev->num_page_tables, + sizeof(uint64_t))) + retval = -EFAULT; + else + retval = 0; + break; + case GASKET_IOCTL_PAGE_TABLE_SIZE: + retval = gasket_read_page_table_size(gasket_dev, argp); + break; + case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: + retval = gasket_read_simple_page_table_size(gasket_dev, argp); + break; + case GASKET_IOCTL_MAP_BUFFER: + retval = gasket_map_buffers(gasket_dev, argp); + break; + case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: + retval = gasket_config_coherent_allocator(gasket_dev, argp); + break; + case GASKET_IOCTL_UNMAP_BUFFER: + retval = gasket_unmap_buffers(gasket_dev, argp); + break; + case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: + /* Clear interrupt counts doesn't take an arg, so use 0. */ + trace_gasket_ioctl_integer_data(0); + retval = gasket_interrupt_reset_counts(gasket_dev); + break; + default: + /* If we don't understand the ioctl, the best we can do is trace + * the arg. + */ + trace_gasket_ioctl_integer_data(arg); + dev_dbg(gasket_dev->dev, + "Unknown ioctl cmd=0x%x not caught by " + "gasket_is_supported_ioctl\n", + cmd); + retval = -EINVAL; + break; + } + + trace_gasket_ioctl_exit(retval); + return retval; +} + +/* + * Determines if an ioctl is part of the standard Gasket framework. + * @cmd: The ioctl number to handle. + * + * Returns 1 if the ioctl is supported and 0 otherwise. + */ +long gasket_is_supported_ioctl(uint cmd) +{ + switch (cmd) { + case GASKET_IOCTL_RESET: + case GASKET_IOCTL_SET_EVENTFD: + case GASKET_IOCTL_CLEAR_EVENTFD: + case GASKET_IOCTL_PARTITION_PAGE_TABLE: + case GASKET_IOCTL_NUMBER_PAGE_TABLES: + case GASKET_IOCTL_PAGE_TABLE_SIZE: + case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE: + case GASKET_IOCTL_MAP_BUFFER: + case GASKET_IOCTL_UNMAP_BUFFER: + case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS: + case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR: + return 1; + default: + return 0; + } +} From d821f8eb92ef500cee280e9467e8d89c8de5da0b Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:36 -0700 Subject: [PATCH 752/903] staging: gasket: interrupt: remove static function forward declarations Remove forward declarations of static functions, move code to avoid forward references, for kernel style. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 499 +++++++++++----------- 1 file changed, 242 insertions(+), 257 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 27fde991edc6..3079b59b122b 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -70,32 +70,259 @@ struct gasket_interrupt_data { int irq; }; -/* Function definitions. */ -static ssize_t interrupt_sysfs_show( - struct device *device, struct device_attribute *attr, char *buf); - -static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id); - /* Structures to display interrupt counts in sysfs. */ enum interrupt_sysfs_attribute_type { ATTR_INTERRUPT_COUNTS, }; +/* Set up device registers for interrupt handling. */ +static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) +{ + int i; + int pack_shift; + ulong mask; + ulong value; + struct gasket_interrupt_data *interrupt_data = + gasket_dev->interrupt_data; + + if (!interrupt_data) { + dev_dbg(gasket_dev->dev, "Interrupt data is not initialized\n"); + return; + } + + dev_dbg(gasket_dev->dev, "Running interrupt setup\n"); + + if (interrupt_data->type == PLATFORM_WIRE || + interrupt_data->type == PCI_MSI) { + /* Nothing needs to be done for platform or PCI devices. */ + return; + } + + if (interrupt_data->type != PCI_MSIX) { + dev_dbg(gasket_dev->dev, + "Cannot handle unsupported interrupt type %d\n", + interrupt_data->type); + return; + } + + /* Setup the MSIX table. */ + + for (i = 0; i < interrupt_data->num_interrupts; i++) { + /* + * If the interrupt is not packed, we can write the index into + * the register directly. If not, we need to deal with a read- + * modify-write and shift based on the packing index. + */ + dev_dbg(gasket_dev->dev, + "Setting up interrupt index %d with index 0x%llx and " + "packing %d\n", + interrupt_data->interrupts[i].index, + interrupt_data->interrupts[i].reg, + interrupt_data->interrupts[i].packing); + if (interrupt_data->interrupts[i].packing == UNPACKED) { + value = interrupt_data->interrupts[i].index; + } else { + switch (interrupt_data->interrupts[i].packing) { + case PACK_0: + pack_shift = 0; + break; + case PACK_1: + pack_shift = interrupt_data->pack_width; + break; + case PACK_2: + pack_shift = 2 * interrupt_data->pack_width; + break; + case PACK_3: + pack_shift = 3 * interrupt_data->pack_width; + break; + default: + dev_dbg(gasket_dev->dev, + "Found interrupt description with " + "unknown enum %d\n", + interrupt_data->interrupts[i].packing); + return; + } + + mask = ~(0xFFFF << pack_shift); + value = gasket_dev_read_64( + gasket_dev, + interrupt_data->interrupt_bar_index, + interrupt_data->interrupts[i].reg) & + mask; + value |= interrupt_data->interrupts[i].index + << pack_shift; + } + gasket_dev_write_64(gasket_dev, value, + interrupt_data->interrupt_bar_index, + interrupt_data->interrupts[i].reg); + } +} + +static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id) +{ + struct eventfd_ctx *ctx; + struct gasket_interrupt_data *interrupt_data = dev_id; + int interrupt = -1; + int i; + + /* If this linear lookup is a problem, we can maintain a map/hash. */ + for (i = 0; i < interrupt_data->num_interrupts; i++) { + if (interrupt_data->msix_entries[i].vector == irq) { + interrupt = interrupt_data->msix_entries[i].entry; + break; + } + } + if (interrupt == -1) { + pr_err("Received unknown irq %d\n", irq); + return IRQ_HANDLED; + } + trace_gasket_interrupt_event(interrupt_data->name, interrupt); + + ctx = interrupt_data->eventfd_ctxs[interrupt]; + if (ctx) + eventfd_signal(ctx, 1); + + ++(interrupt_data->interrupt_counts[interrupt]); + + return IRQ_HANDLED; +} + +static int gasket_interrupt_msix_init( + struct gasket_interrupt_data *interrupt_data) +{ + int ret = 1; + int i; + + for (i = 0; i < interrupt_data->num_interrupts; i++) { + interrupt_data->msix_entries[i].entry = i; + interrupt_data->msix_entries[i].vector = 0; + interrupt_data->eventfd_ctxs[i] = NULL; + } + + /* Retry MSIX_RETRY_COUNT times if not enough IRQs are available. */ + for (i = 0; i < MSIX_RETRY_COUNT && ret > 0; i++) + ret = pci_enable_msix_exact(interrupt_data->pci_dev, + interrupt_data->msix_entries, + interrupt_data->num_interrupts); + + if (ret) + return ret > 0 ? -EBUSY : ret; + interrupt_data->msix_configured = 1; + + for (i = 0; i < interrupt_data->num_interrupts; i++) { + ret = request_irq( + interrupt_data->msix_entries[i].vector, + gasket_msix_interrupt_handler, 0, interrupt_data->name, + interrupt_data); + + if (ret) { + dev_err(&interrupt_data->pci_dev->dev, + "Cannot get IRQ for interrupt %d, vector %d; " + "%d\n", + i, interrupt_data->msix_entries[i].vector, ret); + return ret; + } + + interrupt_data->num_configured++; + } + + return 0; +} + +/* + * On QCM DragonBoard, we exit gasket_interrupt_msix_init() and kernel interrupt + * setup code with MSIX vectors masked. This is wrong because nothing else in + * the driver will normally touch the MSIX vectors. + * + * As a temporary hack, force unmasking there. + * + * TODO: Figure out why QCM kernel doesn't unmask the MSIX vectors, after + * gasket_interrupt_msix_init(), and remove this code. + */ +static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev) +{ + int i; +#define MSIX_VECTOR_SIZE 16 +#define MSIX_MASK_BIT_OFFSET 12 +#define APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE 0x46800 + for (i = 0; i < gasket_dev->interrupt_data->num_configured; i++) { + /* Check if the MSIX vector is unmasked */ + ulong location = APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE + + MSIX_MASK_BIT_OFFSET + i * MSIX_VECTOR_SIZE; + u32 mask = + gasket_dev_read_32( + gasket_dev, + gasket_dev->interrupt_data->interrupt_bar_index, + location); + if (!(mask & 1)) + continue; + /* Unmask the msix vector (clear 32 bits) */ + gasket_dev_write_32( + gasket_dev, 0, + gasket_dev->interrupt_data->interrupt_bar_index, + location); + } +#undef MSIX_VECTOR_SIZE +#undef MSIX_MASK_BIT_OFFSET +#undef APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE +} + +static ssize_t interrupt_sysfs_show( + struct device *device, struct device_attribute *attr, char *buf) +{ + int i, ret; + ssize_t written = 0, total_written = 0; + struct gasket_interrupt_data *interrupt_data; + struct gasket_dev *gasket_dev; + struct gasket_sysfs_attribute *gasket_attr; + enum interrupt_sysfs_attribute_type sysfs_type; + + gasket_dev = gasket_sysfs_get_device_data(device); + if (!gasket_dev) { + dev_dbg(device, "No sysfs mapping found for device\n"); + return 0; + } + + gasket_attr = gasket_sysfs_get_attr(device, attr); + if (!gasket_attr) { + dev_dbg(device, "No sysfs attr data found for device\n"); + gasket_sysfs_put_device_data(device, gasket_dev); + return 0; + } + + sysfs_type = (enum interrupt_sysfs_attribute_type) + gasket_attr->data.attr_type; + interrupt_data = gasket_dev->interrupt_data; + switch (sysfs_type) { + case ATTR_INTERRUPT_COUNTS: + for (i = 0; i < interrupt_data->num_interrupts; ++i) { + written = + scnprintf(buf, PAGE_SIZE - total_written, + "0x%02x: %ld\n", i, + interrupt_data->interrupt_counts[i]); + total_written += written; + buf += written; + } + ret = total_written; + break; + default: + dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", + attr->attr.name); + ret = 0; + break; + } + + gasket_sysfs_put_attr(device, gasket_attr); + gasket_sysfs_put_device_data(device, gasket_dev); + return ret; +} + static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = { GASKET_SYSFS_RO( interrupt_counts, interrupt_sysfs_show, ATTR_INTERRUPT_COUNTS), GASKET_END_OF_ATTR_ARRAY, }; -static void gasket_interrupt_setup(struct gasket_dev *gasket_dev); - -/* MSIX init and cleanup. */ -static int gasket_interrupt_msix_init( - struct gasket_interrupt_data *interrupt_data); -static void gasket_interrupt_msix_cleanup( - struct gasket_interrupt_data *interrupt_data); -static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev); - int gasket_interrupt_init( struct gasket_dev *gasket_dev, const char *name, int type, const struct gasket_interrupt_desc *interrupts, @@ -181,48 +408,6 @@ int gasket_interrupt_init( return 0; } -static int gasket_interrupt_msix_init( - struct gasket_interrupt_data *interrupt_data) -{ - int ret = 1; - int i; - - for (i = 0; i < interrupt_data->num_interrupts; i++) { - interrupt_data->msix_entries[i].entry = i; - interrupt_data->msix_entries[i].vector = 0; - interrupt_data->eventfd_ctxs[i] = NULL; - } - - /* Retry MSIX_RETRY_COUNT times if not enough IRQs are available. */ - for (i = 0; i < MSIX_RETRY_COUNT && ret > 0; i++) - ret = pci_enable_msix_exact(interrupt_data->pci_dev, - interrupt_data->msix_entries, - interrupt_data->num_interrupts); - - if (ret) - return ret > 0 ? -EBUSY : ret; - interrupt_data->msix_configured = 1; - - for (i = 0; i < interrupt_data->num_interrupts; i++) { - ret = request_irq( - interrupt_data->msix_entries[i].vector, - gasket_msix_interrupt_handler, 0, interrupt_data->name, - interrupt_data); - - if (ret) { - dev_err(&interrupt_data->pci_dev->dev, - "Cannot get IRQ for interrupt %d, vector %d; " - "%d\n", - i, interrupt_data->msix_entries[i].vector, ret); - return ret; - } - - interrupt_data->num_configured++; - } - - return 0; -} - static void gasket_interrupt_msix_cleanup( struct gasket_interrupt_data *interrupt_data) { @@ -238,44 +423,6 @@ static void gasket_interrupt_msix_cleanup( interrupt_data->msix_configured = 0; } -/* - * On QCM DragonBoard, we exit gasket_interrupt_msix_init() and kernel interrupt - * setup code with MSIX vectors masked. This is wrong because nothing else in - * the driver will normally touch the MSIX vectors. - * - * As a temporary hack, force unmasking there. - * - * TODO: Figure out why QCM kernel doesn't unmask the MSIX vectors, after - * gasket_interrupt_msix_init(), and remove this code. - */ -static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev) -{ - int i; -#define MSIX_VECTOR_SIZE 16 -#define MSIX_MASK_BIT_OFFSET 12 -#define APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE 0x46800 - for (i = 0; i < gasket_dev->interrupt_data->num_configured; i++) { - /* Check if the MSIX vector is unmasked */ - ulong location = APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE + - MSIX_MASK_BIT_OFFSET + i * MSIX_VECTOR_SIZE; - u32 mask = - gasket_dev_read_32( - gasket_dev, - gasket_dev->interrupt_data->interrupt_bar_index, - location); - if (!(mask & 1)) - continue; - /* Unmask the msix vector (clear 32 bits) */ - gasket_dev_write_32( - gasket_dev, 0, - gasket_dev->interrupt_data->interrupt_bar_index, - location); - } -#undef MSIX_VECTOR_SIZE -#undef MSIX_MASK_BIT_OFFSET -#undef APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE -} - int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) { int ret; @@ -327,89 +474,6 @@ int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev) return 0; } -/* Set up device registers for interrupt handling. */ -static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) -{ - int i; - int pack_shift; - ulong mask; - ulong value; - struct gasket_interrupt_data *interrupt_data = - gasket_dev->interrupt_data; - - if (!interrupt_data) { - dev_dbg(gasket_dev->dev, "Interrupt data is not initialized\n"); - return; - } - - dev_dbg(gasket_dev->dev, "Running interrupt setup\n"); - - if (interrupt_data->type == PLATFORM_WIRE || - interrupt_data->type == PCI_MSI) { - /* Nothing needs to be done for platform or PCI devices. */ - return; - } - - if (interrupt_data->type != PCI_MSIX) { - dev_dbg(gasket_dev->dev, - "Cannot handle unsupported interrupt type %d\n", - interrupt_data->type); - return; - } - - /* Setup the MSIX table. */ - - for (i = 0; i < interrupt_data->num_interrupts; i++) { - /* - * If the interrupt is not packed, we can write the index into - * the register directly. If not, we need to deal with a read- - * modify-write and shift based on the packing index. - */ - dev_dbg(gasket_dev->dev, - "Setting up interrupt index %d with index 0x%llx and " - "packing %d\n", - interrupt_data->interrupts[i].index, - interrupt_data->interrupts[i].reg, - interrupt_data->interrupts[i].packing); - if (interrupt_data->interrupts[i].packing == UNPACKED) { - value = interrupt_data->interrupts[i].index; - } else { - switch (interrupt_data->interrupts[i].packing) { - case PACK_0: - pack_shift = 0; - break; - case PACK_1: - pack_shift = interrupt_data->pack_width; - break; - case PACK_2: - pack_shift = 2 * interrupt_data->pack_width; - break; - case PACK_3: - pack_shift = 3 * interrupt_data->pack_width; - break; - default: - dev_dbg(gasket_dev->dev, - "Found interrupt description with " - "unknown enum %d\n", - interrupt_data->interrupts[i].packing); - return; - } - - mask = ~(0xFFFF << pack_shift); - value = gasket_dev_read_64( - gasket_dev, - interrupt_data->interrupt_bar_index, - interrupt_data->interrupts[i].reg) & - mask; - value |= interrupt_data->interrupts[i].index - << pack_shift; - } - gasket_dev_write_64(gasket_dev, value, - interrupt_data->interrupt_bar_index, - interrupt_data->interrupts[i].reg); - } -} - /* See gasket_interrupt.h for description. */ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) { @@ -489,82 +553,3 @@ int gasket_interrupt_clear_eventfd( interrupt_data->eventfd_ctxs[interrupt] = NULL; return 0; } - -static ssize_t interrupt_sysfs_show( - struct device *device, struct device_attribute *attr, char *buf) -{ - int i, ret; - ssize_t written = 0, total_written = 0; - struct gasket_interrupt_data *interrupt_data; - struct gasket_dev *gasket_dev; - struct gasket_sysfs_attribute *gasket_attr; - enum interrupt_sysfs_attribute_type sysfs_type; - - gasket_dev = gasket_sysfs_get_device_data(device); - if (!gasket_dev) { - dev_dbg(device, "No sysfs mapping found for device\n"); - return 0; - } - - gasket_attr = gasket_sysfs_get_attr(device, attr); - if (!gasket_attr) { - dev_dbg(device, "No sysfs attr data found for device\n"); - gasket_sysfs_put_device_data(device, gasket_dev); - return 0; - } - - sysfs_type = (enum interrupt_sysfs_attribute_type) - gasket_attr->data.attr_type; - interrupt_data = gasket_dev->interrupt_data; - switch (sysfs_type) { - case ATTR_INTERRUPT_COUNTS: - for (i = 0; i < interrupt_data->num_interrupts; ++i) { - written = - scnprintf(buf, PAGE_SIZE - total_written, - "0x%02x: %ld\n", i, - interrupt_data->interrupt_counts[i]); - total_written += written; - buf += written; - } - ret = total_written; - break; - default: - dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", - attr->attr.name); - ret = 0; - break; - } - - gasket_sysfs_put_attr(device, gasket_attr); - gasket_sysfs_put_device_data(device, gasket_dev); - return ret; -} - -static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id) -{ - struct eventfd_ctx *ctx; - struct gasket_interrupt_data *interrupt_data = dev_id; - int interrupt = -1; - int i; - - /* If this linear lookup is a problem, we can maintain a map/hash. */ - for (i = 0; i < interrupt_data->num_interrupts; i++) { - if (interrupt_data->msix_entries[i].vector == irq) { - interrupt = interrupt_data->msix_entries[i].entry; - break; - } - } - if (interrupt == -1) { - pr_err("Received unknown irq %d\n", irq); - return IRQ_HANDLED; - } - trace_gasket_interrupt_event(interrupt_data->name, interrupt); - - ctx = interrupt_data->eventfd_ctxs[interrupt]; - if (ctx) - eventfd_signal(ctx, 1); - - ++(interrupt_data->interrupt_counts[interrupt]); - - return IRQ_HANDLED; -} From 00b60c8d9ed7e9505b70143af04497625d5ef019 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:37 -0700 Subject: [PATCH 753/903] staging: gasket: pg tbl: remove static function forward declarations Remove forward declarations of static functions, move code to avoid forward references, for kernel style. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 1431 ++++++++++---------- 1 file changed, 683 insertions(+), 748 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index b42f6637b909..aa036b2e8193 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -214,71 +214,6 @@ struct gasket_page_table { struct gasket_coherent_page_entry *coherent_pages; }; -/* Mapping declarations */ -static int gasket_map_simple_pages( - struct gasket_page_table *pg_tbl, ulong host_addr, - ulong dev_addr, uint num_pages); -static int gasket_map_extended_pages( - struct gasket_page_table *pg_tbl, ulong host_addr, - ulong dev_addr, uint num_pages); -static int gasket_perform_mapping( - struct gasket_page_table *pg_tbl, - struct gasket_page_table_entry *pte_base, u64 __iomem *att_base, - ulong host_addr, uint num_pages, int is_simple_mapping); - -static int gasket_alloc_simple_entries( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); -static int gasket_alloc_extended_entries( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries); -static int gasket_alloc_extended_subtable( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, - u64 __iomem *att_reg); - -/* Unmapping declarations */ -static void gasket_page_table_unmap_nolock( - struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages); -static void gasket_page_table_unmap_all_nolock( - struct gasket_page_table *pg_tbl); -static void gasket_unmap_simple_pages( - struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages); -static void gasket_unmap_extended_pages( - struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages); -static void gasket_perform_unmapping( - struct gasket_page_table *pg_tbl, - struct gasket_page_table_entry *pte_base, u64 __iomem *att_base, - uint num_pages, int is_simple_mapping); - -static void gasket_free_extended_subtable( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, - u64 __iomem *att_reg); -static bool gasket_release_page(struct page *page); - -/* Other/utility declarations */ -static inline bool gasket_addr_is_simple( - struct gasket_page_table *pg_tbl, ulong addr); -static bool gasket_is_simple_dev_addr_bad( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); -static bool gasket_is_extended_dev_addr_bad( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages); -static bool gasket_is_pte_range_free( - struct gasket_page_table_entry *pte, uint num_entries); -static void gasket_page_table_garbage_collect_nolock( - struct gasket_page_table *pg_tbl); - -/* Address format declarations */ -static ulong gasket_components_to_dev_address( - struct gasket_page_table *pg_tbl, int is_simple, uint page_index, - uint offset); -static int gasket_simple_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr); -static ulong gasket_extended_lvl0_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr); -static ulong gasket_extended_lvl1_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr); - -static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr); - -/* Public/exported functions */ /* See gasket_page_table.h for description. */ int gasket_page_table_init( struct gasket_page_table **ppg_tbl, @@ -353,6 +288,85 @@ int gasket_page_table_init( return 0; } +/* + * Check if a range of PTEs is free. + * The page table mutex must be held by the caller. + */ +static bool gasket_is_pte_range_free( + struct gasket_page_table_entry *ptes, uint num_entries) +{ + int i; + + for (i = 0; i < num_entries; i++) { + if (ptes[i].status != PTE_FREE) + return false; + } + + return true; +} + +/* + * Free a second level page [sub]table. + * The page table mutex must be held before this call. + */ +static void gasket_free_extended_subtable( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, + u64 __iomem *slot) +{ + /* Release the page table from the driver */ + pte->status = PTE_FREE; + + /* Release the page table from the device */ + writeq(0, slot); + /* Force sync around the address release. */ + mb(); + + if (pte->dma_addr) + dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE, + DMA_BIDIRECTIONAL); + + vfree(pte->sublevel); + + if (pte->page) + free_page((ulong)page_address(pte->page)); + + memset(pte, 0, sizeof(struct gasket_page_table_entry)); +} + +/* + * Actually perform collection. + * The page table mutex must be held by the caller. + */ +static void gasket_page_table_garbage_collect_nolock( + struct gasket_page_table *pg_tbl) +{ + struct gasket_page_table_entry *pte; + u64 __iomem *slot; + + /* XXX FIX ME XXX -- more efficient to keep a usage count */ + /* rather than scanning the second level page tables */ + + for (pte = pg_tbl->entries + pg_tbl->num_simple_entries, + slot = pg_tbl->base_slot + pg_tbl->num_simple_entries; + pte < pg_tbl->entries + pg_tbl->config.total_entries; + pte++, slot++) { + if (pte->status == PTE_INUSE) { + if (gasket_is_pte_range_free( + pte->sublevel, GASKET_PAGES_PER_SUBTABLE)) + gasket_free_extended_subtable( + pg_tbl, pte, slot); + } + } +} + +/* See gasket_page_table.h for description. */ +void gasket_page_table_garbage_collect(struct gasket_page_table *pg_tbl) +{ + mutex_lock(&pg_tbl->mutex); + gasket_page_table_garbage_collect_nolock(pg_tbl); + mutex_unlock(&pg_tbl->mutex); +} + /* See gasket_page_table.h for description. */ void gasket_page_table_cleanup(struct gasket_page_table *pg_tbl) { @@ -403,6 +417,610 @@ int gasket_page_table_partition( } EXPORT_SYMBOL(gasket_page_table_partition); +/* + * Return whether a host buffer was mapped as coherent memory. + * + * A Gasket page_table currently support one contiguous dma range, mapped to one + * contiguous virtual memory range. Check if the host_addr is within that range. + */ +static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr) +{ + u64 min, max; + + /* whether the host address is within user virt range */ + if (!pg_tbl->coherent_pages) + return 0; + + min = (u64)pg_tbl->coherent_pages[0].user_virt; + max = min + PAGE_SIZE * pg_tbl->num_coherent_pages; + + return min <= host_addr && host_addr < max; +} + +/* + * Get and map last level page table buffers. + * + * slots is the location(s) to write device-mapped page address. If this is a + * simple mapping, these will be address translation registers. If this is + * an extended mapping, these will be within a second-level page table + * allocated by the host and so must have their __iomem attribute casted away. + */ +static int gasket_perform_mapping( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, + u64 __iomem *slots, ulong host_addr, uint num_pages, + int is_simple_mapping) +{ + int ret; + ulong offset; + struct page *page; + dma_addr_t dma_addr; + ulong page_addr; + int i; + + for (i = 0; i < num_pages; i++) { + page_addr = host_addr + i * PAGE_SIZE; + offset = page_addr & (PAGE_SIZE - 1); + dev_dbg(pg_tbl->device, "%s i %d\n", __func__, i); + if (is_coherent(pg_tbl, host_addr)) { + u64 off = + (u64)host_addr - + (u64)pg_tbl->coherent_pages[0].user_virt; + ptes[i].page = NULL; + ptes[i].offset = offset; + ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + + off + i * PAGE_SIZE; + } else { + ret = get_user_pages_fast( + page_addr - offset, 1, 1, &page); + + if (ret <= 0) { + dev_err(pg_tbl->device, + "get user pages failed for addr=0x%lx, " + "offset=0x%lx [ret=%d]\n", + page_addr, offset, ret); + return ret ? ret : -ENOMEM; + } + ++pg_tbl->num_active_pages; + + ptes[i].page = page; + ptes[i].offset = offset; + + /* Map the page into DMA space. */ + ptes[i].dma_addr = + dma_map_page(pg_tbl->device, page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); + dev_dbg(pg_tbl->device, + "%s i %d pte %p pfn %p -> mapped %llx\n", + __func__, i, &ptes[i], + (void *)page_to_pfn(page), + (unsigned long long)ptes[i].dma_addr); + + if (ptes[i].dma_addr == -1) { + dev_dbg(pg_tbl->device, + "%s i %d -> fail to map page %llx " + "[pfn %p ohys %p]\n", + __func__, i, + (unsigned long long)ptes[i].dma_addr, + (void *)page_to_pfn(page), + (void *)page_to_phys(page)); + return -1; + } + /* Wait until the page is mapped. */ + mb(); + } + + /* Make the DMA-space address available to the device. */ + dma_addr = (ptes[i].dma_addr + offset) | GASKET_VALID_SLOT_FLAG; + + if (is_simple_mapping) { + writeq(dma_addr, &slots[i]); + } else { + ((u64 __force *)slots)[i] = dma_addr; + /* Extended page table vectors are in DRAM, + * and so need to be synced each time they are updated. + */ + dma_map_single(pg_tbl->device, + (void *)&((u64 __force *)slots)[i], + sizeof(u64), DMA_TO_DEVICE); + } + ptes[i].status = PTE_INUSE; + } + return 0; +} + +/* + * Return the index of the page for the address in the simple table. + * Does not perform validity checking. + */ +static int gasket_simple_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr) +{ + return (dev_addr >> GASKET_SIMPLE_PAGE_SHIFT) & + (pg_tbl->config.total_entries - 1); +} + +/* + * Return the level 0 page index for the given address. + * Does not perform validity checking. + */ +static ulong gasket_extended_lvl0_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr) +{ + return (dev_addr >> GASKET_EXTENDED_LVL0_SHIFT) & + ((1 << GASKET_EXTENDED_LVL0_WIDTH) - 1); +} + +/* + * Return the level 1 page index for the given address. + * Does not perform validity checking. + */ +static ulong gasket_extended_lvl1_page_idx( + struct gasket_page_table *pg_tbl, ulong dev_addr) +{ + return (dev_addr >> GASKET_EXTENDED_LVL1_SHIFT) & + (GASKET_PAGES_PER_SUBTABLE - 1); +} + +/* + * Allocate page table entries in a simple table. + * The page table mutex must be held by the caller. + */ +static int gasket_alloc_simple_entries( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + if (!gasket_is_pte_range_free( + pg_tbl->entries + gasket_simple_page_idx(pg_tbl, dev_addr), + num_pages)) + return -EBUSY; + + return 0; +} + +/* Safely return a page to the OS. */ +static bool gasket_release_page(struct page *page) +{ + if (!page) + return false; + + if (!PageReserved(page)) + SetPageDirty(page); + put_page(page); + + return true; +} + +/* + * Unmap and release mapped pages. + * The page table mutex must be held by the caller. + */ +static void gasket_perform_unmapping( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, + u64 __iomem *slots, uint num_pages, int is_simple_mapping) +{ + int i; + /* + * For each page table entry and corresponding entry in the device's + * address translation table: + */ + for (i = 0; i < num_pages; i++) { + /* release the address from the device, */ + if (is_simple_mapping || ptes[i].status == PTE_INUSE) + writeq(0, &slots[i]); + else + ((u64 __force *)slots)[i] = 0; + /* Force sync around the address release. */ + mb(); + + /* release the address from the driver, */ + if (ptes[i].status == PTE_INUSE) { + if (ptes[i].dma_addr) { + dma_unmap_page(pg_tbl->device, ptes[i].dma_addr, + PAGE_SIZE, DMA_FROM_DEVICE); + } + if (gasket_release_page(ptes[i].page)) + --pg_tbl->num_active_pages; + } + ptes[i].status = PTE_FREE; + + /* and clear the PTE. */ + memset(&ptes[i], 0, sizeof(struct gasket_page_table_entry)); + } +} + +/* + * Unmap and release pages mapped to simple addresses. + * The page table mutex must be held by the caller. + */ +static void gasket_unmap_simple_pages( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + uint slot = gasket_simple_page_idx(pg_tbl, dev_addr); + + gasket_perform_unmapping(pg_tbl, pg_tbl->entries + slot, + pg_tbl->base_slot + slot, num_pages, 1); +} + +/* + * Unmap and release buffers to extended addresses. + * The page table mutex must be held by the caller. + */ +static void gasket_unmap_extended_pages( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + uint slot_idx, remain, len; + struct gasket_page_table_entry *pte; + u64 __iomem *slot_base; + + remain = num_pages; + slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); + pte = pg_tbl->entries + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + while (remain > 0) { + /* TODO: Add check to ensure pte remains valid? */ + len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx); + + if (pte->status == PTE_INUSE) { + slot_base = (u64 __iomem *)(page_address(pte->page) + + pte->offset); + gasket_perform_unmapping( + pg_tbl, pte->sublevel + slot_idx, + slot_base + slot_idx, len, 0); + } + + remain -= len; + slot_idx = 0; + pte++; + } +} + +/* Evaluates to nonzero if the specified virtual address is simple. */ +static inline bool gasket_addr_is_simple( + struct gasket_page_table *pg_tbl, ulong addr) +{ + return !((addr) & (pg_tbl)->extended_flag); +} + +/* + * Convert (simple, page, offset) into a device address. + * Examples: + * Simple page 0, offset 32: + * Input (0, 0, 32), Output 0x20 + * Simple page 1000, offset 511: + * Input (0, 1000, 512), Output 0x3E81FF + * Extended page 0, offset 32: + * Input (0, 0, 32), Output 0x8000000020 + * Extended page 1000, offset 511: + * Input (1, 1000, 512), Output 0x8003E81FF + */ +static ulong gasket_components_to_dev_address( + struct gasket_page_table *pg_tbl, int is_simple, uint page_index, + uint offset) +{ + ulong lvl0_index, lvl1_index; + + if (is_simple) { + /* Return simple addresses directly. */ + lvl0_index = page_index & (pg_tbl->config.total_entries - 1); + return (lvl0_index << GASKET_SIMPLE_PAGE_SHIFT) | offset; + } + + /* + * This could be compressed into fewer statements, but + * A) the compiler should optimize it + * B) this is not slow + * C) this is an uncommon operation + * D) this is actually readable this way. + */ + lvl0_index = page_index / GASKET_PAGES_PER_SUBTABLE; + lvl1_index = page_index & (GASKET_PAGES_PER_SUBTABLE - 1); + return (pg_tbl)->extended_flag | + (lvl0_index << GASKET_EXTENDED_LVL0_SHIFT) | + (lvl1_index << GASKET_EXTENDED_LVL1_SHIFT) | offset; +} + +/* + * Validity checking for simple addresses. + * + * Verify that address translation commutes (from address to/from page + offset) + * and that the requested page range starts and ends within the set of + * currently-partitioned simple pages. + */ +static bool gasket_is_simple_dev_addr_bad( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + ulong page_offset = dev_addr & (PAGE_SIZE - 1); + ulong page_index = + (dev_addr / PAGE_SIZE) & (pg_tbl->config.total_entries - 1); + + if (gasket_components_to_dev_address( + pg_tbl, 1, page_index, page_offset) != dev_addr) { + dev_err(pg_tbl->device, "address is invalid, 0x%lX\n", + dev_addr); + return true; + } + + if (page_index >= pg_tbl->num_simple_entries) { + dev_err(pg_tbl->device, + "starting slot at %lu is too large, max is < %u\n", + page_index, pg_tbl->num_simple_entries); + return true; + } + + if (page_index + num_pages > pg_tbl->num_simple_entries) { + dev_err(pg_tbl->device, + "ending slot at %lu is too large, max is <= %u\n", + page_index + num_pages, pg_tbl->num_simple_entries); + return true; + } + + return false; +} + +/* + * Validity checking for extended addresses. + * + * Verify that address translation commutes (from address to/from page + + * offset) and that the requested page range starts and ends within the set of + * currently-partitioned extended pages. + */ +static bool gasket_is_extended_dev_addr_bad( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + /* Starting byte index of dev_addr into the first mapped page */ + ulong page_offset = dev_addr & (PAGE_SIZE - 1); + ulong page_global_idx, page_lvl0_idx; + ulong num_lvl0_pages; + ulong addr; + + /* check if the device address is out of bound */ + addr = dev_addr & ~((pg_tbl)->extended_flag); + if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) { + dev_err(pg_tbl->device, "device address out of bounds: 0x%lx\n", + dev_addr); + return true; + } + + /* Find the starting sub-page index in the space of all sub-pages. */ + page_global_idx = (dev_addr / PAGE_SIZE) & + (pg_tbl->config.total_entries * GASKET_PAGES_PER_SUBTABLE - 1); + + /* Find the starting level 0 index. */ + page_lvl0_idx = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + /* Get the count of affected level 0 pages. */ + num_lvl0_pages = (num_pages + GASKET_PAGES_PER_SUBTABLE - 1) / + GASKET_PAGES_PER_SUBTABLE; + + if (gasket_components_to_dev_address( + pg_tbl, 0, page_global_idx, page_offset) != dev_addr) { + dev_err(pg_tbl->device, "address is invalid: 0x%lx\n", + dev_addr); + return true; + } + + if (page_lvl0_idx >= pg_tbl->num_extended_entries) { + dev_err(pg_tbl->device, + "starting level 0 slot at %lu is too large, max is < " + "%u\n", page_lvl0_idx, pg_tbl->num_extended_entries); + return true; + } + + if (page_lvl0_idx + num_lvl0_pages > pg_tbl->num_extended_entries) { + dev_err(pg_tbl->device, + "ending level 0 slot at %lu is too large, max is <= %u\n", + page_lvl0_idx + num_lvl0_pages, + pg_tbl->num_extended_entries); + return true; + } + + return false; +} + +/* + * Non-locking entry to unmapping routines. + * The page table mutex must be held by the caller. + */ +static void gasket_page_table_unmap_nolock( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +{ + if (!num_pages) + return; + + if (gasket_addr_is_simple(pg_tbl, dev_addr)) + gasket_unmap_simple_pages(pg_tbl, dev_addr, num_pages); + else + gasket_unmap_extended_pages(pg_tbl, dev_addr, num_pages); +} + +/* + * Allocate and map pages to simple addresses. + * If there is an error, no pages are mapped. + */ +static int gasket_map_simple_pages( + struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, + uint num_pages) +{ + int ret; + uint slot_idx = gasket_simple_page_idx(pg_tbl, dev_addr); + + ret = gasket_alloc_simple_entries(pg_tbl, dev_addr, num_pages); + if (ret) { + dev_err(pg_tbl->device, + "page table slots %u (@ 0x%lx) to %u are not available\n", + slot_idx, dev_addr, slot_idx + num_pages - 1); + return ret; + } + + ret = gasket_perform_mapping( + pg_tbl, pg_tbl->entries + slot_idx, + pg_tbl->base_slot + slot_idx, host_addr, num_pages, 1); + + if (ret) { + gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages); + dev_err(pg_tbl->device, "gasket_perform_mapping %d\n", ret); + } + return ret; +} + +/* + * Allocate a second level page table. + * The page table mutex must be held by the caller. + */ +static int gasket_alloc_extended_subtable( + struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, + u64 __iomem *slot) +{ + ulong page_addr, subtable_bytes; + dma_addr_t dma_addr; + + /* XXX FIX ME XXX this is inefficient for non-4K page sizes */ + + /* GFP_DMA flag must be passed to architectures for which + * part of the memory range is not considered DMA'able. + * This seems to be the case for Juno board with 4.5.0 Linaro kernel + */ + page_addr = get_zeroed_page(GFP_KERNEL | GFP_DMA); + if (!page_addr) + return -ENOMEM; + pte->page = virt_to_page((void *)page_addr); + pte->offset = 0; + + subtable_bytes = sizeof(struct gasket_page_table_entry) * + GASKET_PAGES_PER_SUBTABLE; + pte->sublevel = vzalloc(subtable_bytes); + if (!pte->sublevel) { + free_page(page_addr); + memset(pte, 0, sizeof(struct gasket_page_table_entry)); + return -ENOMEM; + } + + /* Map the page into DMA space. */ + pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); + /* Wait until the page is mapped. */ + mb(); + + /* make the addresses available to the device */ + dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG; + writeq(dma_addr, slot); + + pte->status = PTE_INUSE; + + return 0; +} + +/* + * Allocate slots in an extended page table. Check to see if a range of page + * table slots are available. If necessary, memory is allocated for second level + * page tables. + * + * Note that memory for second level page tables is allocated as needed, but + * that memory is only freed on the final close of the device file, when the + * page tables are repartitioned, or the the device is removed. If there is an + * error or if the full range of slots is not available, any memory + * allocated for second level page tables remains allocated until final close, + * repartition, or device removal. + * + * The page table mutex must be held by the caller. + */ +static int gasket_alloc_extended_entries( + struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries) +{ + int ret = 0; + uint remain, subtable_slot_idx, len; + struct gasket_page_table_entry *pte; + u64 __iomem *slot; + + remain = num_entries; + subtable_slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); + pte = pg_tbl->entries + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + slot = pg_tbl->base_slot + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + while (remain > 0) { + len = min(remain, + GASKET_PAGES_PER_SUBTABLE - subtable_slot_idx); + + if (pte->status == PTE_FREE) { + ret = gasket_alloc_extended_subtable(pg_tbl, pte, slot); + if (ret) { + dev_err(pg_tbl->device, + "no memory for extended addr subtable\n"); + return ret; + } + } else { + if (!gasket_is_pte_range_free( + pte->sublevel + subtable_slot_idx, len)) + return -EBUSY; + } + + remain -= len; + subtable_slot_idx = 0; + pte++; + slot++; + } + + return 0; +} + +/* + * gasket_map_extended_pages - Get and map buffers to extended addresses. + * If there is an error, no pages are mapped. + */ +static int gasket_map_extended_pages( + struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, + uint num_pages) +{ + int ret; + ulong dev_addr_end; + uint slot_idx, remain, len; + struct gasket_page_table_entry *pte; + u64 __iomem *slot_base; + + ret = gasket_alloc_extended_entries(pg_tbl, dev_addr, num_pages); + if (ret) { + dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1; + dev_err(pg_tbl->device, + "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are " + "not available\n", + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr), + dev_addr, + gasket_extended_lvl1_page_idx(pg_tbl, dev_addr), + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr_end), + gasket_extended_lvl1_page_idx(pg_tbl, dev_addr_end)); + return ret; + } + + remain = num_pages; + slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); + pte = pg_tbl->entries + pg_tbl->num_simple_entries + + gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); + + while (remain > 0) { + len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx); + + slot_base = + (u64 __iomem *)(page_address(pte->page) + pte->offset); + ret = gasket_perform_mapping( + pg_tbl, pte->sublevel + slot_idx, slot_base + slot_idx, + host_addr, len, 0); + if (ret) { + gasket_page_table_unmap_nolock( + pg_tbl, dev_addr, num_pages); + return ret; + } + + remain -= len; + slot_idx = 0; + pte++; + host_addr += len * PAGE_SIZE; + } + + return 0; +} + /* * See gasket_page_table.h for general description. * @@ -489,14 +1107,6 @@ void gasket_page_table_reset(struct gasket_page_table *pg_tbl) mutex_unlock(&pg_tbl->mutex); } -/* See gasket_page_table.h for description. */ -void gasket_page_table_garbage_collect(struct gasket_page_table *pg_tbl) -{ - mutex_lock(&pg_tbl->mutex); - gasket_page_table_garbage_collect_nolock(pg_tbl); - mutex_unlock(&pg_tbl->mutex); -} - /* See gasket_page_table.h for description. */ int gasket_page_table_lookup_page( struct gasket_page_table *pg_tbl, ulong dev_addr, struct page **ppage, @@ -635,681 +1245,6 @@ int gasket_page_table_system_status(struct gasket_page_table *page_table) return GASKET_STATUS_ALIVE; } -/* - * Allocate and map pages to simple addresses. - * If there is an error, no pages are mapped. - */ -static int gasket_map_simple_pages( - struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, - uint num_pages) -{ - int ret; - uint slot_idx = gasket_simple_page_idx(pg_tbl, dev_addr); - - ret = gasket_alloc_simple_entries(pg_tbl, dev_addr, num_pages); - if (ret) { - dev_err(pg_tbl->device, - "page table slots %u (@ 0x%lx) to %u are not available\n", - slot_idx, dev_addr, slot_idx + num_pages - 1); - return ret; - } - - ret = gasket_perform_mapping( - pg_tbl, pg_tbl->entries + slot_idx, - pg_tbl->base_slot + slot_idx, host_addr, num_pages, 1); - - if (ret) { - gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages); - dev_err(pg_tbl->device, "gasket_perform_mapping %d\n", ret); - } - return ret; -} - -/* - * gasket_map_extended_pages - Get and map buffers to extended addresses. - * If there is an error, no pages are mapped. - */ -static int gasket_map_extended_pages( - struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, - uint num_pages) -{ - int ret; - ulong dev_addr_end; - uint slot_idx, remain, len; - struct gasket_page_table_entry *pte; - u64 __iomem *slot_base; - - ret = gasket_alloc_extended_entries(pg_tbl, dev_addr, num_pages); - if (ret) { - dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1; - dev_err(pg_tbl->device, - "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are " - "not available\n", - gasket_extended_lvl0_page_idx(pg_tbl, dev_addr), - dev_addr, - gasket_extended_lvl1_page_idx(pg_tbl, dev_addr), - gasket_extended_lvl0_page_idx(pg_tbl, dev_addr_end), - gasket_extended_lvl1_page_idx(pg_tbl, dev_addr_end)); - return ret; - } - - remain = num_pages; - slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); - pte = pg_tbl->entries + pg_tbl->num_simple_entries + - gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); - - while (remain > 0) { - len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx); - - slot_base = - (u64 __iomem *)(page_address(pte->page) + pte->offset); - ret = gasket_perform_mapping( - pg_tbl, pte->sublevel + slot_idx, slot_base + slot_idx, - host_addr, len, 0); - if (ret) { - gasket_page_table_unmap_nolock( - pg_tbl, dev_addr, num_pages); - return ret; - } - - remain -= len; - slot_idx = 0; - pte++; - host_addr += len * PAGE_SIZE; - } - - return 0; -} - -/* - * Get and map last level page table buffers. - * - * slots is the location(s) to write device-mapped page address. If this is a - * simple mapping, these will be address translation registers. If this is - * an extended mapping, these will be within a second-level page table - * allocated by the host and so must have their __iomem attribute casted away. - */ -static int gasket_perform_mapping( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, - u64 __iomem *slots, ulong host_addr, uint num_pages, - int is_simple_mapping) -{ - int ret; - ulong offset; - struct page *page; - dma_addr_t dma_addr; - ulong page_addr; - int i; - - for (i = 0; i < num_pages; i++) { - page_addr = host_addr + i * PAGE_SIZE; - offset = page_addr & (PAGE_SIZE - 1); - dev_dbg(pg_tbl->device, "%s i %d\n", __func__, i); - if (is_coherent(pg_tbl, host_addr)) { - u64 off = - (u64)host_addr - - (u64)pg_tbl->coherent_pages[0].user_virt; - ptes[i].page = NULL; - ptes[i].offset = offset; - ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + - off + i * PAGE_SIZE; - } else { - ret = get_user_pages_fast( - page_addr - offset, 1, 1, &page); - - if (ret <= 0) { - dev_err(pg_tbl->device, - "get user pages failed for addr=0x%lx, " - "offset=0x%lx [ret=%d]\n", - page_addr, offset, ret); - return ret ? ret : -ENOMEM; - } - ++pg_tbl->num_active_pages; - - ptes[i].page = page; - ptes[i].offset = offset; - - /* Map the page into DMA space. */ - ptes[i].dma_addr = - dma_map_page(pg_tbl->device, page, 0, PAGE_SIZE, - DMA_BIDIRECTIONAL); - dev_dbg(pg_tbl->device, - "%s i %d pte %p pfn %p -> mapped %llx\n", - __func__, i, &ptes[i], - (void *)page_to_pfn(page), - (unsigned long long)ptes[i].dma_addr); - - if (ptes[i].dma_addr == -1) { - dev_dbg(pg_tbl->device, - "%s i %d -> fail to map page %llx " - "[pfn %p ohys %p]\n", - __func__, i, - (unsigned long long)ptes[i].dma_addr, - (void *)page_to_pfn(page), - (void *)page_to_phys(page)); - return -1; - } - /* Wait until the page is mapped. */ - mb(); - } - - /* Make the DMA-space address available to the device. */ - dma_addr = (ptes[i].dma_addr + offset) | GASKET_VALID_SLOT_FLAG; - - if (is_simple_mapping) { - writeq(dma_addr, &slots[i]); - } else { - ((u64 __force *)slots)[i] = dma_addr; - /* Extended page table vectors are in DRAM, - * and so need to be synced each time they are updated. - */ - dma_map_single(pg_tbl->device, - (void *)&((u64 __force *)slots)[i], - sizeof(u64), DMA_TO_DEVICE); - } - ptes[i].status = PTE_INUSE; - } - return 0; -} - -/* - * Allocate page table entries in a simple table. - * The page table mutex must be held by the caller. - */ -static int gasket_alloc_simple_entries( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) -{ - if (!gasket_is_pte_range_free( - pg_tbl->entries + gasket_simple_page_idx(pg_tbl, dev_addr), - num_pages)) - return -EBUSY; - - return 0; -} - -/* - * Allocate slots in an extended page table. Check to see if a range of page - * table slots are available. If necessary, memory is allocated for second level - * page tables. - * - * Note that memory for second level page tables is allocated as needed, but - * that memory is only freed on the final close of the device file, when the - * page tables are repartitioned, or the the device is removed. If there is an - * error or if the full range of slots is not available, any memory - * allocated for second level page tables remains allocated until final close, - * repartition, or device removal. - * - * The page table mutex must be held by the caller. - */ -static int gasket_alloc_extended_entries( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries) -{ - int ret = 0; - uint remain, subtable_slot_idx, len; - struct gasket_page_table_entry *pte; - u64 __iomem *slot; - - remain = num_entries; - subtable_slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); - pte = pg_tbl->entries + pg_tbl->num_simple_entries + - gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); - slot = pg_tbl->base_slot + pg_tbl->num_simple_entries + - gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); - - while (remain > 0) { - len = min(remain, - GASKET_PAGES_PER_SUBTABLE - subtable_slot_idx); - - if (pte->status == PTE_FREE) { - ret = gasket_alloc_extended_subtable(pg_tbl, pte, slot); - if (ret) { - dev_err(pg_tbl->device, - "no memory for extended addr subtable\n"); - return ret; - } - } else { - if (!gasket_is_pte_range_free( - pte->sublevel + subtable_slot_idx, len)) - return -EBUSY; - } - - remain -= len; - subtable_slot_idx = 0; - pte++; - slot++; - } - - return 0; -} - -/* - * Allocate a second level page table. - * The page table mutex must be held by the caller. - */ -static int gasket_alloc_extended_subtable( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, - u64 __iomem *slot) -{ - ulong page_addr, subtable_bytes; - dma_addr_t dma_addr; - - /* XXX FIX ME XXX this is inefficient for non-4K page sizes */ - - /* GFP_DMA flag must be passed to architectures for which - * part of the memory range is not considered DMA'able. - * This seems to be the case for Juno board with 4.5.0 Linaro kernel - */ - page_addr = get_zeroed_page(GFP_KERNEL | GFP_DMA); - if (!page_addr) - return -ENOMEM; - pte->page = virt_to_page((void *)page_addr); - pte->offset = 0; - - subtable_bytes = sizeof(struct gasket_page_table_entry) * - GASKET_PAGES_PER_SUBTABLE; - pte->sublevel = vzalloc(subtable_bytes); - if (!pte->sublevel) { - free_page(page_addr); - memset(pte, 0, sizeof(struct gasket_page_table_entry)); - return -ENOMEM; - } - - /* Map the page into DMA space. */ - pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE, - DMA_BIDIRECTIONAL); - /* Wait until the page is mapped. */ - mb(); - - /* make the addresses available to the device */ - dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG; - writeq(dma_addr, slot); - - pte->status = PTE_INUSE; - - return 0; -} - -/* - * Non-locking entry to unmapping routines. - * The page table mutex must be held by the caller. - */ -static void gasket_page_table_unmap_nolock( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) -{ - if (!num_pages) - return; - - if (gasket_addr_is_simple(pg_tbl, dev_addr)) - gasket_unmap_simple_pages(pg_tbl, dev_addr, num_pages); - else - gasket_unmap_extended_pages(pg_tbl, dev_addr, num_pages); -} - -/* - * Unmap and release pages mapped to simple addresses. - * The page table mutex must be held by the caller. - */ -static void gasket_unmap_simple_pages( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) -{ - uint slot = gasket_simple_page_idx(pg_tbl, dev_addr); - - gasket_perform_unmapping(pg_tbl, pg_tbl->entries + slot, - pg_tbl->base_slot + slot, num_pages, 1); -} - -/* - * Unmap and release buffers to extended addresses. - * The page table mutex must be held by the caller. - */ -static void gasket_unmap_extended_pages( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) -{ - uint slot_idx, remain, len; - struct gasket_page_table_entry *pte; - u64 __iomem *slot_base; - - remain = num_pages; - slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr); - pte = pg_tbl->entries + pg_tbl->num_simple_entries + - gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); - - while (remain > 0) { - /* TODO: Add check to ensure pte remains valid? */ - len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx); - - if (pte->status == PTE_INUSE) { - slot_base = (u64 __iomem *)(page_address(pte->page) + - pte->offset); - gasket_perform_unmapping( - pg_tbl, pte->sublevel + slot_idx, - slot_base + slot_idx, len, 0); - } - - remain -= len; - slot_idx = 0; - pte++; - } -} - -/* - * Unmap and release mapped pages. - * The page table mutex must be held by the caller. - */ -static void gasket_perform_unmapping( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, - u64 __iomem *slots, uint num_pages, int is_simple_mapping) -{ - int i; - /* - * For each page table entry and corresponding entry in the device's - * address translation table: - */ - for (i = 0; i < num_pages; i++) { - /* release the address from the device, */ - if (is_simple_mapping || ptes[i].status == PTE_INUSE) - writeq(0, &slots[i]); - else - ((u64 __force *)slots)[i] = 0; - /* Force sync around the address release. */ - mb(); - - /* release the address from the driver, */ - if (ptes[i].status == PTE_INUSE) { - if (ptes[i].dma_addr) { - dma_unmap_page(pg_tbl->device, ptes[i].dma_addr, - PAGE_SIZE, DMA_FROM_DEVICE); - } - if (gasket_release_page(ptes[i].page)) - --pg_tbl->num_active_pages; - } - ptes[i].status = PTE_FREE; - - /* and clear the PTE. */ - memset(&ptes[i], 0, sizeof(struct gasket_page_table_entry)); - } -} - -/* - * Free a second level page [sub]table. - * The page table mutex must be held before this call. - */ -static void gasket_free_extended_subtable( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, - u64 __iomem *slot) -{ - /* Release the page table from the driver */ - pte->status = PTE_FREE; - - /* Release the page table from the device */ - writeq(0, slot); - /* Force sync around the address release. */ - mb(); - - if (pte->dma_addr) - dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE, - DMA_BIDIRECTIONAL); - - vfree(pte->sublevel); - - if (pte->page) - free_page((ulong)page_address(pte->page)); - - memset(pte, 0, sizeof(struct gasket_page_table_entry)); -} - -/* Safely return a page to the OS. */ -static bool gasket_release_page(struct page *page) -{ - if (!page) - return false; - - if (!PageReserved(page)) - SetPageDirty(page); - put_page(page); - - return true; -} - -/* Evaluates to nonzero if the specified virtual address is simple. */ -static inline bool gasket_addr_is_simple( - struct gasket_page_table *pg_tbl, ulong addr) -{ - return !((addr) & (pg_tbl)->extended_flag); -} - -/* - * Validity checking for simple addresses. - * - * Verify that address translation commutes (from address to/from page + offset) - * and that the requested page range starts and ends within the set of - * currently-partitioned simple pages. - */ -static bool gasket_is_simple_dev_addr_bad( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) -{ - ulong page_offset = dev_addr & (PAGE_SIZE - 1); - ulong page_index = - (dev_addr / PAGE_SIZE) & (pg_tbl->config.total_entries - 1); - - if (gasket_components_to_dev_address( - pg_tbl, 1, page_index, page_offset) != dev_addr) { - dev_err(pg_tbl->device, "address is invalid, 0x%lX\n", - dev_addr); - return true; - } - - if (page_index >= pg_tbl->num_simple_entries) { - dev_err(pg_tbl->device, - "starting slot at %lu is too large, max is < %u\n", - page_index, pg_tbl->num_simple_entries); - return true; - } - - if (page_index + num_pages > pg_tbl->num_simple_entries) { - dev_err(pg_tbl->device, - "ending slot at %lu is too large, max is <= %u\n", - page_index + num_pages, pg_tbl->num_simple_entries); - return true; - } - - return false; -} - -/* - * Validity checking for extended addresses. - * - * Verify that address translation commutes (from address to/from page + - * offset) and that the requested page range starts and ends within the set of - * currently-partitioned extended pages. - */ -static bool gasket_is_extended_dev_addr_bad( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) -{ - /* Starting byte index of dev_addr into the first mapped page */ - ulong page_offset = dev_addr & (PAGE_SIZE - 1); - ulong page_global_idx, page_lvl0_idx; - ulong num_lvl0_pages; - ulong addr; - - /* check if the device address is out of bound */ - addr = dev_addr & ~((pg_tbl)->extended_flag); - if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) { - dev_err(pg_tbl->device, "device address out of bounds: 0x%lx\n", - dev_addr); - return true; - } - - /* Find the starting sub-page index in the space of all sub-pages. */ - page_global_idx = (dev_addr / PAGE_SIZE) & - (pg_tbl->config.total_entries * GASKET_PAGES_PER_SUBTABLE - 1); - - /* Find the starting level 0 index. */ - page_lvl0_idx = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr); - - /* Get the count of affected level 0 pages. */ - num_lvl0_pages = (num_pages + GASKET_PAGES_PER_SUBTABLE - 1) / - GASKET_PAGES_PER_SUBTABLE; - - if (gasket_components_to_dev_address( - pg_tbl, 0, page_global_idx, page_offset) != dev_addr) { - dev_err(pg_tbl->device, "address is invalid: 0x%lx\n", - dev_addr); - return true; - } - - if (page_lvl0_idx >= pg_tbl->num_extended_entries) { - dev_err(pg_tbl->device, - "starting level 0 slot at %lu is too large, max is < " - "%u\n", page_lvl0_idx, pg_tbl->num_extended_entries); - return true; - } - - if (page_lvl0_idx + num_lvl0_pages > pg_tbl->num_extended_entries) { - dev_err(pg_tbl->device, - "ending level 0 slot at %lu is too large, max is <= %u\n", - page_lvl0_idx + num_lvl0_pages, - pg_tbl->num_extended_entries); - return true; - } - - return false; -} - -/* - * Check if a range of PTEs is free. - * The page table mutex must be held by the caller. - */ -static bool gasket_is_pte_range_free( - struct gasket_page_table_entry *ptes, uint num_entries) -{ - int i; - - for (i = 0; i < num_entries; i++) { - if (ptes[i].status != PTE_FREE) - return false; - } - - return true; -} - -/* - * Actually perform collection. - * The page table mutex must be held by the caller. - */ -static void gasket_page_table_garbage_collect_nolock( - struct gasket_page_table *pg_tbl) -{ - struct gasket_page_table_entry *pte; - u64 __iomem *slot; - - /* XXX FIX ME XXX -- more efficient to keep a usage count */ - /* rather than scanning the second level page tables */ - - for (pte = pg_tbl->entries + pg_tbl->num_simple_entries, - slot = pg_tbl->base_slot + pg_tbl->num_simple_entries; - pte < pg_tbl->entries + pg_tbl->config.total_entries; - pte++, slot++) { - if (pte->status == PTE_INUSE) { - if (gasket_is_pte_range_free( - pte->sublevel, GASKET_PAGES_PER_SUBTABLE)) - gasket_free_extended_subtable( - pg_tbl, pte, slot); - } - } -} - -/* - * Convert (simple, page, offset) into a device address. - * Examples: - * Simple page 0, offset 32: - * Input (0, 0, 32), Output 0x20 - * Simple page 1000, offset 511: - * Input (0, 1000, 512), Output 0x3E81FF - * Extended page 0, offset 32: - * Input (0, 0, 32), Output 0x8000000020 - * Extended page 1000, offset 511: - * Input (1, 1000, 512), Output 0x8003E81FF - */ -static ulong gasket_components_to_dev_address( - struct gasket_page_table *pg_tbl, int is_simple, uint page_index, - uint offset) -{ - ulong lvl0_index, lvl1_index; - - if (is_simple) { - /* Return simple addresses directly. */ - lvl0_index = page_index & (pg_tbl->config.total_entries - 1); - return (lvl0_index << GASKET_SIMPLE_PAGE_SHIFT) | offset; - } - - /* - * This could be compressed into fewer statements, but - * A) the compiler should optimize it - * B) this is not slow - * C) this is an uncommon operation - * D) this is actually readable this way. - */ - lvl0_index = page_index / GASKET_PAGES_PER_SUBTABLE; - lvl1_index = page_index & (GASKET_PAGES_PER_SUBTABLE - 1); - return (pg_tbl)->extended_flag | - (lvl0_index << GASKET_EXTENDED_LVL0_SHIFT) | - (lvl1_index << GASKET_EXTENDED_LVL1_SHIFT) | offset; -} - -/* - * Return the index of the page for the address in the simple table. - * Does not perform validity checking. - */ -static int gasket_simple_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr) -{ - return (dev_addr >> GASKET_SIMPLE_PAGE_SHIFT) & - (pg_tbl->config.total_entries - 1); -} - -/* - * Return the level 0 page index for the given address. - * Does not perform validity checking. - */ -static ulong gasket_extended_lvl0_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr) -{ - return (dev_addr >> GASKET_EXTENDED_LVL0_SHIFT) & - ((1 << GASKET_EXTENDED_LVL0_WIDTH) - 1); -} - -/* - * Return the level 1 page index for the given address. - * Does not perform validity checking. - */ -static ulong gasket_extended_lvl1_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr) -{ - return (dev_addr >> GASKET_EXTENDED_LVL1_SHIFT) & - (GASKET_PAGES_PER_SUBTABLE - 1); -} - -/* - * Return whether a host buffer was mapped as coherent memory. - * - * A Gasket page_table currently support one contiguous dma range, mapped to one - * contiguous virtual memory range. Check if the host_addr is within that range. - */ -static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr) -{ - u64 min, max; - - /* whether the host address is within user virt range */ - if (!pg_tbl->coherent_pages) - return 0; - - min = (u64)pg_tbl->coherent_pages[0].user_virt; - max = min + PAGE_SIZE * pg_tbl->num_coherent_pages; - - return min <= host_addr && host_addr < max; -} - /* Record the host_addr to coherent dma memory mapping. */ int gasket_set_user_virt( struct gasket_dev *gasket_dev, u64 size, dma_addr_t dma_address, From 6d2bd645cbae8feb252510bae627bb2e8d9e3286 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:38 -0700 Subject: [PATCH 754/903] staging: gasket: TODO: remove entry for static function declarations The static function declarations are removed, remove the TODO file entry for this. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO index 7f4c13ce021b..6aa2a7f6bc4b 100644 --- a/drivers/staging/gasket/TODO +++ b/drivers/staging/gasket/TODO @@ -1,6 +1,5 @@ This is a list of things that need to be done to get this driver out of the staging directory. -- Remove static function declarations. - Document sysfs files with Documentation/ABI/ entries. - Use misc interface instead of major number for driver version description. - Add descriptions of module_param's From 88c8a377c00ff3a69bf5a4abfdf6fc5f041089e1 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:39 -0700 Subject: [PATCH 755/903] staging: gasket: core: fix function param line continuation style Fix multi-line alignment formatting to look like: int ret = long_function_name(device, VARIABLE1, VARIABLE2, VARIABLE3, VARIABLE4); Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 294 +++++++++++++-------------- drivers/staging/gasket/gasket_core.h | 68 +++---- 2 files changed, 179 insertions(+), 183 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index b5a7254fbfb3..44344528cd88 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -103,8 +103,9 @@ enum gasket_sysfs_attribute_type { }; /* Perform a standard Gasket callback. */ -static inline int check_and_invoke_callback( - struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) +static inline int +check_and_invoke_callback(struct gasket_dev *gasket_dev, + int (*cb_function)(struct gasket_dev *)) { int ret = 0; @@ -119,8 +120,9 @@ static inline int check_and_invoke_callback( } /* Perform a standard Gasket callback without grabbing gasket_dev->mutex. */ -static inline int gasket_check_and_invoke_callback_nolock( - struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) +static inline int +gasket_check_and_invoke_callback_nolock(struct gasket_dev *gasket_dev, + int (*cb_function)(struct gasket_dev *)) { int ret = 0; @@ -147,8 +149,8 @@ static int gasket_owned_by_current_tgid(struct gasket_cdev_info *info) * * Returns the located slot number on success or a negative number on failure. */ -static int gasket_find_dev_slot( - struct gasket_internal_desc *internal_desc, const char *kobj_name) +static int gasket_find_dev_slot(struct gasket_internal_desc *internal_desc, + const char *kobj_name) { int i; @@ -186,9 +188,9 @@ static int gasket_find_dev_slot( * * Returns 0 if successful, a negative error code otherwise. */ -static int gasket_alloc_dev( - struct gasket_internal_desc *internal_desc, struct device *parent, - struct gasket_dev **pdev, const char *kobj_name) +static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc, + struct device *parent, struct gasket_dev **pdev, + const char *kobj_name) { int dev_idx; const struct gasket_driver_desc *driver_desc = @@ -228,7 +230,7 @@ static int gasket_alloc_dev( gasket_dev->dev_idx); dev_info->devt = MKDEV(driver_desc->major, driver_desc->minor + - gasket_dev->dev_idx); + gasket_dev->dev_idx); dev_info->device = device_create(internal_desc->class, parent, dev_info->devt, gasket_dev, dev_info->name); @@ -371,8 +373,8 @@ static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num) * * Returns 0 on success and a negative value otherwise. */ -static int gasket_setup_pci( - struct pci_dev *pci_dev, struct gasket_dev *gasket_dev) +static int gasket_setup_pci(struct pci_dev *pci_dev, + struct gasket_dev *gasket_dev) { int i, mapped_bars, ret; @@ -421,8 +423,8 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) const struct gasket_driver_desc *driver_desc = gasket_dev->internal_desc->driver_desc; - status = gasket_check_and_invoke_callback_nolock( - gasket_dev, driver_desc->device_status_cb); + status = gasket_check_and_invoke_callback_nolock(gasket_dev, + driver_desc->device_status_cb); if (status != GASKET_STATUS_ALIVE) { dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n", status); @@ -437,8 +439,7 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) } for (i = 0; i < driver_desc->num_page_tables; ++i) { - status = gasket_page_table_system_status( - gasket_dev->page_table[i]); + status = gasket_page_table_system_status(gasket_dev->page_table[i]); if (status != GASKET_STATUS_ALIVE) { dev_dbg(gasket_dev->dev, "Page table %d reported status %d.\n", @@ -450,8 +451,10 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev) return GASKET_STATUS_ALIVE; } -static ssize_t gasket_write_mappable_regions( - char *buf, const struct gasket_driver_desc *driver_desc, int bar_index) +static ssize_t +gasket_write_mappable_regions(char *buf, + const struct gasket_driver_desc *driver_desc, + int bar_index) { int i; ssize_t written; @@ -478,8 +481,8 @@ static ssize_t gasket_write_mappable_regions( return total_written; } -static ssize_t gasket_sysfs_data_show( - struct device *device, struct device_attribute *attr, char *buf) +static ssize_t gasket_sysfs_data_show(struct device *device, + struct device_attribute *attr, char *buf) { int i, ret = 0; ssize_t current_written = 0; @@ -532,54 +535,49 @@ static ssize_t gasket_sysfs_data_show( } break; case ATTR_DRIVER_VERSION: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", - gasket_dev->internal_desc->driver_desc->driver_version); + ret = snprintf(buf, PAGE_SIZE, "%s\n", + gasket_dev->internal_desc->driver_desc->driver_version); break; case ATTR_FRAMEWORK_VERSION: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", GASKET_FRAMEWORK_VERSION); + ret = snprintf(buf, PAGE_SIZE, "%s\n", + GASKET_FRAMEWORK_VERSION); break; case ATTR_DEVICE_TYPE: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", - gasket_dev->internal_desc->driver_desc->name); + ret = snprintf(buf, PAGE_SIZE, "%s\n", + gasket_dev->internal_desc->driver_desc->name); break; case ATTR_HARDWARE_REVISION: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", gasket_dev->hardware_revision); + ret = snprintf(buf, PAGE_SIZE, "%d\n", + gasket_dev->hardware_revision); break; case ATTR_PCI_ADDRESS: ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name); break; case ATTR_STATUS: - ret = snprintf( - buf, PAGE_SIZE, "%s\n", - gasket_num_name_lookup( - gasket_dev->status, gasket_status_name_table)); + ret = snprintf(buf, PAGE_SIZE, "%s\n", + gasket_num_name_lookup(gasket_dev->status, + gasket_status_name_table)); break; case ATTR_IS_DEVICE_OWNED: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", - gasket_dev->dev_info.ownership.is_owned); + ret = snprintf(buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.is_owned); break; case ATTR_DEVICE_OWNER: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", - gasket_dev->dev_info.ownership.owner); + ret = snprintf(buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.owner); break; case ATTR_WRITE_OPEN_COUNT: - ret = snprintf( - buf, PAGE_SIZE, "%d\n", - gasket_dev->dev_info.ownership.write_open_count); + ret = snprintf(buf, PAGE_SIZE, "%d\n", + gasket_dev->dev_info.ownership.write_open_count); break; case ATTR_RESET_COUNT: ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count); break; case ATTR_USER_MEM_RANGES: for (i = 0; i < GASKET_NUM_BARS; ++i) { - current_written = gasket_write_mappable_regions( - buf, driver_desc, i); + current_written = + gasket_write_mappable_regions(buf, driver_desc, + i); buf += current_written; ret += current_written; } @@ -622,9 +620,9 @@ static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = { }; /* Add a char device and related info. */ -static int gasket_add_cdev( - struct gasket_cdev_info *dev_info, - const struct file_operations *file_ops, struct module *owner) +static int gasket_add_cdev(struct gasket_cdev_info *dev_info, + const struct file_operations *file_ops, + struct module *owner) { int ret; @@ -672,8 +670,8 @@ static void gasket_disable_dev(struct gasket_dev *gasket_dev) * Precondition: Called with g_mutex held (to avoid a race on return). * Returns NULL if no matching device was found. */ -static struct gasket_internal_desc *lookup_internal_desc( - struct pci_dev *pci_dev) +static struct gasket_internal_desc * +lookup_internal_desc(struct pci_dev *pci_dev) { int i; @@ -693,9 +691,9 @@ static struct gasket_internal_desc *lookup_internal_desc( * that the provided descriptor/range is of adequate size to hold the range to * be mapped. */ -static bool gasket_mmap_has_permissions( - struct gasket_dev *gasket_dev, struct vm_area_struct *vma, - int bar_permissions) +static bool gasket_mmap_has_permissions(struct gasket_dev *gasket_dev, + struct vm_area_struct *vma, + int bar_permissions) { int requested_permissions; /* Always allow sysadmin to access. */ @@ -735,8 +733,9 @@ static bool gasket_mmap_has_permissions( * Verifies that the input address is within the region allocated to coherent * buffer. */ -static bool gasket_is_coherent_region( - const struct gasket_driver_desc *driver_desc, ulong address) +static bool +gasket_is_coherent_region(const struct gasket_driver_desc *driver_desc, + ulong address) { struct gasket_coherent_buffer_desc coh_buff_desc = driver_desc->coherent_buffer_description; @@ -750,8 +749,8 @@ static bool gasket_is_coherent_region( return false; } -static int gasket_get_bar_index( - const struct gasket_dev *gasket_dev, ulong phys_addr) +static int gasket_get_bar_index(const struct gasket_dev *gasket_dev, + ulong phys_addr) { int i; const struct gasket_driver_desc *driver_desc; @@ -786,10 +785,11 @@ static int gasket_get_bar_index( * * Returns true if there's anything to map, and false otherwise. */ -static bool gasket_mm_get_mapping_addrs( - const struct gasket_mappable_region *region, ulong bar_offset, - ulong requested_length, struct gasket_mappable_region *mappable_region, - ulong *virt_offset) +static bool +gasket_mm_get_mapping_addrs(const struct gasket_mappable_region *region, + ulong bar_offset, ulong requested_length, + struct gasket_mappable_region *mappable_region, + ulong *virt_offset) { ulong range_start = region->start; ulong range_length = region->length_bytes; @@ -835,8 +835,8 @@ static bool gasket_mm_get_mapping_addrs( */ mappable_region->start = bar_offset; *virt_offset = 0; - mappable_region->length_bytes = min( - requested_length, range_end - bar_offset); + mappable_region->length_bytes = + min(requested_length, range_end - bar_offset); return true; } @@ -852,9 +852,9 @@ static bool gasket_mm_get_mapping_addrs( * The offset is written into bar_offset on success. * Returns zero on success, anything else on error. */ -static int gasket_mm_vma_bar_offset( - const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, - ulong *bar_offset) +static int gasket_mm_vma_bar_offset(const struct gasket_dev *gasket_dev, + const struct vm_area_struct *vma, + ulong *bar_offset) { ulong raw_offset; int bar_index; @@ -877,9 +877,9 @@ static int gasket_mm_vma_bar_offset( return 0; } -int gasket_mm_unmap_region( - const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, - const struct gasket_mappable_region *map_region) +int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev, + struct vm_area_struct *vma, + const struct gasket_mappable_region *map_region) { ulong bar_offset; ulong virt_offset; @@ -893,9 +893,9 @@ int gasket_mm_unmap_region( if (ret) return ret; - if (!gasket_mm_get_mapping_addrs( - map_region, bar_offset, vma->vm_end - vma->vm_start, - &mappable_region, &virt_offset)) + if (!gasket_mm_get_mapping_addrs(map_region, bar_offset, + vma->vm_end - vma->vm_start, + &mappable_region, &virt_offset)) return 1; /* @@ -904,18 +904,17 @@ int gasket_mm_unmap_region( * * Next multiple of y: ceil_div(x, y) * y */ - zap_vma_ptes( - vma, vma->vm_start + virt_offset, - DIV_ROUND_UP(mappable_region.length_bytes, PAGE_SIZE) * - PAGE_SIZE); + zap_vma_ptes(vma, vma->vm_start + virt_offset, + DIV_ROUND_UP(mappable_region.length_bytes, PAGE_SIZE) * + PAGE_SIZE); return 0; } EXPORT_SYMBOL(gasket_mm_unmap_region); /* Maps a virtual address + range to a physical offset of a BAR. */ -static enum do_map_region_status do_map_region( - const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, - struct gasket_mappable_region *mappable_region) +static enum do_map_region_status +do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, + struct gasket_mappable_region *mappable_region) { /* Maximum size of a single call to io_remap_pfn_range. */ /* I pulled this number out of thin air. */ @@ -944,10 +943,9 @@ static enum do_map_region_status do_map_region( virt_base = vma->vm_start + virt_offset; bar_index = - gasket_get_bar_index( - gasket_dev, - (vma->vm_pgoff << PAGE_SHIFT) + - driver_desc->legacy_mmap_address_offset); + gasket_get_bar_index(gasket_dev, + (vma->vm_pgoff << PAGE_SHIFT) + + driver_desc->legacy_mmap_address_offset); phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset; while (mapped_bytes < map_length) { /* @@ -957,10 +955,10 @@ static enum do_map_region_status do_map_region( chunk_size = min(max_chunk_size, map_length - mapped_bytes); cond_resched(); - ret = io_remap_pfn_range( - vma, virt_base + mapped_bytes, - (phys_base + mapped_bytes) >> PAGE_SHIFT, - chunk_size, vma->vm_page_prot); + ret = io_remap_pfn_range(vma, virt_base + mapped_bytes, + (phys_base + mapped_bytes) >> + PAGE_SHIFT, chunk_size, + vma->vm_page_prot); if (ret) { dev_err(gasket_dev->dev, "Error remapping PFN range.\n"); @@ -984,8 +982,8 @@ fail: } /* Map a region of coherent memory. */ -static int gasket_mmap_coherent( - struct gasket_dev *gasket_dev, struct vm_area_struct *vma) +static int gasket_mmap_coherent(struct gasket_dev *gasket_dev, + struct vm_area_struct *vma) { const struct gasket_driver_desc *driver_desc = gasket_dev->internal_desc->driver_desc; @@ -1008,10 +1006,9 @@ static int gasket_mmap_coherent( vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - ret = remap_pfn_range( - vma, vma->vm_start, - (gasket_dev->coherent_buffer.phys_base) >> PAGE_SHIFT, - requested_length, vma->vm_page_prot); + ret = remap_pfn_range(vma, vma->vm_start, + (gasket_dev->coherent_buffer.phys_base) >> + PAGE_SHIFT, requested_length, vma->vm_page_prot); if (ret) { dev_err(gasket_dev->dev, "Error remapping PFN range err=%d.\n", ret); @@ -1022,9 +1019,9 @@ static int gasket_mmap_coherent( /* Record the user virtual to dma_address mapping that was * created by the kernel. */ - gasket_set_user_virt( - gasket_dev, requested_length, - gasket_dev->coherent_buffer.phys_base, vma->vm_start); + gasket_set_user_virt(gasket_dev, requested_length, + gasket_dev->coherent_buffer.phys_base, + vma->vm_start); return 0; } @@ -1058,8 +1055,8 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) raw_offset = (vma->vm_pgoff << PAGE_SHIFT) + driver_desc->legacy_mmap_address_offset; vma_size = vma->vm_end - vma->vm_start; - trace_gasket_mmap_entry( - gasket_dev->dev_info.name, raw_offset, vma_size); + trace_gasket_mmap_entry(gasket_dev->dev_info.name, raw_offset, + vma_size); /* * Check if the raw offset is within a bar region. If not, check if it @@ -1103,8 +1100,10 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) } if (driver_desc->get_mappable_regions_cb) { - ret = driver_desc->get_mappable_regions_cb( - gasket_dev, bar_index, &map_regions, &num_map_regions); + ret = driver_desc->get_mappable_regions_cb(gasket_dev, + bar_index, + &map_regions, + &num_map_regions); if (ret) return ret; } else { @@ -1231,8 +1230,8 @@ static int gasket_open(struct inode *inode, struct file *filp) /* If the node is not owned, assign it to the current TGID. */ if (!ownership->is_owned) { - ret = gasket_check_and_invoke_callback_nolock( - gasket_dev, driver_desc->device_open_cb); + ret = gasket_check_and_invoke_callback_nolock(gasket_dev, + driver_desc->device_open_cb); if (ret) { dev_err(gasket_dev->dev, "Error in device open cb: %d\n", ret); @@ -1298,16 +1297,14 @@ static int gasket_release(struct inode *inode, struct file *file) driver_desc->device_reset_cb(gasket_dev, 0); for (i = 0; i < driver_desc->num_page_tables; ++i) { - gasket_page_table_unmap_all( - gasket_dev->page_table[i]); - gasket_page_table_garbage_collect( - gasket_dev->page_table[i]); + gasket_page_table_unmap_all(gasket_dev->page_table[i]); + gasket_page_table_garbage_collect(gasket_dev->page_table[i]); gasket_free_coherent_memory_all(gasket_dev, i); } /* Closes device, enters power save. */ - gasket_check_and_invoke_callback_nolock( - gasket_dev, driver_desc->device_close_cb); + gasket_check_and_invoke_callback_nolock(gasket_dev, + driver_desc->device_close_cb); } } @@ -1367,21 +1364,21 @@ static const struct file_operations gasket_file_ops = { }; /* Perform final init and marks the device as active. */ -static int gasket_enable_dev( - struct gasket_internal_desc *internal_desc, - struct gasket_dev *gasket_dev) +static int gasket_enable_dev(struct gasket_internal_desc *internal_desc, + struct gasket_dev *gasket_dev) { int tbl_idx; int ret; const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc; - ret = gasket_interrupt_init( - gasket_dev, driver_desc->name, - driver_desc->interrupt_type, driver_desc->interrupts, - driver_desc->num_interrupts, driver_desc->interrupt_pack_width, - driver_desc->interrupt_bar_index, - driver_desc->wire_interrupt_offsets); + ret = gasket_interrupt_init(gasket_dev, driver_desc->name, + driver_desc->interrupt_type, + driver_desc->interrupts, + driver_desc->num_interrupts, + driver_desc->interrupt_pack_width, + driver_desc->interrupt_bar_index, + driver_desc->wire_interrupt_offsets); if (ret) { dev_err(gasket_dev->dev, "Critical failure to allocate interrupts: %d\n", ret); @@ -1392,12 +1389,11 @@ static int gasket_enable_dev( for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { dev_dbg(gasket_dev->dev, "Initializing page table %d.\n", tbl_idx); - ret = gasket_page_table_init( - &gasket_dev->page_table[tbl_idx], - &gasket_dev->bar_data[ - driver_desc->page_table_bar_index], - &driver_desc->page_table_configs[tbl_idx], - gasket_dev->dev, gasket_dev->pci_dev); + ret = gasket_page_table_init(&gasket_dev->page_table[tbl_idx], + &gasket_dev->bar_data[driver_desc->page_table_bar_index], + &driver_desc->page_table_configs[tbl_idx], + gasket_dev->dev, + gasket_dev->pci_dev); if (ret) { dev_err(gasket_dev->dev, "Couldn't init page table %d: %d\n", @@ -1415,8 +1411,8 @@ static int gasket_enable_dev( * hardware_revision_cb returns a positive integer (the rev) if * successful.) */ - ret = check_and_invoke_callback( - gasket_dev, driver_desc->hardware_revision_cb); + ret = check_and_invoke_callback(gasket_dev, + driver_desc->hardware_revision_cb); if (ret < 0) { dev_err(gasket_dev->dev, "Error getting hardware revision: %d\n", ret); @@ -1436,8 +1432,8 @@ static int gasket_enable_dev( if (gasket_dev->status == GASKET_STATUS_DEAD) dev_err(gasket_dev->dev, "Device reported as unhealthy.\n"); - ret = gasket_add_cdev( - &gasket_dev->dev_info, &gasket_file_ops, driver_desc->module); + ret = gasket_add_cdev(&gasket_dev->dev_info, &gasket_file_ops, + driver_desc->module); if (ret) return ret; @@ -1452,8 +1448,8 @@ static int gasket_enable_dev( * * Returns 0 if successful and a negative value otherwise. */ -static int gasket_pci_probe( - struct pci_dev *pci_dev, const struct pci_device_id *id) +static int gasket_pci_probe(struct pci_dev *pci_dev, + const struct pci_device_id *id) { int ret; const char *kobj_name = dev_name(&pci_dev->dev); @@ -1497,8 +1493,8 @@ static int gasket_pci_probe( goto fail2; } - ret = gasket_sysfs_create_mapping( - gasket_dev->dev_info.device, gasket_dev); + ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device, + gasket_dev); if (ret) goto fail3; @@ -1513,13 +1509,13 @@ static int gasket_pci_probe( "Cannot create sysfs pci link: %d\n", ret); goto fail3; } - ret = gasket_sysfs_create_entries( - gasket_dev->dev_info.device, gasket_sysfs_generic_attrs); + ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device, + gasket_sysfs_generic_attrs); if (ret) goto fail4; - ret = check_and_invoke_callback( - gasket_dev, driver_desc->sysfs_setup_cb); + ret = check_and_invoke_callback(gasket_dev, + driver_desc->sysfs_setup_cb); if (ret) { dev_err(gasket_dev->dev, "Error in sysfs setup cb: %d\n", ret); goto fail5; @@ -1611,8 +1607,8 @@ static void gasket_pci_remove(struct pci_dev *pci_dev) * * The table must have a NULL name pointer at the end. */ -const char *gasket_num_name_lookup( - uint num, const struct gasket_num_name *table) +const char *gasket_num_name_lookup(uint num, + const struct gasket_num_name *table) { uint i = 0; @@ -1677,8 +1673,8 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) } EXPORT_SYMBOL(gasket_reset_nolock); -gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( - struct gasket_dev *gasket_dev) +gasket_ioctl_permissions_cb_t +gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev) { return gasket_dev->internal_desc->driver_desc->ioctl_permissions_cb; } @@ -1713,9 +1709,9 @@ struct device *gasket_get_device(struct gasket_dev *dev) * Description: Busy waits for a specific combination of bits to be set on a * Gasket register. **/ -int gasket_wait_with_reschedule( - struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - uint max_retries, u64 delay_ms) +int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar, + u64 offset, u64 mask, u64 val, + uint max_retries, u64 delay_ms) { uint retries = 0; u64 tmp; @@ -1797,17 +1793,17 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) * depends on KBUILD_MODNAME, and this is a shared file. */ pr_debug("Registering PCI driver.\n"); - ret = __pci_register_driver( - &internal->pci, driver_desc->module, driver_desc->name); + ret = __pci_register_driver(&internal->pci, driver_desc->module, + driver_desc->name); if (ret) { pr_err("cannot register pci driver [ret=%d]\n", ret); goto fail1; } pr_debug("Registering char driver.\n"); - ret = register_chrdev_region( - MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, - driver_desc->name); + ret = register_chrdev_region(MKDEV(driver_desc->major, + driver_desc->minor), GASKET_DEV_MAX, + driver_desc->name); if (ret) { pr_err("cannot register char driver [ret=%d]\n", ret); goto fail2; @@ -1853,8 +1849,8 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) return; } - unregister_chrdev_region( - MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX); + unregister_chrdev_region(MKDEV(driver_desc->major, driver_desc->minor), + GASKET_DEV_MAX); pci_unregister_driver(&internal_desc->pci); diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 8bd431ad3b58..713bf42de41a 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -318,11 +318,11 @@ struct gasket_dev { }; /* Type of the ioctl handler callback. */ -typedef long (*gasket_ioctl_handler_cb_t) - (struct file *file, uint cmd, void __user *argp); +typedef long (*gasket_ioctl_handler_cb_t)(struct file *file, uint cmd, + void __user *argp); /* Type of the ioctl permissions check callback. See below. */ -typedef int (*gasket_ioctl_permissions_cb_t)( - struct file *filp, uint cmd, void __user *argp); +typedef int (*gasket_ioctl_permissions_cb_t)(struct file *filp, uint cmd, + void __user *argp); /* * Device type descriptor. @@ -457,8 +457,8 @@ struct gasket_driver_desc { * descriptor for an open file is closed. This call is intended to * handle any per-user or per-fd cleanup. */ - int (*device_release_cb)( - struct gasket_dev *gasket_dev, struct file *file); + int (*device_release_cb)(struct gasket_dev *gasket_dev, + struct file *file); /* * device_close_cb: Callback for when a device node is closed for the @@ -527,10 +527,10 @@ struct gasket_driver_desc { * information is then compared to mmap request to determine which * regions to actually map. */ - int (*get_mappable_regions_cb)( - struct gasket_dev *gasket_dev, int bar_index, - struct gasket_mappable_region **mappable_regions, - int *num_mappable_regions); + int (*get_mappable_regions_cb)(struct gasket_dev *gasket_dev, + int bar_index, + struct gasket_mappable_region **mappable_regions, + int *num_mappable_regions); /* * ioctl_permissions_cb: Check permissions for generic ioctls. @@ -631,16 +631,16 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type); */ /* Unmaps the specified mappable region from a VMA. */ -int gasket_mm_unmap_region( - const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, - const struct gasket_mappable_region *map_region); +int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev, + struct vm_area_struct *vma, + const struct gasket_mappable_region *map_region); /* * Get the ioctl permissions callback. * @gasket_dev: Gasket device structure. */ -gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( - struct gasket_dev *gasket_dev); +gasket_ioctl_permissions_cb_t +gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev); /** * Lookup a name by number in a num_name table. @@ -648,37 +648,37 @@ gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( * @table: Array of num_name structures, the table for the lookup. * */ -const char *gasket_num_name_lookup( - uint num, const struct gasket_num_name *table); +const char *gasket_num_name_lookup(uint num, + const struct gasket_num_name *table); /* Handy inlines */ -static inline ulong gasket_dev_read_64( - struct gasket_dev *gasket_dev, int bar, ulong location) +static inline ulong gasket_dev_read_64(struct gasket_dev *gasket_dev, int bar, + ulong location) { return readq(&gasket_dev->bar_data[bar].virt_base[location]); } -static inline void gasket_dev_write_64( - struct gasket_dev *dev, u64 value, int bar, ulong location) +static inline void gasket_dev_write_64(struct gasket_dev *dev, u64 value, + int bar, ulong location) { writeq(value, &dev->bar_data[bar].virt_base[location]); } -static inline void gasket_dev_write_32( - struct gasket_dev *dev, u32 value, int bar, ulong location) +static inline void gasket_dev_write_32(struct gasket_dev *dev, u32 value, + int bar, ulong location) { writel(value, &dev->bar_data[bar].virt_base[location]); } -static inline u32 gasket_dev_read_32( - struct gasket_dev *dev, int bar, ulong location) +static inline u32 gasket_dev_read_32(struct gasket_dev *dev, int bar, + ulong location) { return readl(&dev->bar_data[bar].virt_base[location]); } -static inline void gasket_read_modify_write_64( - struct gasket_dev *dev, int bar, ulong location, u64 value, - u64 mask_width, u64 mask_shift) +static inline void gasket_read_modify_write_64(struct gasket_dev *dev, int bar, + ulong location, u64 value, + u64 mask_width, u64 mask_shift) { u64 mask, tmp; @@ -688,9 +688,9 @@ static inline void gasket_read_modify_write_64( gasket_dev_write_64(dev, tmp, bar, location); } -static inline void gasket_read_modify_write_32( - struct gasket_dev *dev, int bar, ulong location, u32 value, - u32 mask_width, u32 mask_shift) +static inline void gasket_read_modify_write_32(struct gasket_dev *dev, int bar, + ulong location, u32 value, + u32 mask_width, u32 mask_shift) { u32 mask, tmp; @@ -707,8 +707,8 @@ const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev); struct device *gasket_get_device(struct gasket_dev *dev); /* Helper function, Asynchronous waits on a given set of bits. */ -int gasket_wait_with_reschedule( - struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - uint max_retries, u64 delay_ms); +int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar, + u64 offset, u64 mask, u64 val, + uint max_retries, u64 delay_ms); #endif /* __GASKET_CORE_H__ */ From 3e845083131224934b6833642aa1c9a0754b4e61 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:40 -0700 Subject: [PATCH 756/903] staging: gasket: ioctl: fix function param line continuation style Fix multi-line alignment formatting to look like: int ret = long_function_name(device, VARIABLE1, VARIABLE2, VARIABLE3, VARIABLE4); Many of these TODO items were previously cleaned up during the conversion to standard logging functions. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 60 +++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 134d45a281ac..d3397cc74e69 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -79,12 +79,12 @@ static int gasket_read_simple_page_table_size( if (ibuf.page_table_index >= gasket_dev->num_page_tables) return -EFAULT; - ibuf.size = gasket_page_table_num_simple_entries( - gasket_dev->page_table[ibuf.page_table_index]); + ibuf.size = + gasket_page_table_num_simple_entries(gasket_dev->page_table[ibuf.page_table_index]); - trace_gasket_ioctl_page_table_data( - ibuf.page_table_index, ibuf.size, ibuf.host_address, - ibuf.device_address); + trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size, + ibuf.host_address, + ibuf.device_address); if (copy_to_user(argp, &ibuf, sizeof(ibuf))) return -EFAULT; @@ -138,21 +138,21 @@ static int gasket_map_buffers(struct gasket_dev *gasket_dev, if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; - trace_gasket_ioctl_page_table_data( - ibuf.page_table_index, ibuf.size, ibuf.host_address, - ibuf.device_address); + trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size, + ibuf.host_address, + ibuf.device_address); if (ibuf.page_table_index >= gasket_dev->num_page_tables) return -EFAULT; - if (gasket_page_table_are_addrs_bad( - gasket_dev->page_table[ibuf.page_table_index], - ibuf.host_address, ibuf.device_address, ibuf.size)) + if (gasket_page_table_are_addrs_bad(gasket_dev->page_table[ibuf.page_table_index], + ibuf.host_address, + ibuf.device_address, ibuf.size)) return -EINVAL; - return gasket_page_table_map( - gasket_dev->page_table[ibuf.page_table_index], - ibuf.host_address, ibuf.device_address, ibuf.size / PAGE_SIZE); + return gasket_page_table_map(gasket_dev->page_table[ibuf.page_table_index], + ibuf.host_address, ibuf.device_address, + ibuf.size / PAGE_SIZE); } /* Unmap a userspace buffer from a device virtual address. */ @@ -164,16 +164,15 @@ static int gasket_unmap_buffers(struct gasket_dev *gasket_dev, if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; - trace_gasket_ioctl_page_table_data( - ibuf.page_table_index, ibuf.size, ibuf.host_address, - ibuf.device_address); + trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size, + ibuf.host_address, + ibuf.device_address); if (ibuf.page_table_index >= gasket_dev->num_page_tables) return -EFAULT; - if (gasket_page_table_is_dev_addr_bad( - gasket_dev->page_table[ibuf.page_table_index], - ibuf.device_address, ibuf.size)) + if (gasket_page_table_is_dev_addr_bad(gasket_dev->page_table[ibuf.page_table_index], + ibuf.device_address, ibuf.size)) return -EINVAL; gasket_page_table_unmap(gasket_dev->page_table[ibuf.page_table_index], @@ -197,8 +196,8 @@ static int gasket_config_coherent_allocator( sizeof(struct gasket_coherent_alloc_config_ioctl))) return -EFAULT; - trace_gasket_ioctl_config_coherent_allocator( - ibuf.enable, ibuf.size, ibuf.dma_address); + trace_gasket_ioctl_config_coherent_allocator(ibuf.enable, ibuf.size, + ibuf.dma_address); if (ibuf.page_table_index >= gasket_dev->num_page_tables) return -EFAULT; @@ -207,13 +206,13 @@ static int gasket_config_coherent_allocator( return -ENOMEM; if (ibuf.enable == 0) { - ret = gasket_free_coherent_memory( - gasket_dev, ibuf.size, ibuf.dma_address, - ibuf.page_table_index); + ret = gasket_free_coherent_memory(gasket_dev, ibuf.size, + ibuf.dma_address, + ibuf.page_table_index); } else { - ret = gasket_alloc_coherent_memory( - gasket_dev, ibuf.size, &ibuf.dma_address, - ibuf.page_table_index); + ret = gasket_alloc_coherent_memory(gasket_dev, ibuf.size, + &ibuf.dma_address, + ibuf.page_table_index); } if (ret) return ret; @@ -313,8 +312,9 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) break; case GASKET_IOCTL_CLEAR_EVENTFD: trace_gasket_ioctl_integer_data(arg); - retval = gasket_interrupt_clear_eventfd( - gasket_dev->interrupt_data, (int)arg); + retval = + gasket_interrupt_clear_eventfd(gasket_dev->interrupt_data, + (int)arg); break; case GASKET_IOCTL_PARTITION_PAGE_TABLE: trace_gasket_ioctl_integer_data(arg); From e8c7f19981dce9e8661b0b1e277bda4c322f9af7 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:41 -0700 Subject: [PATCH 757/903] staging: gasket: page table: fix function param line continuation style Fix multi-line alignment formatting to look like: int ret = long_function_name(device, VARIABLE1, VARIABLE2, VARIABLE3, VARIABLE4); Many of these TODO items were previously cleaned up during the conversion to standard logging functions. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 206 +++++++++++---------- drivers/staging/gasket/gasket_page_table.h | 33 ++-- 2 files changed, 120 insertions(+), 119 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index aa036b2e8193..13e1d0952a47 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -215,11 +215,10 @@ struct gasket_page_table { }; /* See gasket_page_table.h for description. */ -int gasket_page_table_init( - struct gasket_page_table **ppg_tbl, - const struct gasket_bar_data *bar_data, - const struct gasket_page_table_config *page_table_config, - struct device *device, struct pci_dev *pci_dev) +int gasket_page_table_init(struct gasket_page_table **ppg_tbl, + const struct gasket_bar_data *bar_data, + const struct gasket_page_table_config *page_table_config, + struct device *device, struct pci_dev *pci_dev) { ulong bytes; struct gasket_page_table *pg_tbl; @@ -276,10 +275,10 @@ int gasket_page_table_init( pg_tbl->extended_flag = 0; } pg_tbl->num_active_pages = 0; - pg_tbl->base_slot = (u64 __iomem *)&( - bar_data->virt_base[page_table_config->base_reg]); - pg_tbl->extended_offset_reg = (u64 __iomem *)&( - bar_data->virt_base[page_table_config->extended_reg]); + pg_tbl->base_slot = + (u64 __iomem *)&bar_data->virt_base[page_table_config->base_reg]; + pg_tbl->extended_offset_reg = + (u64 __iomem *)&bar_data->virt_base[page_table_config->extended_reg]; pg_tbl->device = get_device(device); pg_tbl->pci_dev = pci_dev_get(pci_dev); @@ -292,8 +291,8 @@ int gasket_page_table_init( * Check if a range of PTEs is free. * The page table mutex must be held by the caller. */ -static bool gasket_is_pte_range_free( - struct gasket_page_table_entry *ptes, uint num_entries) +static bool gasket_is_pte_range_free(struct gasket_page_table_entry *ptes, + uint num_entries) { int i; @@ -309,9 +308,9 @@ static bool gasket_is_pte_range_free( * Free a second level page [sub]table. * The page table mutex must be held before this call. */ -static void gasket_free_extended_subtable( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, - u64 __iomem *slot) +static void gasket_free_extended_subtable(struct gasket_page_table *pg_tbl, + struct gasket_page_table_entry *pte, + u64 __iomem *slot) { /* Release the page table from the driver */ pte->status = PTE_FREE; @@ -337,8 +336,8 @@ static void gasket_free_extended_subtable( * Actually perform collection. * The page table mutex must be held by the caller. */ -static void gasket_page_table_garbage_collect_nolock( - struct gasket_page_table *pg_tbl) +static void +gasket_page_table_garbage_collect_nolock(struct gasket_page_table *pg_tbl) { struct gasket_page_table_entry *pte; u64 __iomem *slot; @@ -351,10 +350,10 @@ static void gasket_page_table_garbage_collect_nolock( pte < pg_tbl->entries + pg_tbl->config.total_entries; pte++, slot++) { if (pte->status == PTE_INUSE) { - if (gasket_is_pte_range_free( - pte->sublevel, GASKET_PAGES_PER_SUBTABLE)) - gasket_free_extended_subtable( - pg_tbl, pte, slot); + if (gasket_is_pte_range_free(pte->sublevel, + GASKET_PAGES_PER_SUBTABLE)) + gasket_free_extended_subtable(pg_tbl, pte, + slot); } } } @@ -384,8 +383,8 @@ void gasket_page_table_cleanup(struct gasket_page_table *pg_tbl) } /* See gasket_page_table.h for description. */ -int gasket_page_table_partition( - struct gasket_page_table *pg_tbl, uint num_simple_entries) +int gasket_page_table_partition(struct gasket_page_table *pg_tbl, + uint num_simple_entries) { int i, start; @@ -445,10 +444,10 @@ static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr) * an extended mapping, these will be within a second-level page table * allocated by the host and so must have their __iomem attribute casted away. */ -static int gasket_perform_mapping( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, - u64 __iomem *slots, ulong host_addr, uint num_pages, - int is_simple_mapping) +static int gasket_perform_mapping(struct gasket_page_table *pg_tbl, + struct gasket_page_table_entry *ptes, + u64 __iomem *slots, ulong host_addr, + uint num_pages, int is_simple_mapping) { int ret; ulong offset; @@ -470,8 +469,8 @@ static int gasket_perform_mapping( ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + off + i * PAGE_SIZE; } else { - ret = get_user_pages_fast( - page_addr - offset, 1, 1, &page); + ret = get_user_pages_fast(page_addr - offset, 1, 1, + &page); if (ret <= 0) { dev_err(pg_tbl->device, @@ -532,8 +531,8 @@ static int gasket_perform_mapping( * Return the index of the page for the address in the simple table. * Does not perform validity checking. */ -static int gasket_simple_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr) +static int gasket_simple_page_idx(struct gasket_page_table *pg_tbl, + ulong dev_addr) { return (dev_addr >> GASKET_SIMPLE_PAGE_SHIFT) & (pg_tbl->config.total_entries - 1); @@ -543,8 +542,8 @@ static int gasket_simple_page_idx( * Return the level 0 page index for the given address. * Does not perform validity checking. */ -static ulong gasket_extended_lvl0_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr) +static ulong gasket_extended_lvl0_page_idx(struct gasket_page_table *pg_tbl, + ulong dev_addr) { return (dev_addr >> GASKET_EXTENDED_LVL0_SHIFT) & ((1 << GASKET_EXTENDED_LVL0_WIDTH) - 1); @@ -554,8 +553,8 @@ static ulong gasket_extended_lvl0_page_idx( * Return the level 1 page index for the given address. * Does not perform validity checking. */ -static ulong gasket_extended_lvl1_page_idx( - struct gasket_page_table *pg_tbl, ulong dev_addr) +static ulong gasket_extended_lvl1_page_idx(struct gasket_page_table *pg_tbl, + ulong dev_addr) { return (dev_addr >> GASKET_EXTENDED_LVL1_SHIFT) & (GASKET_PAGES_PER_SUBTABLE - 1); @@ -565,12 +564,12 @@ static ulong gasket_extended_lvl1_page_idx( * Allocate page table entries in a simple table. * The page table mutex must be held by the caller. */ -static int gasket_alloc_simple_entries( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +static int gasket_alloc_simple_entries(struct gasket_page_table *pg_tbl, + ulong dev_addr, uint num_pages) { - if (!gasket_is_pte_range_free( - pg_tbl->entries + gasket_simple_page_idx(pg_tbl, dev_addr), - num_pages)) + if (!gasket_is_pte_range_free(pg_tbl->entries + + gasket_simple_page_idx(pg_tbl, dev_addr), + num_pages)) return -EBUSY; return 0; @@ -593,9 +592,10 @@ static bool gasket_release_page(struct page *page) * Unmap and release mapped pages. * The page table mutex must be held by the caller. */ -static void gasket_perform_unmapping( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *ptes, - u64 __iomem *slots, uint num_pages, int is_simple_mapping) +static void gasket_perform_unmapping(struct gasket_page_table *pg_tbl, + struct gasket_page_table_entry *ptes, + u64 __iomem *slots, uint num_pages, + int is_simple_mapping) { int i; /* @@ -631,8 +631,8 @@ static void gasket_perform_unmapping( * Unmap and release pages mapped to simple addresses. * The page table mutex must be held by the caller. */ -static void gasket_unmap_simple_pages( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +static void gasket_unmap_simple_pages(struct gasket_page_table *pg_tbl, + ulong dev_addr, uint num_pages) { uint slot = gasket_simple_page_idx(pg_tbl, dev_addr); @@ -644,8 +644,8 @@ static void gasket_unmap_simple_pages( * Unmap and release buffers to extended addresses. * The page table mutex must be held by the caller. */ -static void gasket_unmap_extended_pages( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +static void gasket_unmap_extended_pages(struct gasket_page_table *pg_tbl, + ulong dev_addr, uint num_pages) { uint slot_idx, remain, len; struct gasket_page_table_entry *pte; @@ -663,9 +663,9 @@ static void gasket_unmap_extended_pages( if (pte->status == PTE_INUSE) { slot_base = (u64 __iomem *)(page_address(pte->page) + pte->offset); - gasket_perform_unmapping( - pg_tbl, pte->sublevel + slot_idx, - slot_base + slot_idx, len, 0); + gasket_perform_unmapping(pg_tbl, + pte->sublevel + slot_idx, + slot_base + slot_idx, len, 0); } remain -= len; @@ -675,8 +675,8 @@ static void gasket_unmap_extended_pages( } /* Evaluates to nonzero if the specified virtual address is simple. */ -static inline bool gasket_addr_is_simple( - struct gasket_page_table *pg_tbl, ulong addr) +static inline bool gasket_addr_is_simple(struct gasket_page_table *pg_tbl, + ulong addr) { return !((addr) & (pg_tbl)->extended_flag); } @@ -693,9 +693,9 @@ static inline bool gasket_addr_is_simple( * Extended page 1000, offset 511: * Input (1, 1000, 512), Output 0x8003E81FF */ -static ulong gasket_components_to_dev_address( - struct gasket_page_table *pg_tbl, int is_simple, uint page_index, - uint offset) +static ulong gasket_components_to_dev_address(struct gasket_page_table *pg_tbl, + int is_simple, uint page_index, + uint offset) { ulong lvl0_index, lvl1_index; @@ -726,15 +726,15 @@ static ulong gasket_components_to_dev_address( * and that the requested page range starts and ends within the set of * currently-partitioned simple pages. */ -static bool gasket_is_simple_dev_addr_bad( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +static bool gasket_is_simple_dev_addr_bad(struct gasket_page_table *pg_tbl, + ulong dev_addr, uint num_pages) { ulong page_offset = dev_addr & (PAGE_SIZE - 1); ulong page_index = (dev_addr / PAGE_SIZE) & (pg_tbl->config.total_entries - 1); - if (gasket_components_to_dev_address( - pg_tbl, 1, page_index, page_offset) != dev_addr) { + if (gasket_components_to_dev_address(pg_tbl, 1, page_index, + page_offset) != dev_addr) { dev_err(pg_tbl->device, "address is invalid, 0x%lX\n", dev_addr); return true; @@ -764,8 +764,8 @@ static bool gasket_is_simple_dev_addr_bad( * offset) and that the requested page range starts and ends within the set of * currently-partitioned extended pages. */ -static bool gasket_is_extended_dev_addr_bad( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +static bool gasket_is_extended_dev_addr_bad(struct gasket_page_table *pg_tbl, + ulong dev_addr, uint num_pages) { /* Starting byte index of dev_addr into the first mapped page */ ulong page_offset = dev_addr & (PAGE_SIZE - 1); @@ -792,8 +792,8 @@ static bool gasket_is_extended_dev_addr_bad( num_lvl0_pages = (num_pages + GASKET_PAGES_PER_SUBTABLE - 1) / GASKET_PAGES_PER_SUBTABLE; - if (gasket_components_to_dev_address( - pg_tbl, 0, page_global_idx, page_offset) != dev_addr) { + if (gasket_components_to_dev_address(pg_tbl, 0, page_global_idx, + page_offset) != dev_addr) { dev_err(pg_tbl->device, "address is invalid: 0x%lx\n", dev_addr); return true; @@ -821,8 +821,8 @@ static bool gasket_is_extended_dev_addr_bad( * Non-locking entry to unmapping routines. * The page table mutex must be held by the caller. */ -static void gasket_page_table_unmap_nolock( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +static void gasket_page_table_unmap_nolock(struct gasket_page_table *pg_tbl, + ulong dev_addr, uint num_pages) { if (!num_pages) return; @@ -837,9 +837,9 @@ static void gasket_page_table_unmap_nolock( * Allocate and map pages to simple addresses. * If there is an error, no pages are mapped. */ -static int gasket_map_simple_pages( - struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, - uint num_pages) +static int gasket_map_simple_pages(struct gasket_page_table *pg_tbl, + ulong host_addr, ulong dev_addr, + uint num_pages) { int ret; uint slot_idx = gasket_simple_page_idx(pg_tbl, dev_addr); @@ -852,9 +852,9 @@ static int gasket_map_simple_pages( return ret; } - ret = gasket_perform_mapping( - pg_tbl, pg_tbl->entries + slot_idx, - pg_tbl->base_slot + slot_idx, host_addr, num_pages, 1); + ret = gasket_perform_mapping(pg_tbl, pg_tbl->entries + slot_idx, + pg_tbl->base_slot + slot_idx, host_addr, + num_pages, 1); if (ret) { gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages); @@ -867,9 +867,9 @@ static int gasket_map_simple_pages( * Allocate a second level page table. * The page table mutex must be held by the caller. */ -static int gasket_alloc_extended_subtable( - struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte, - u64 __iomem *slot) +static int gasket_alloc_extended_subtable(struct gasket_page_table *pg_tbl, + struct gasket_page_table_entry *pte, + u64 __iomem *slot) { ulong page_addr, subtable_bytes; dma_addr_t dma_addr; @@ -924,8 +924,8 @@ static int gasket_alloc_extended_subtable( * * The page table mutex must be held by the caller. */ -static int gasket_alloc_extended_entries( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries) +static int gasket_alloc_extended_entries(struct gasket_page_table *pg_tbl, + ulong dev_addr, uint num_entries) { int ret = 0; uint remain, subtable_slot_idx, len; @@ -951,8 +951,8 @@ static int gasket_alloc_extended_entries( return ret; } } else { - if (!gasket_is_pte_range_free( - pte->sublevel + subtable_slot_idx, len)) + if (!gasket_is_pte_range_free(pte->sublevel + + subtable_slot_idx, len)) return -EBUSY; } @@ -969,9 +969,9 @@ static int gasket_alloc_extended_entries( * gasket_map_extended_pages - Get and map buffers to extended addresses. * If there is an error, no pages are mapped. */ -static int gasket_map_extended_pages( - struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, - uint num_pages) +static int gasket_map_extended_pages(struct gasket_page_table *pg_tbl, + ulong host_addr, ulong dev_addr, + uint num_pages) { int ret; ulong dev_addr_end; @@ -1003,12 +1003,12 @@ static int gasket_map_extended_pages( slot_base = (u64 __iomem *)(page_address(pte->page) + pte->offset); - ret = gasket_perform_mapping( - pg_tbl, pte->sublevel + slot_idx, slot_base + slot_idx, - host_addr, len, 0); + ret = gasket_perform_mapping(pg_tbl, pte->sublevel + slot_idx, + slot_base + slot_idx, host_addr, + len, 0); if (ret) { - gasket_page_table_unmap_nolock( - pg_tbl, dev_addr, num_pages); + gasket_page_table_unmap_nolock(pg_tbl, dev_addr, + num_pages); return ret; } @@ -1029,9 +1029,8 @@ static int gasket_map_extended_pages( * * The page table mutex is held for the entire operation. */ -int gasket_page_table_map( - struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, - uint num_pages) +int gasket_page_table_map(struct gasket_page_table *pg_tbl, ulong host_addr, + ulong dev_addr, uint num_pages) { int ret; @@ -1041,11 +1040,11 @@ int gasket_page_table_map( mutex_lock(&pg_tbl->mutex); if (gasket_addr_is_simple(pg_tbl, dev_addr)) { - ret = gasket_map_simple_pages( - pg_tbl, host_addr, dev_addr, num_pages); + ret = gasket_map_simple_pages(pg_tbl, host_addr, dev_addr, + num_pages); } else { - ret = gasket_map_extended_pages( - pg_tbl, host_addr, dev_addr, num_pages); + ret = gasket_map_extended_pages(pg_tbl, host_addr, dev_addr, + num_pages); } mutex_unlock(&pg_tbl->mutex); @@ -1067,8 +1066,8 @@ EXPORT_SYMBOL(gasket_page_table_map); * * The page table mutex is held for the entire operation. */ -void gasket_page_table_unmap( - struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages) +void gasket_page_table_unmap(struct gasket_page_table *pg_tbl, ulong dev_addr, + uint num_pages) { if (!num_pages) return; @@ -1081,12 +1080,15 @@ EXPORT_SYMBOL(gasket_page_table_unmap); static void gasket_page_table_unmap_all_nolock(struct gasket_page_table *pg_tbl) { - gasket_unmap_simple_pages( - pg_tbl, gasket_components_to_dev_address(pg_tbl, 1, 0, 0), - pg_tbl->num_simple_entries); - gasket_unmap_extended_pages( - pg_tbl, gasket_components_to_dev_address(pg_tbl, 0, 0, 0), - pg_tbl->num_extended_entries * GASKET_PAGES_PER_SUBTABLE); + gasket_unmap_simple_pages(pg_tbl, + gasket_components_to_dev_address(pg_tbl, 1, 0, + 0), + pg_tbl->num_simple_entries); + gasket_unmap_extended_pages(pg_tbl, + gasket_components_to_dev_address(pg_tbl, 0, + 0, 0), + pg_tbl->num_extended_entries * + GASKET_PAGES_PER_SUBTABLE); } /* See gasket_page_table.h for description. */ @@ -1189,8 +1191,8 @@ bool gasket_page_table_is_dev_addr_bad( } if (gasket_addr_is_simple(pg_tbl, dev_addr)) - return gasket_is_simple_dev_addr_bad( - pg_tbl, dev_addr, num_pages); + return gasket_is_simple_dev_addr_bad(pg_tbl, dev_addr, + num_pages); return gasket_is_extended_dev_addr_bad(pg_tbl, dev_addr, num_pages); } EXPORT_SYMBOL(gasket_page_table_is_dev_addr_bad); diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index 765588649365..00c06f050eb9 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h @@ -46,11 +46,10 @@ struct gasket_page_table; * * Returns 0 on success, a negative error code otherwise. */ -int gasket_page_table_init( - struct gasket_page_table **ppg_tbl, - const struct gasket_bar_data *bar_data, - const struct gasket_page_table_config *page_table_config, - struct device *device, struct pci_dev *pci_dev); +int gasket_page_table_init(struct gasket_page_table **ppg_tbl, + const struct gasket_bar_data *bar_data, + const struct gasket_page_table_config *page_table_config, + struct device *device, struct pci_dev *pci_dev); /* * Deallocate and cleanup page table data. @@ -77,8 +76,8 @@ void gasket_page_table_cleanup(struct gasket_page_table *page_table); * Returns 0 if successful, or non-zero if the page table entries * are not free. */ -int gasket_page_table_partition( - struct gasket_page_table *page_table, uint num_simple_entries); +int gasket_page_table_partition(struct gasket_page_table *page_table, + uint num_simple_entries); /* * Get and map [host] user space pages into device memory. @@ -106,8 +105,8 @@ int gasket_page_table_map(struct gasket_page_table *page_table, ulong host_addr, * * Description: The inverse of gasket_map_pages. Unmaps pages from the device. */ -void gasket_page_table_unmap( - struct gasket_page_table *page_table, ulong dev_addr, uint num_pages); +void gasket_page_table_unmap(struct gasket_page_table *page_table, + ulong dev_addr, uint num_pages); /* * Unmap ALL host pages from device memory. @@ -146,9 +145,9 @@ void gasket_page_table_garbage_collect(struct gasket_page_table *page_table); * Returns 0 if successful, -1 for an error. The page pointer * and offset are returned through the pointers, if successful. */ -int gasket_page_table_lookup_page( - struct gasket_page_table *page_table, ulong dev_addr, - struct page **page, ulong *poffset); +int gasket_page_table_lookup_page(struct gasket_page_table *page_table, + ulong dev_addr, struct page **page, + ulong *poffset); /* * Checks validity for input addrs and size. @@ -163,9 +162,9 @@ int gasket_page_table_lookup_page( * * Returns true if the mapping is bad, false otherwise. */ -bool gasket_page_table_are_addrs_bad( - struct gasket_page_table *page_table, ulong host_addr, ulong dev_addr, - ulong bytes); +bool gasket_page_table_are_addrs_bad(struct gasket_page_table *page_table, + ulong host_addr, ulong dev_addr, + ulong bytes); /* * Checks validity for input dev addr and size. @@ -179,8 +178,8 @@ bool gasket_page_table_are_addrs_bad( * * Returns true if the address is bad, false otherwise. */ -bool gasket_page_table_is_dev_addr_bad( - struct gasket_page_table *page_table, ulong dev_addr, ulong bytes); +bool gasket_page_table_is_dev_addr_bad(struct gasket_page_table *page_table, + ulong dev_addr, ulong bytes); /* * Gets maximum size for the given page table. From 46b77a6b6922113add0a0b9711f5044b1e6aa6a1 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:42 -0700 Subject: [PATCH 758/903] staging: gasket: sysfs: fix function param line continuation style Fix multi-line alignment formatting to look like: int ret = long_function_name(device, VARIABLE1, VARIABLE2, VARIABLE3, VARIABLE4); Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 26 +++++++++++----------- drivers/staging/gasket/gasket_sysfs.h | 32 +++++++++++++-------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index ef4eca02afa6..a4bfca43cd03 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -145,8 +145,8 @@ void gasket_sysfs_init(void) } } -int gasket_sysfs_create_mapping( - struct device *device, struct gasket_dev *gasket_dev) +int gasket_sysfs_create_mapping(struct device *device, + struct gasket_dev *gasket_dev) { struct gasket_sysfs_mapping *mapping; int map_idx = -1; @@ -210,8 +210,8 @@ int gasket_sysfs_create_mapping( return 0; } -int gasket_sysfs_create_entries( - struct device *device, const struct gasket_sysfs_attribute *attrs) +int gasket_sysfs_create_entries(struct device *device, + const struct gasket_sysfs_attribute *attrs) { int i; int ret; @@ -293,8 +293,8 @@ void gasket_sysfs_put_device_data(struct device *device, struct gasket_dev *dev) } EXPORT_SYMBOL(gasket_sysfs_put_device_data); -struct gasket_sysfs_attribute *gasket_sysfs_get_attr( - struct device *device, struct device_attribute *attr) +struct gasket_sysfs_attribute * +gasket_sysfs_get_attr(struct device *device, struct device_attribute *attr) { int i; int num_attrs; @@ -317,8 +317,8 @@ struct gasket_sysfs_attribute *gasket_sysfs_get_attr( } EXPORT_SYMBOL(gasket_sysfs_get_attr); -void gasket_sysfs_put_attr( - struct device *device, struct gasket_sysfs_attribute *attr) +void gasket_sysfs_put_attr(struct device *device, + struct gasket_sysfs_attribute *attr) { int i; int num_attrs; @@ -342,9 +342,9 @@ void gasket_sysfs_put_attr( } EXPORT_SYMBOL(gasket_sysfs_put_attr); -ssize_t gasket_sysfs_register_store( - struct device *device, struct device_attribute *attr, const char *buf, - size_t count) +ssize_t gasket_sysfs_register_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t count) { ulong parsed_value = 0; struct gasket_sysfs_mapping *mapping; @@ -386,8 +386,8 @@ ssize_t gasket_sysfs_register_store( gasket_attr->data.bar_address.offset); if (gasket_attr->write_callback) - gasket_attr->write_callback( - gasket_dev, gasket_attr, parsed_value); + gasket_attr->write_callback(gasket_dev, gasket_attr, + parsed_value); gasket_sysfs_put_attr(device, gasket_attr); put_mapping(mapping); diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h index e9f4fad80461..f32eaf89e056 100644 --- a/drivers/staging/gasket/gasket_sysfs.h +++ b/drivers/staging/gasket/gasket_sysfs.h @@ -68,9 +68,9 @@ struct gasket_sysfs_attribute { * The callback should perform any logging necessary, as errors cannot * be returned from the callback. */ - void (*write_callback)( - struct gasket_dev *dev, struct gasket_sysfs_attribute *attr, - ulong value); + void (*write_callback)(struct gasket_dev *dev, + struct gasket_sysfs_attribute *attr, + ulong value); }; #define GASKET_SYSFS_RO(_name, _show_function, _attr_type) \ @@ -98,8 +98,8 @@ void gasket_sysfs_init(void); * If this function is not called before gasket_sysfs_create_entries, a warning * will be logged. */ -int gasket_sysfs_create_mapping( - struct device *device, struct gasket_dev *gasket_dev); +int gasket_sysfs_create_mapping(struct device *device, + struct gasket_dev *gasket_dev); /* * Creates bulk entries in sysfs. @@ -111,8 +111,8 @@ int gasket_sysfs_create_mapping( * gasket_sysfs_create_mapping had a legacy device, the entries will be created * for it, as well. */ -int gasket_sysfs_create_entries( - struct device *device, const struct gasket_sysfs_attribute *attrs); +int gasket_sysfs_create_entries(struct device *device, + const struct gasket_sysfs_attribute *attrs); /* * Removes a device mapping from the global table. @@ -141,8 +141,8 @@ struct gasket_dev *gasket_sysfs_get_device_data(struct device *device); * @device: Kernel device structure. * @dev: Gasket device descriptor (returned by gasket_sysfs_get_device_data). */ -void gasket_sysfs_put_device_data( - struct device *device, struct gasket_dev *gasket_dev); +void gasket_sysfs_put_device_data(struct device *device, + struct gasket_dev *gasket_dev); /* * Gasket-specific attribute lookup. @@ -155,8 +155,8 @@ void gasket_sysfs_put_device_data( * gasket_sysfs_get_device_data. While this reference is held, the underlying * device sysfs information/structure will remain valid/will not be deleted. */ -struct gasket_sysfs_attribute *gasket_sysfs_get_attr( - struct device *device, struct device_attribute *attr); +struct gasket_sysfs_attribute * +gasket_sysfs_get_attr(struct device *device, struct device_attribute *attr); /* * Releases a references to internal data. @@ -164,16 +164,16 @@ struct gasket_sysfs_attribute *gasket_sysfs_get_attr( * @attr: Gasket sysfs attribute descriptor (returned by * gasket_sysfs_get_attr). */ -void gasket_sysfs_put_attr( - struct device *device, struct gasket_sysfs_attribute *attr); +void gasket_sysfs_put_attr(struct device *device, + struct gasket_sysfs_attribute *attr); /* * Write to a register sysfs node. * @buf: NULL-terminated data being written. * @count: number of bytes in the "buf" argument. */ -ssize_t gasket_sysfs_register_store( - struct device *device, struct device_attribute *attr, const char *buf, - size_t count); +ssize_t gasket_sysfs_register_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t count); #endif /* __GASKET_SYSFS_H__ */ From 21cfa72cddee4cfd6a091968517fdbb4263f71d3 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:43 -0700 Subject: [PATCH 759/903] staging: gasket: interrupt: fix function param line continuation style Fix multi-line alignment formatting to look like: int ret = long_function_name(device, VARIABLE1, VARIABLE2, VARIABLE3, VARIABLE4); Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 73 +++++++++++------------ drivers/staging/gasket/gasket_interrupt.h | 19 +++--- 2 files changed, 43 insertions(+), 49 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 3079b59b122b..09c3d0747af6 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -144,11 +144,10 @@ static void gasket_interrupt_setup(struct gasket_dev *gasket_dev) } mask = ~(0xFFFF << pack_shift); - value = gasket_dev_read_64( - gasket_dev, - interrupt_data->interrupt_bar_index, - interrupt_data->interrupts[i].reg) & - mask; + value = gasket_dev_read_64(gasket_dev, + interrupt_data->interrupt_bar_index, + interrupt_data->interrupts[i].reg); + value &= mask; value |= interrupt_data->interrupts[i].index << pack_shift; } @@ -187,8 +186,8 @@ static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static int gasket_interrupt_msix_init( - struct gasket_interrupt_data *interrupt_data) +static int +gasket_interrupt_msix_init(struct gasket_interrupt_data *interrupt_data) { int ret = 1; int i; @@ -210,10 +209,9 @@ static int gasket_interrupt_msix_init( interrupt_data->msix_configured = 1; for (i = 0; i < interrupt_data->num_interrupts; i++) { - ret = request_irq( - interrupt_data->msix_entries[i].vector, - gasket_msix_interrupt_handler, 0, interrupt_data->name, - interrupt_data); + ret = request_irq(interrupt_data->msix_entries[i].vector, + gasket_msix_interrupt_handler, 0, + interrupt_data->name, interrupt_data); if (ret) { dev_err(&interrupt_data->pci_dev->dev, @@ -250,25 +248,23 @@ static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev) ulong location = APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE + MSIX_MASK_BIT_OFFSET + i * MSIX_VECTOR_SIZE; u32 mask = - gasket_dev_read_32( - gasket_dev, - gasket_dev->interrupt_data->interrupt_bar_index, - location); + gasket_dev_read_32(gasket_dev, + gasket_dev->interrupt_data->interrupt_bar_index, + location); if (!(mask & 1)) continue; /* Unmask the msix vector (clear 32 bits) */ - gasket_dev_write_32( - gasket_dev, 0, - gasket_dev->interrupt_data->interrupt_bar_index, - location); + gasket_dev_write_32(gasket_dev, 0, + gasket_dev->interrupt_data->interrupt_bar_index, + location); } #undef MSIX_VECTOR_SIZE #undef MSIX_MASK_BIT_OFFSET #undef APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE } -static ssize_t interrupt_sysfs_show( - struct device *device, struct device_attribute *attr, char *buf) +static ssize_t interrupt_sysfs_show(struct device *device, + struct device_attribute *attr, char *buf) { int i, ret; ssize_t written = 0, total_written = 0; @@ -318,22 +314,22 @@ static ssize_t interrupt_sysfs_show( } static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = { - GASKET_SYSFS_RO( - interrupt_counts, interrupt_sysfs_show, ATTR_INTERRUPT_COUNTS), + GASKET_SYSFS_RO(interrupt_counts, interrupt_sysfs_show, + ATTR_INTERRUPT_COUNTS), GASKET_END_OF_ATTR_ARRAY, }; -int gasket_interrupt_init( - struct gasket_dev *gasket_dev, const char *name, int type, - const struct gasket_interrupt_desc *interrupts, - int num_interrupts, int pack_width, int bar_index, - const struct gasket_wire_interrupt_offsets *wire_int_offsets) +int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, + int type, + const struct gasket_interrupt_desc *interrupts, + int num_interrupts, int pack_width, int bar_index, + const struct gasket_wire_interrupt_offsets *wire_int_offsets) { int ret; struct gasket_interrupt_data *interrupt_data; - interrupt_data = kzalloc( - sizeof(struct gasket_interrupt_data), GFP_KERNEL); + interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data), + GFP_KERNEL); if (!interrupt_data) return -ENOMEM; gasket_dev->interrupt_data = interrupt_data; @@ -402,14 +398,14 @@ int gasket_interrupt_init( } gasket_interrupt_setup(gasket_dev); - gasket_sysfs_create_entries( - gasket_dev->dev_info.device, interrupt_sysfs_attrs); + gasket_sysfs_create_entries(gasket_dev->dev_info.device, + interrupt_sysfs_attrs); return 0; } -static void gasket_interrupt_msix_cleanup( - struct gasket_interrupt_data *interrupt_data) +static void +gasket_interrupt_msix_cleanup(struct gasket_interrupt_data *interrupt_data) { int i; @@ -528,9 +524,8 @@ int gasket_interrupt_system_status(struct gasket_dev *gasket_dev) return GASKET_STATUS_ALIVE; } -int gasket_interrupt_set_eventfd( - struct gasket_interrupt_data *interrupt_data, int interrupt, - int event_fd) +int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data, + int interrupt, int event_fd) { struct eventfd_ctx *ctx = eventfd_ctx_fdget(event_fd); @@ -544,8 +539,8 @@ int gasket_interrupt_set_eventfd( return 0; } -int gasket_interrupt_clear_eventfd( - struct gasket_interrupt_data *interrupt_data, int interrupt) +int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data, + int interrupt) { if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts) return -EINVAL; diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h index 805fee64569f..835af439e96a 100644 --- a/drivers/staging/gasket/gasket_interrupt.h +++ b/drivers/staging/gasket/gasket_interrupt.h @@ -43,11 +43,11 @@ struct gasket_interrupt_data; * are not possible to set up, but is otherwise OK; that device will report * status LAMED.) */ -int gasket_interrupt_init( - struct gasket_dev *gasket_dev, const char *name, int type, - const struct gasket_interrupt_desc *interrupts, - int num_interrupts, int pack_width, int bar_index, - const struct gasket_wire_interrupt_offsets *wire_int_offsets); +int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, + int type, + const struct gasket_interrupt_desc *interrupts, + int num_interrupts, int pack_width, int bar_index, + const struct gasket_wire_interrupt_offsets *wire_int_offsets); /* * Clean up a device's interrupt structure. @@ -87,9 +87,8 @@ int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev); * * Returns 0 on success, a negative error code otherwise. */ -int gasket_interrupt_set_eventfd( - struct gasket_interrupt_data *interrupt_data, int interrupt, - int event_fd); +int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data, + int interrupt, int event_fd); /* * Removes an interrupt-eventfd association. @@ -98,8 +97,8 @@ int gasket_interrupt_set_eventfd( * * Removes any eventfd associated with the specified interrupt, if any. */ -int gasket_interrupt_clear_eventfd( - struct gasket_interrupt_data *interrupt_data, int interrupt); +int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data, + int interrupt); /* * The below functions exist for backwards compatibility. From 953105453b1aeb45d15a4c053fdc911f039b097b Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:44 -0700 Subject: [PATCH 760/903] staging: gasket: TODO: remove entry for multi-line alignment style Multi-line alignment formatting issues fixed, remove the TODO entry for this. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/TODO | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO index 6aa2a7f6bc4b..6ff8e01b04cc 100644 --- a/drivers/staging/gasket/TODO +++ b/drivers/staging/gasket/TODO @@ -4,9 +4,6 @@ staging directory. - Use misc interface instead of major number for driver version description. - Add descriptions of module_param's - apex_get_status() should actually check status. -- Fix multi-line alignment formatting to look like: - int ret = long_function_name(device, VARIABLE1, VARIABLE2, - VARIABLE3, VARIABLE4); - "drivers" should never be dealing with "raw" sysfs calls or mess around with kobjects at all. The driver core should handle all of this for you automaically. There should not be a need for raw attribute macros. From 4287dbaa7c3ef0db9d8258c9f505b4149c21a393 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:45 -0700 Subject: [PATCH 761/903] staging: gasket: apex: move driver-private defines out of apex.h apex.h is supposed to contain kernel-userspace interface definitions, but has a number of defines that are only used by apex_driver.c or are not used at all. Move driver implementation defines not shared with userspace to the driver source. Remove unused defines. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex.h | 62 +--------------------------- drivers/staging/gasket/apex_driver.c | 29 +++++++++++++ 2 files changed, 31 insertions(+), 60 deletions(-) diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h index d89cc2387b7d..3bbceffff5e4 100644 --- a/drivers/staging/gasket/apex.h +++ b/drivers/staging/gasket/apex.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Apex kernel-userspace interface definition(s). + * Apex kernel-userspace interface definitions. * * Copyright (C) 2018 Google, Inc. */ @@ -8,66 +8,8 @@ #define __APEX_H__ #include -#include -#include "gasket.h" - -/* Structural definitions/macros. */ -/* The number of PCI BARs. */ -#define APEX_NUM_BARS 3 - -/* Size of a memory page in bytes, and the related number of bits to shift. */ -#define APEX_PAGE_SHIFT 12 -#define APEX_PAGE_SIZE BIT(APEX_PAGE_SHIFT) - -#define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */ - -/* - * Addresses are 2^3=8 bytes each. Page in second level page table holds - * APEX_PAGE_SIZE/8 addresses. - */ -#define APEX_ADDR_SHIFT 3 -#define APEX_LEVEL_SHIFT (APEX_PAGE_SHIFT - APEX_ADDR_SHIFT) -#define APEX_LEVEL_SIZE BIT(APEX_LEVEL_SHIFT) - -#define APEX_PAGE_TABLE_MAX 65536 -#define APEX_SIMPLE_PAGE_MAX APEX_PAGE_TABLE_MAX -#define APEX_EXTENDED_PAGE_MAX (APEX_PAGE_TABLE_MAX << APEX_LEVEL_SHIFT) - -/* Check reset 120 times */ -#define APEX_RESET_RETRY 120 -/* Wait 100 ms between checks. Total 12 sec wait maximum. */ -#define APEX_RESET_DELAY 100 - -#define APEX_CHIP_INIT_DONE 2 -#define APEX_RESET_ACCEPTED 0 - -enum apex_reset_types { - APEX_CHIP_REINIT_RESET = 3, -}; - -/* Interrupt defines */ -/* Gasket device interrupts enums must be dense (i.e., no empty slots). */ -enum apex_interrupt { - APEX_INTERRUPT_INSTR_QUEUE = 0, - APEX_INTERRUPT_INPUT_ACTV_QUEUE = 1, - APEX_INTERRUPT_PARAM_QUEUE = 2, - APEX_INTERRUPT_OUTPUT_ACTV_QUEUE = 3, - APEX_INTERRUPT_SC_HOST_0 = 4, - APEX_INTERRUPT_SC_HOST_1 = 5, - APEX_INTERRUPT_SC_HOST_2 = 6, - APEX_INTERRUPT_SC_HOST_3 = 7, - APEX_INTERRUPT_TOP_LEVEL_0 = 8, - APEX_INTERRUPT_TOP_LEVEL_1 = 9, - APEX_INTERRUPT_TOP_LEVEL_2 = 10, - APEX_INTERRUPT_TOP_LEVEL_3 = 11, - APEX_INTERRUPT_FATAL_ERR = 12, - APEX_INTERRUPT_COUNT = 13, -}; - -/* - * Clock Gating ioctl. - */ +/* Clock Gating ioctl. */ struct apex_gate_clock_ioctl { /* Enter or leave clock gated state. */ u64 enable; diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index c0d3922e1d7c..dfbff47b4608 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -54,6 +54,17 @@ */ #define APEX_PAGE_TABLE_TOTAL_ENTRIES 8192 +#define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */ + +enum apex_reset_types { + APEX_CHIP_REINIT_RESET = 3, +}; + +/* Check reset 120 times */ +#define APEX_RESET_RETRY 120 +/* Wait 100 ms between checks. Total 12 sec wait maximum. */ +#define APEX_RESET_DELAY 100 + /* Enumeration of the supported sysfs entries. */ enum sysfs_attribute_type { ATTR_KERNEL_HIB_PAGE_TABLE_SIZE, @@ -133,6 +144,24 @@ static const struct gasket_mappable_region mappable_regions[NUM_REGIONS] = { static const struct gasket_mappable_region cm_mappable_regions[1] = { { 0x0, APEX_CH_MEM_BYTES } }; +/* Gasket device interrupts enums must be dense (i.e., no empty slots). */ +enum apex_interrupt { + APEX_INTERRUPT_INSTR_QUEUE = 0, + APEX_INTERRUPT_INPUT_ACTV_QUEUE = 1, + APEX_INTERRUPT_PARAM_QUEUE = 2, + APEX_INTERRUPT_OUTPUT_ACTV_QUEUE = 3, + APEX_INTERRUPT_SC_HOST_0 = 4, + APEX_INTERRUPT_SC_HOST_1 = 5, + APEX_INTERRUPT_SC_HOST_2 = 6, + APEX_INTERRUPT_SC_HOST_3 = 7, + APEX_INTERRUPT_TOP_LEVEL_0 = 8, + APEX_INTERRUPT_TOP_LEVEL_1 = 9, + APEX_INTERRUPT_TOP_LEVEL_2 = 10, + APEX_INTERRUPT_TOP_LEVEL_3 = 11, + APEX_INTERRUPT_FATAL_ERR = 12, + APEX_INTERRUPT_COUNT = 13, +}; + /* Interrupt descriptors for Apex */ static struct gasket_interrupt_desc apex_interrupts[] = { { From e02fed16b3f430d89cdb9b2eda69906dafb507b3 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:46 -0700 Subject: [PATCH 762/903] staging: gasket: core: use bool type for ns_capable result When gasket core was converted from using capable() to use ns_capable() instead, the type of the variable holding the result should have been converted from int to bool. Reported-by: Dmitry Torokhov Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 44344528cd88..f76f4a0ecbac 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1191,7 +1191,7 @@ static int gasket_open(struct inode *inode, struct file *filp) struct gasket_cdev_info *dev_info = container_of(inode->i_cdev, struct gasket_cdev_info, cdev); struct pid_namespace *pid_ns = task_active_pid_ns(current); - int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); + bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; @@ -1270,7 +1270,7 @@ static int gasket_release(struct inode *inode, struct file *file) struct gasket_cdev_info *dev_info = container_of(inode->i_cdev, struct gasket_cdev_info, cdev); struct pid_namespace *pid_ns = task_active_pid_ns(current); - int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); + bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN); gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; From d29f6c19b0d4f71ee72e4e2b387c3d08666a6a18 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:47 -0700 Subject: [PATCH 763/903] Revert "staging: gasket: page table: hold references to device and pci_dev" gasket_free_dev() is called only from driver PCI probe and remove function. It is guaranteed that that pci_dev structure is not going anywhere during that time; there is no need to take this additional reference. This reverts commit dd9d1502feea3c23d412f289aad79e1d4e86d45d. Reported-by: Dmitry Torokhov Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 13e1d0952a47..ed6ab3c5f038 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -280,7 +280,7 @@ int gasket_page_table_init(struct gasket_page_table **ppg_tbl, pg_tbl->extended_offset_reg = (u64 __iomem *)&bar_data->virt_base[page_table_config->extended_reg]; pg_tbl->device = get_device(device); - pg_tbl->pci_dev = pci_dev_get(pci_dev); + pg_tbl->pci_dev = pci_dev; dev_dbg(device, "Page table initialized successfully\n"); @@ -378,7 +378,6 @@ void gasket_page_table_cleanup(struct gasket_page_table *pg_tbl) pg_tbl->entries = NULL; put_device(pg_tbl->device); - pci_dev_put(pg_tbl->pci_dev); kfree(pg_tbl); } From 799d8a8e0500ec782fb9fe8c95ded67e80ad4346 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Tue, 31 Jul 2018 13:24:48 -0700 Subject: [PATCH 764/903] staging: gasket: page table: fix header file include guard symbol The include guard symbol for gasket_page_table.h is out-of-date. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h index 00c06f050eb9..7b01b73ea3e7 100644 --- a/drivers/staging/gasket/gasket_page_table.h +++ b/drivers/staging/gasket/gasket_page_table.h @@ -9,8 +9,8 @@ * Copyright (C) 2018 Google, Inc. */ -#ifndef __GASKET_ADDR_TRNSL_H__ -#define __GASKET_ADDR_TRNSL_H__ +#ifndef __GASKET_PAGE_TABLE_H__ +#define __GASKET_PAGE_TABLE_H__ #include #include @@ -246,4 +246,4 @@ void gasket_free_coherent_memory_all(struct gasket_dev *gasket_dev, int gasket_set_user_virt(struct gasket_dev *gasket_dev, uint64_t size, dma_addr_t dma_address, ulong vma); -#endif +#endif /* __GASKET_PAGE_TABLE_H__ */ From 548b9f03f007ae654055644cff844b2b4fd2b5d2 Mon Sep 17 00:00:00 2001 From: Ivan Bornyakov Date: Wed, 1 Aug 2018 21:37:44 +0300 Subject: [PATCH 765/903] staging: gasket: sysfs: fix potential null dereference Add handling of possible allocation failure. Reported by smatch: drivers/staging/gasket/gasket_sysfs.c:105 put_mapping() error: potential null dereference 'files_to_remove'. (kcalloc returns null) Signed-off-by: Ivan Bornyakov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index a4bfca43cd03..56d62aea5111 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -101,6 +101,11 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) files_to_remove = kcalloc(num_files_to_remove, sizeof(*files_to_remove), GFP_KERNEL); + if (!files_to_remove) { + mutex_unlock(&mapping->mutex); + return; + } + for (i = 0; i < num_files_to_remove; i++) files_to_remove[i] = mapping->attributes[i].attr; From ba67f54d911c3da6fc284b4a9cf30ca1a27591e6 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Fri, 20 Jul 2018 10:17:30 -0700 Subject: [PATCH 766/903] staging: vboxvideo: Pass a new framebuffer to vbox_crtc_do_set_base This modifies vbox_crtc_do_set_base() to take a new framebuffer to be activated, instead of the existing framebuffer attached to the crtc. This change allows the function to be given the new framebuffer from a page-flip request. Signed-off-by: Steve Longerbeam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_mode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 5c7ea237893e..7295491d3f21 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -222,7 +222,9 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) } static int vbox_crtc_do_set_base(struct drm_crtc *crtc, - struct drm_framebuffer *old_fb, int x, int y) + struct drm_framebuffer *old_fb, + struct drm_framebuffer *new_fb, + int x, int y) { struct vbox_private *vbox = crtc->dev->dev_private; struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc); @@ -245,7 +247,7 @@ static int vbox_crtc_do_set_base(struct drm_crtc *crtc, vbox_bo_unreserve(bo); } - vbox_fb = to_vbox_framebuffer(CRTC_FB(crtc)); + vbox_fb = to_vbox_framebuffer(new_fb); obj = vbox_fb->obj; bo = gem_to_vbox_bo(obj); @@ -281,7 +283,7 @@ static int vbox_crtc_do_set_base(struct drm_crtc *crtc, static int vbox_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, struct drm_framebuffer *old_fb) { - return vbox_crtc_do_set_base(crtc, old_fb, x, y); + return vbox_crtc_do_set_base(crtc, old_fb, CRTC_FB(crtc), x, y); } static int vbox_crtc_mode_set(struct drm_crtc *crtc, From 2408898e3b6c99b3ec792760989e57026cd9909d Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Fri, 20 Jul 2018 10:17:31 -0700 Subject: [PATCH 767/903] staging: vboxvideo: Add page-flip support Adds crtc page-flip support by passing the new requested framebuffer to vbox_crtc_do_set_base(). Note there is no attempt to support vblank interrupts, it's not not known how to do this in VBOX or if it is even possible. Since this page-flip implementation does not try to sync the page-flip to vertical blanking, tearing effects are possible. Signed-off-by: Steve Longerbeam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_mode.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 7295491d3f21..e157c73aac35 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -308,6 +308,31 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc, return ret; } +static int vbox_crtc_page_flip(struct drm_crtc *crtc, + struct drm_framebuffer *fb, + struct drm_pending_vblank_event *event, + uint32_t page_flip_flags, + struct drm_modeset_acquire_ctx *ctx) +{ + struct vbox_private *vbox = crtc->dev->dev_private; + struct drm_device *drm = vbox->dev; + unsigned long flags; + int rc; + + rc = vbox_crtc_do_set_base(crtc, CRTC_FB(crtc), fb, 0, 0); + if (rc) + return rc; + + spin_lock_irqsave(&drm->event_lock, flags); + + if (event) + drm_crtc_send_vblank_event(crtc, event); + + spin_unlock_irqrestore(&drm->event_lock, flags); + + return 0; +} + static void vbox_crtc_disable(struct drm_crtc *crtc) { } @@ -346,6 +371,7 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = { .reset = vbox_crtc_reset, .set_config = drm_crtc_helper_set_config, /* .gamma_set = vbox_crtc_gamma_set, */ + .page_flip = vbox_crtc_page_flip, .destroy = vbox_crtc_destroy, }; From 9abc44ba4e2f27c4d8db8cbe7e9b180c9f37e921 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 29 Jul 2018 11:36:50 +0530 Subject: [PATCH 768/903] staging: wilc1000: fix TODO to compile spi and sdio components in single module Changes to compile module component along with SPI and SDIO module. Previously 'wilc1000.ko' used to generate along with wilc-spi.ko or wilc1000-sdio.ko module. After these changes only wilc1000-spi.ko or wilc1000-sdio.ko modules are required for SPI and SDIO respectively. These changes are done to address below TODO item. - make SPI and SDIO components coexist in one build Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 3 ++- drivers/staging/wilc1000/TODO | 1 - drivers/staging/wilc1000/linux_wlan.c | 6 ++---- drivers/staging/wilc1000/wilc_debugfs.c | 7 ++----- drivers/staging/wilc1000/wilc_wlan.c | 6 ------ drivers/staging/wilc1000/wilc_wlan_if.h | 2 ++ 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index ee7e26b886a5..f7b07c0b5ce2 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_WILC1000) += wilc1000.o ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ -DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\" @@ -12,7 +11,9 @@ wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ wilc_wlan.o obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o +wilc1000-sdio-objs += $(wilc1000-objs) wilc1000-sdio-objs += wilc_sdio.o obj-$(CONFIG_WILC1000_SPI) += wilc1000-spi.o +wilc1000-spi-objs += $(wilc1000-objs) wilc1000-spi-objs += wilc_spi.o diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO index 3d82bb0a8131..6fd3a4c1004f 100644 --- a/drivers/staging/wilc1000/TODO +++ b/drivers/staging/wilc1000/TODO @@ -1,5 +1,4 @@ TODO: - rework comments and function headers(also coding style) -- make spi and sdio components coexist in one build - support soft-ap and p2p mode - support resume/suspend function diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 64c5d692d0e3..c9e771a7f7e2 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1033,8 +1033,8 @@ void wilc_netdev_cleanup(struct wilc *wilc) } kfree(wilc); + wilc_debugfs_remove(); } -EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); static const struct net_device_ops wilc_netdev_ops = { .ndo_init = mac_init_fn, @@ -1057,6 +1057,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, if (!wl) return -ENOMEM; + wilc_debugfs_init(); *wilc = wl; wl->io_type = io_type; wl->hif_func = ops; @@ -1118,6 +1119,3 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, return 0; } -EXPORT_SYMBOL_GPL(wilc_netdev_init); - -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c index 287c11b58160..ecbf3dbaec28 100644 --- a/drivers/staging/wilc1000/wilc_debugfs.c +++ b/drivers/staging/wilc1000/wilc_debugfs.c @@ -28,7 +28,6 @@ static struct dentry *wilc_dir; #define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR) static atomic_t WILC_DEBUG_LEVEL = ATOMIC_INIT(ERR); -EXPORT_SYMBOL_GPL(WILC_DEBUG_LEVEL); /* * ---------------------------------------------------------------------------- @@ -105,7 +104,7 @@ static struct wilc_debugfs_info_t debugfs_info[] = { }, }; -static int __init wilc_debugfs_init(void) +int wilc_debugfs_init(void) { int i; struct wilc_debugfs_info_t *info; @@ -121,12 +120,10 @@ static int __init wilc_debugfs_init(void) } return 0; } -module_init(wilc_debugfs_init); -static void __exit wilc_debugfs_remove(void) +void wilc_debugfs_remove(void) { debugfs_remove_recursive(wilc_dir); } -module_exit(wilc_debugfs_remove); #endif diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index ea2e77f30aeb..61dca05cc8db 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -407,7 +407,6 @@ void chip_allow_sleep(struct wilc *wilc) wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0)); wilc->hif_func->hif_write_reg(wilc, 0xfa, 0); } -EXPORT_SYMBOL_GPL(chip_allow_sleep); void chip_wakeup(struct wilc *wilc) { @@ -462,7 +461,6 @@ void chip_wakeup(struct wilc *wilc) } chip_ps_state = CHIP_WAKEDUP; } -EXPORT_SYMBOL_GPL(chip_wakeup); void wilc_chip_sleep_manually(struct wilc *wilc) { @@ -476,7 +474,6 @@ void wilc_chip_sleep_manually(struct wilc *wilc) chip_ps_state = CHIP_SLEEPING_MANUAL; release_bus(wilc, RELEASE_ONLY); } -EXPORT_SYMBOL_GPL(wilc_chip_sleep_manually); void host_wakeup_notify(struct wilc *wilc) { @@ -484,7 +481,6 @@ void host_wakeup_notify(struct wilc *wilc) wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); release_bus(wilc, RELEASE_ONLY); } -EXPORT_SYMBOL_GPL(host_wakeup_notify); void host_sleep_notify(struct wilc *wilc) { @@ -492,7 +488,6 @@ void host_sleep_notify(struct wilc *wilc) wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); release_bus(wilc, RELEASE_ONLY); } -EXPORT_SYMBOL_GPL(host_sleep_notify); int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) { @@ -869,7 +864,6 @@ void wilc_handle_isr(struct wilc *wilc) release_bus(wilc, RELEASE_ALLOW_SLEEP); } -EXPORT_SYMBOL_GPL(wilc_handle_isr); int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 buffer_size) diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 73b57fb623b6..598c8dc3d07b 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -835,4 +835,6 @@ struct wilc; int wilc_wlan_init(struct net_device *dev); u32 wilc_get_chipid(struct wilc *wilc, bool update); +int wilc_debugfs_init(void); +void wilc_debugfs_remove(void); #endif From f131bbe556fb8c765d7b84c487b92b56e56dd0fa Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 29 Jul 2018 11:36:51 +0530 Subject: [PATCH 769/903] staging: wilc1000: remove unnecessary comments and comments description Cleanup patch to remove the unnecessary comments and commented code. Also updated description for few of comments. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 4 ++-- drivers/staging/wilc1000/linux_mon.c | 15 ++++++++------- drivers/staging/wilc1000/wilc_debugfs.c | 11 ----------- drivers/staging/wilc1000/wilc_sdio.c | 10 +--------- drivers/staging/wilc1000/wilc_spi.c | 1 - drivers/staging/wilc1000/wilc_wfi_netdevice.h | 5 ----- drivers/staging/wilc1000/wilc_wlan.h | 6 ------ drivers/staging/wilc1000/wilc_wlan_cfg.c | 5 ----- 8 files changed, 11 insertions(+), 46 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index c78b51a2f841..d96014777785 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -230,7 +230,7 @@ static int wilc_enqueue_work(struct host_if_msg *msg) return 0; } -/* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as +/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as * special purpose in wilc device, so we add 1 to the index to starts from 1. * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC. */ @@ -242,7 +242,7 @@ int wilc_get_vif_idx(struct wilc_vif *vif) /* We need to minus 1 from idx which is from wilc device to get real index * of wilc->vif[], because we add 1 when pass to wilc device in the function * wilc_get_vif_idx. - * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1. + * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1). */ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) { diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index 14405bf1d8fa..fa49588bba1e 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -63,7 +63,7 @@ void wilc_wfi_monitor_rx(u8 *buff, u32 size) cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT); - cb_hdr->rate = 5; /* txrate->bitrate / 5; */ + cb_hdr->rate = 5; if (pkt_offset & IS_MGMT_STATUS_SUCCES) { /* success */ @@ -84,8 +84,8 @@ void wilc_wfi_monitor_rx(u8 *buff, u32 size) hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); hdr->hdr.it_present = cpu_to_le32 - (1 << IEEE80211_RADIOTAP_RATE); /* | */ - hdr->rate = 5; /* txrate->bitrate / 5; */ + (1 << IEEE80211_RADIOTAP_RATE); + hdr->rate = 5; } skb->dev = wilc_wfi_mon; @@ -178,7 +178,7 @@ static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb, cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT); - cb_hdr->rate = 5; /* txrate->bitrate / 5; */ + cb_hdr->rate = 5; cb_hdr->tx_flags = 0x0004; skb2->dev = wilc_wfi_mon; @@ -194,11 +194,12 @@ static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb, } skb->dev = mon_priv->real_ndev; - /* Identify if Ethernet or MAC header (data or mgmt) */ memcpy(srcadd, &skb->data[10], 6); memcpy(bssid, &skb->data[16], 6); - /* if source address and bssid fields are equal>>Mac header */ - /*send it to mgmt frames handler */ + /* + * Identify if data or mgmt packet, if source address and bssid + * fields are equal send it to mgmt frames handler + */ if (!(memcmp(srcadd, bssid, 6))) { ret = mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len); if (ret) diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c index ecbf3dbaec28..ac26e94ae097 100644 --- a/drivers/staging/wilc1000/wilc_debugfs.c +++ b/drivers/staging/wilc1000/wilc_debugfs.c @@ -18,9 +18,6 @@ static struct dentry *wilc_dir; -/* - * ---------------------------------------------------------------------------- - */ #define DEBUG BIT(0) #define INFO BIT(1) #define WRN BIT(2) @@ -29,10 +26,6 @@ static struct dentry *wilc_dir; #define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR) static atomic_t WILC_DEBUG_LEVEL = ATOMIC_INIT(ERR); -/* - * ---------------------------------------------------------------------------- - */ - static ssize_t wilc_debug_level_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) { @@ -76,10 +69,6 @@ static ssize_t wilc_debug_level_write(struct file *filp, return count; } -/* - * ---------------------------------------------------------------------------- - */ - #define FOPS(_open, _read, _write, _poll) { \ .owner = THIS_MODULE, \ .open = (_open), \ diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 8a471474a807..0628237cdcf4 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -809,9 +809,6 @@ static int sdio_read_size(struct wilc *wilc, u32 *size) wilc_sdio_cmd52(wilc, &cmd); tmp = cmd.data; - /* cmd.read_write = 0; */ - /* cmd.function = 0; */ - /* cmd.raw = 0; */ cmd.address = 0xf3; cmd.data = 0; wilc_sdio_cmd52(wilc, &cmd); @@ -1096,12 +1093,7 @@ static int sdio_sync_ext(struct wilc *wilc, int nint) return 1; } -/******************************************** - * - * Global sdio HIF function table - * - ********************************************/ - +/* Global sdio HIF function table */ static const struct wilc_hif_func wilc_hif_sdio = { .hif_init = sdio_init, .hif_deinit = sdio_deinit, diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index fa9371ba53a9..5aa1f7b701d8 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -767,7 +767,6 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) u8 clockless = 0; if (addr < 0x30) { - /* dev_err(&spi->dev, "***** read addr %d\n\n", addr); */ /* Clockless register */ cmd = CMD_INTERNAL_READ; clockless = 1; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 331a9711e31d..371a87fbf26b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -37,11 +37,6 @@ struct wilc_wfi_stats { }; -/* - * This structure is private to each device. It is used to pass - * packets in and out, so there is place for a packet - */ - struct wilc_wfi_key { u8 *key; u8 *seq; diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index f29d1ea73551..696cf1f229b6 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -246,12 +246,6 @@ struct wilc_hif_func { void (*disable_interrupt)(struct wilc *nic); }; -/******************************************** - * - * Configuration Structure - * - ********************************************/ - #define MAX_CFG_FRAME_SIZE 1468 struct wilc_cfg_frame { diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index c0b9b700f4d7..331be7b95294 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -13,11 +13,6 @@ #include "wilc_wlan_cfg.h" #include "coreconfigurator.h" -/******************************************** - * - * Global Data - * - ********************************************/ enum cfg_cmd_type { CFG_BYTE_CMD = 0, CFG_HWORD_CMD = 1, From a120adb8b6eddc1645a61a4e7a8daa0cc2f6ddd8 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 29 Jul 2018 11:36:53 +0530 Subject: [PATCH 770/903] staging: wilc1000: modified debug log messages description Cleanup patch to update the debug logs message to provide correct information. Also added the function name tag for same description log to help identify the place from where log was captured. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 134 +++++++++--------- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 13 +- drivers/staging/wilc1000/wilc_wlan.c | 9 +- 3 files changed, 80 insertions(+), 76 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index d96014777785..0df4d9c1e9a8 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -342,7 +342,8 @@ static void handle_set_operation_mode(struct work_struct *work) complete(&hif_driver_comp); if (ret) - netdev_err(vif->ndev, "Failed to set driver handler\n"); + netdev_err(vif->ndev, "Failed to set operation mode\n"); + kfree(msg); } @@ -747,7 +748,7 @@ static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) } if (!hif_drv) { - netdev_err(vif->ndev, "Driver handler is NULL\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); return result; } @@ -1155,7 +1156,7 @@ static void handle_connect_timeout(struct work_struct *work) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - netdev_err(vif->ndev, "Driver handler is NULL\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); goto out; } @@ -1187,7 +1188,7 @@ static void handle_connect_timeout(struct work_struct *work) kfree(info.req_ies); info.req_ies = NULL; } else { - netdev_err(vif->ndev, "Connect callback is NULL\n"); + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); } wid.id = WID_DISCONNECT; @@ -1400,7 +1401,8 @@ static void handle_rcvd_ntwrk_info(struct work_struct *work) wilc_parse_network_info(rcvd_info->buffer, &info); if (!info || !scan_req->scan_result) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: info or scan result NULL\n", + __func__); goto done; } @@ -1519,7 +1521,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, if (mac_status == MAC_STATUS_CONNECTED && conn_info.status != WLAN_STATUS_SUCCESS) { netdev_err(vif->ndev, - "Received MAC status is MAC_STATUS_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n"); + "Received MAC status is MAC_STATUS_CONNECTED, Assoc Resp is not SUCCESS\n"); eth_zero_addr(wilc_connected_ssid); } else if (mac_status == MAC_STATUS_DISCONNECTED) { netdev_err(vif->ndev, "Received MAC status is MAC_STATUS_DISCONNECTED\n"); @@ -1594,7 +1596,7 @@ static inline void host_int_handle_disconnect(struct wilc_vif *vif) conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL, 0, &disconn_info, hif_drv->usr_conn_req.arg); } else { - netdev_err(vif->ndev, "Connect result NULL\n"); + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); } eth_zero_addr(hif_drv->assoc_bssid); @@ -1613,12 +1615,12 @@ static void handle_rcvd_gnrl_async_info(struct work_struct *work) struct host_if_drv *hif_drv = vif->hif_drv; if (!rcvd_info->buffer) { - netdev_err(vif->ndev, "Received buffer is NULL\n"); + netdev_err(vif->ndev, "%s: buffer is NULL\n", __func__); goto free_msg; } if (!hif_drv) { - netdev_err(vif->ndev, "Driver handler is NULL\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); goto free_rcvd_info; } @@ -1626,7 +1628,8 @@ static void handle_rcvd_gnrl_async_info(struct work_struct *work) hif_drv->hif_state == HOST_IF_CONNECTED || hif_drv->usr_scan_req.scan_result) { if (!hif_drv->usr_conn_req.conn_result) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: conn_result is NULL\n", + __func__); goto free_rcvd_info; } @@ -1969,7 +1972,7 @@ static void handle_disconnect(struct work_struct *work) conn_req->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL, 0, &disconn_info, conn_req->arg); } else { - netdev_err(vif->ndev, "conn_result = NULL\n"); + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); } hif_drv->hif_state = HOST_IF_IDLE; @@ -2101,7 +2104,7 @@ static void handle_get_inactive_time(struct work_struct *work) kfree(wid.val); if (result) { - netdev_err(vif->ndev, "Failed to SET inactive time\n"); + netdev_err(vif->ndev, "Failed to set inactive mac\n"); goto out; } @@ -2293,7 +2296,7 @@ static void handle_del_all_sta(struct work_struct *work) result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - netdev_err(vif->ndev, "Failed to send add station\n"); + netdev_err(vif->ndev, "Failed to send delete all station\n"); error: kfree(wid.val); @@ -2323,7 +2326,7 @@ static void handle_del_station(struct work_struct *work) result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - netdev_err(vif->ndev, "Failed to send add station\n"); + netdev_err(vif->ndev, "Failed to del station\n"); error: kfree(wid.val); @@ -2523,7 +2526,7 @@ static void listen_timer_cb(struct timer_list *t) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } } @@ -2719,7 +2722,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) if (!hif_drv) { result = -EFAULT; - netdev_err(vif->ndev, "Failed to send setup multicast\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return result; } @@ -2733,7 +2736,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) result = wilc_enqueue_work(msg); if (result) - netdev_err(vif->ndev, "Request to remove WEP key\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); else wait_for_completion(&msg->work_comp); @@ -2749,7 +2752,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) if (!hif_drv) { result = -EFAULT; - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); return result; } @@ -2763,7 +2766,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) result = wilc_enqueue_work(msg); if (result) - netdev_err(vif->ndev, "Default key index\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); else wait_for_completion(&msg->work_comp); @@ -2779,7 +2782,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -2820,7 +2823,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); return -EFAULT; } @@ -2865,7 +2868,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, u8 key_len = ptk_key_len; if (!hif_drv) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -2907,7 +2910,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "PTK Key\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); goto free_key; } @@ -2932,7 +2935,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, u8 key_len = gtk_key_len; if (!hif_drv) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -2985,7 +2988,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "RX GTK\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); goto free_key; } @@ -3025,7 +3028,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "PMKID Info\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3045,7 +3048,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) result = wilc_enqueue_work(msg); if (result) - netdev_err(vif->ndev, "Failed to send get mac address\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); else wait_for_completion(&msg->work_comp); @@ -3065,12 +3068,14 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv || !connect_result) { - netdev_err(vif->ndev, "Driver is null\n"); + netdev_err(vif->ndev, + "%s: hif driver or connect result is NULL", + __func__); return -EFAULT; } if (!join_params) { - netdev_err(vif->ndev, "Unable to Join - JoinParams is NULL\n"); + netdev_err(vif->ndev, "%s: joinparams is NULL\n", __func__); return -EFAULT; } @@ -3115,7 +3120,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "send message: Set join request\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); goto free_ies; } @@ -3146,7 +3151,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - netdev_err(vif->ndev, "Driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -3156,7 +3161,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) result = wilc_enqueue_work(msg); if (result) - netdev_err(vif->ndev, "Failed to send message: disconnect\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); else wait_for_completion(&msg->work_comp); @@ -3177,7 +3182,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc mq send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3200,7 +3205,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc mq send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3219,7 +3224,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) msg->body.mode.mode = mode; result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc mq send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3234,7 +3239,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -3246,7 +3251,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, result = wilc_enqueue_work(msg); if (result) - netdev_err(vif->ndev, "Failed to send get host ch param\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); else wait_for_completion(&msg->work_comp); @@ -3262,7 +3267,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) struct host_if_msg *msg; if (!rssi_level) { - netdev_err(vif->ndev, "RSS pointer value is null\n"); + netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__); return -EFAULT; } @@ -3278,7 +3283,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "Failed to send get host ch param\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); } else { wait_for_completion(&msg->work_comp); *rssi_level = *msg->body.data; @@ -3304,7 +3309,7 @@ wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "Failed to send get host channel\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); return result; } @@ -3366,7 +3371,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "Error in sending message queue\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); goto free_ies; } @@ -3395,7 +3400,7 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, int result; if (!hif_drv) { - netdev_err(vif->ndev, "hif_drv NULL\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -3416,7 +3421,7 @@ static void get_periodic_rssi(struct timer_list *unused) struct wilc_vif *vif = periodic_rssi_vif; if (!vif->hif_drv) { - netdev_err(vif->ndev, "Driver handler is NULL\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return; } @@ -3494,7 +3499,7 @@ int wilc_deinit(struct wilc_vif *vif) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - netdev_err(vif->ndev, "hif_drv = NULL\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -3578,7 +3583,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "message parameters (%d)\n", result); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg->body.net_info.buffer); kfree(msg); } @@ -3612,7 +3617,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) } if (!hif_drv->usr_conn_req.conn_result) { - netdev_err(vif->ndev, "there is no current Connect Request\n"); + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); mutex_unlock(&hif_deinit_lock); return; } @@ -3633,7 +3638,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "synchronous info (%d)\n", result); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg->body.async_info.buffer); kfree(msg); } @@ -3669,7 +3674,8 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "complete param (%d)\n", result); + netdev_err(vif->ndev, "%s: enqueue work failed\n", + __func__); kfree(msg); } } @@ -3697,7 +3703,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc mq send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3711,7 +3717,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - netdev_err(vif->ndev, "driver is null\n"); + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } @@ -3725,7 +3731,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc mq send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3758,7 +3764,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc mq send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3799,7 +3805,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, result = wilc_enqueue_work(msg); if (result) - netdev_err(vif->ndev, "wilc mq send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); error: if (result) { @@ -3822,7 +3828,7 @@ int wilc_del_beacon(struct wilc_vif *vif) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -3853,7 +3859,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(add_sta_info->rates); kfree(msg); } @@ -3879,7 +3885,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } return result; @@ -3916,7 +3922,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) result = wilc_enqueue_work(msg); if (result) - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); else wait_for_completion(&msg->work_comp); @@ -3950,7 +3956,7 @@ int wilc_edit_station(struct wilc_vif *vif, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(add_sta_info->rates); kfree(msg); } @@ -3975,7 +3981,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } return result; @@ -3996,7 +4002,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } return result; @@ -4016,7 +4022,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -4037,7 +4043,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) result = wilc_enqueue_work(msg); if (result) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -4057,7 +4063,7 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) ret = wilc_enqueue_work(msg); if (ret) { - netdev_err(vif->ndev, "wilc_mq_send fail\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); kfree(msg); } @@ -4075,7 +4081,7 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) ret = wilc_enqueue_work(msg); if (ret) { - netdev_err(vif->ndev, "Failed to get TX PWR\n"); + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); } else { wait_for_completion(&msg->work_comp); *tx_power = msg->body.tx_power.tx_pwr; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 42c01280ff91..0eb271503c7c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -741,7 +741,8 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, security = ENCRYPT_ENABLED | WPA | AES; } else { ret = -ENOTSUPP; - netdev_err(dev, "Not supported cipher\n"); + netdev_err(dev, "%s: Unsupported cipher\n", + __func__); wilc_connecting = 0; return ret; } @@ -995,7 +996,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, break; default: - netdev_err(netdev, "Not supported cipher\n"); + netdev_err(netdev, "%s: Unsupported cipher\n", __func__); ret = -ENOTSUPP; } @@ -1413,8 +1414,8 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) default: netdev_dbg(dev, - "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", - buff[ACTION_SUBTYPE_ID]); + "%s: Not handled action frame type:%x\n", + __func__, buff[ACTION_SUBTYPE_ID]); break; } } @@ -1620,8 +1621,8 @@ static int mgmt_tx(struct wiphy *wiphy, default: netdev_dbg(vif->ndev, - "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", - buf[ACTION_SUBTYPE_ID]); + "%s: Not handled action frame type:%x\n", + __func__, buf[ACTION_SUBTYPE_ID]); break; } } diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 61dca05cc8db..6bac3f7de710 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1148,10 +1148,7 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, if (!commit) return ret_size; - netdev_dbg(vif->ndev, - "[WILC]PACKET Commit with sequence number %d\n", - wilc->cfg_seq_no); - netdev_dbg(vif->ndev, "Processing cfg_set()\n"); + netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no); wilc->cfg_frame_in_use = 1; if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler)) @@ -1159,7 +1156,7 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, if (!wait_for_completion_timeout(&wilc->cfg_event, msecs_to_jiffies(CFG_PKTS_TIMEOUT))) { - netdev_dbg(vif->ndev, "Set Timed Out\n"); + netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); ret_size = 0; } @@ -1198,7 +1195,7 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, if (!wait_for_completion_timeout(&wilc->cfg_event, msecs_to_jiffies(CFG_PKTS_TIMEOUT))) { - netdev_dbg(vif->ndev, "Get Timed Out\n"); + netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); ret_size = 0; } wilc->cfg_frame_in_use = 0; From 97ed6d34e31275fef331c6520cc9b983b678d334 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 29 Jul 2018 11:36:54 +0530 Subject: [PATCH 771/903] staging: wilc1000: added comments for 'hif_cs' mutex lock Added comments for 'hif_cs' mutex to avoid checkpatch.pl reported issues. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 371a87fbf26b..a0e2e11c1c39 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -130,6 +130,7 @@ struct wilc { spinlock_t txq_spinlock; /*protect rxq_entry_t receiver queue*/ struct mutex rxq_cs; + /* lock to protect hif access */ struct mutex hif_cs; struct completion cfg_event; From 49328076f6f93bae8376dfb7a19143f613da6f52 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 29 Jul 2018 11:36:55 +0530 Subject: [PATCH 772/903] staging: wilc1000: rename 'rcvd_ch_cnt' element in 'user_scan_req' struct Cleanup patch to use shorter name for 'rcvd_ch_cnt' to 'ch_cnt' to avoid line over 80 character issue reported by checkpatch. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 12 ++++++------ drivers/staging/wilc1000/host_interface.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0df4d9c1e9a8..86d8aafafb06 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -792,7 +792,7 @@ static void handle_scan(struct work_struct *work) goto error; } - hif_drv->usr_scan_req.rcvd_ch_cnt = 0; + hif_drv->usr_scan_req.ch_cnt = 0; wid_list[index].id = WID_SSID_PROBE_REQ; wid_list[index].type = WID_STR; @@ -1406,7 +1406,7 @@ static void handle_rcvd_ntwrk_info(struct work_struct *work) goto done; } - for (i = 0; i < scan_req->rcvd_ch_cnt; i++) { + for (i = 0; i < scan_req->ch_cnt; i++) { if (memcmp(scan_req->net_info[i].bssid, info->bssid, 6) == 0) { if (info->rssi <= scan_req->net_info[i].rssi) { goto done; @@ -1419,13 +1419,13 @@ static void handle_rcvd_ntwrk_info(struct work_struct *work) } if (found) { - if (scan_req->rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) { - scan_req->net_info[scan_req->rcvd_ch_cnt].rssi = info->rssi; + if (scan_req->ch_cnt < MAX_NUM_SCANNED_NETWORKS) { + scan_req->net_info[scan_req->ch_cnt].rssi = info->rssi; - memcpy(scan_req->net_info[scan_req->rcvd_ch_cnt].bssid, + memcpy(scan_req->net_info[scan_req->ch_cnt].bssid, info->bssid, 6); - scan_req->rcvd_ch_cnt++; + scan_req->ch_cnt++; info->new_network = true; params = host_int_parse_join_bss_param(info); diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 9a016c56a62f..3ddeec2f2f1f 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -199,7 +199,7 @@ struct hidden_network { struct user_scan_req { wilc_scan_result scan_result; void *arg; - u32 rcvd_ch_cnt; + u32 ch_cnt; struct found_net_info net_info[MAX_NUM_SCANNED_NETWORKS]; }; From 7878abdec92040e8c20ff3f1b8f8ab35d8dafc5b Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 1 Aug 2018 10:33:41 +0530 Subject: [PATCH 773/903] staging: wilc1000: refactor wilc_wlan_handle_isr_ext to avoid goto statement Refactor wilc_wlan_handle_isr_ext() to avoid the use of the goto label. Also avoid the unnecessary NULL check for 'wilc->rx_buffer' and calling wilc_wlan_handle_rxq() only after wilc_wlan_rxq_add() call. The link [1] contains details for discussion related to this changes. [1]. https://patchwork.kernel.org/patch/10533601/ Signed-off-by: Ajay Singh Suggested-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan.c | 41 +++++++++++++--------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 6bac3f7de710..eb5f32f6d607 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -815,31 +815,28 @@ static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status) retries++; } - if (size > 0) { - if (LINUX_RX_SIZE - offset < size) - offset = 0; + if (size <= 0) + return; - if (wilc->rx_buffer) - buffer = &wilc->rx_buffer[offset]; - else - goto end; + if (LINUX_RX_SIZE - offset < size) + offset = 0; - wilc->hif_func->hif_clear_int_ext(wilc, - DATA_INT_CLR | ENABLE_RX_VMM); - ret = wilc->hif_func->hif_block_rx_ext(wilc, 0, buffer, size); + buffer = &wilc->rx_buffer[offset]; -end: - if (ret) { - offset += size; - wilc->rx_buffer_offset = offset; - rqe = kmalloc(sizeof(*rqe), GFP_KERNEL); - if (rqe) { - rqe->buffer = buffer; - rqe->buffer_size = size; - wilc_wlan_rxq_add(wilc, rqe); - } - } - } + wilc->hif_func->hif_clear_int_ext(wilc, DATA_INT_CLR | ENABLE_RX_VMM); + ret = wilc->hif_func->hif_block_rx_ext(wilc, 0, buffer, size); + if (!ret) + return; + + offset += size; + wilc->rx_buffer_offset = offset; + rqe = kmalloc(sizeof(*rqe), GFP_KERNEL); + if (!rqe) + return; + + rqe->buffer = buffer; + rqe->buffer_size = size; + wilc_wlan_rxq_add(wilc, rqe); wilc_wlan_handle_rxq(wilc); } From 41203a451b6c9f6458195d9c0de964bf33c52e93 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 1 Aug 2018 16:40:59 +0530 Subject: [PATCH 774/903] staging: wilc1000: use 'u16' data type for config id parameter Cleanup patch to use the correct data type 'u16' for keeping the WID value in 'wilc_cfg_word' & 'wilc_cfg_str' structure. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan_cfg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h b/drivers/staging/wilc1000/wilc_wlan_cfg.h index 08092a551840..2aa7a9beb8d2 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.h +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.h @@ -22,12 +22,12 @@ struct wilc_cfg_hword { }; struct wilc_cfg_word { - u32 id; + u16 id; u32 val; }; struct wilc_cfg_str { - u32 id; + u16 id; u8 *str; }; From 02211edc9a1f71942a67d545614f8c7382230de7 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 1 Aug 2018 16:41:00 +0530 Subject: [PATCH 775/903] staging: wilc1000: fix endianness warnings reported by sparse This patch fixes the sparse warnings by making use of le32_to_cpus() & cpu_to_le32s() conversion API's. Remove the unnecessary byte-order conversion in wilc_wlan_parse_response_frame() as the data is copied using individual byte operation. Also added the byte-order conversion for 'header' in wilc_wfi_monitor_rx() & wilc_wfi_p2p_rx() as received in LE byte-order. The link [1] contains the details of discussion related to this patch. [1]. https://patchwork.kernel.org/patch/10436791/ Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_mon.c | 1 + drivers/staging/wilc1000/wilc_sdio.c | 4 ++-- drivers/staging/wilc1000/wilc_spi.c | 8 +++---- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 6 ++++-- drivers/staging/wilc1000/wilc_wlan.c | 12 +++++------ drivers/staging/wilc1000/wilc_wlan_cfg.c | 21 +++++++++---------- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index fa49588bba1e..9d12a9111213 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -39,6 +39,7 @@ void wilc_wfi_monitor_rx(u8 *buff, u32 size) /* Get WILC header */ memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); + le32_to_cpus(&header); /* * The packet offset field contain info about what type of management * the frame we are dealing with and ack status diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 0628237cdcf4..8bda55018e3e 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -384,7 +384,7 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) struct sdio_func *func = dev_to_sdio_func(wilc->dev); int ret; - data = cpu_to_le32(data); + cpu_to_le32s(&data); if (addr >= 0xf0 && addr <= 0xff) { struct sdio_cmd52 cmd; @@ -563,7 +563,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) } } - *data = cpu_to_le32(*data); + le32_to_cpus(*data); return 1; diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 5aa1f7b701d8..064892d5f132 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -678,7 +678,7 @@ static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat) struct spi_device *spi = to_spi_device(wilc->dev); int result; - dat = cpu_to_le32(dat); + cpu_to_le32s(&dat); result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4, 0); if (result != N_OK) @@ -699,7 +699,7 @@ static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data) return 0; } - *data = cpu_to_le32(*data); + le32_to_cpus(*data); return 1; } @@ -717,7 +717,7 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data) u8 cmd = CMD_SINGLE_WRITE; u8 clockless = 0; - data = cpu_to_le32(data); + cpu_to_le32s(&data); if (addr < 0x30) { /* Clockless register */ cmd = CMD_INTERNAL_WRITE; @@ -778,7 +778,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) return 0; } - *data = cpu_to_le32(*data); + le32_to_cpus(*data); return 1; } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 0eb271503c7c..0caf89699781 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1364,9 +1364,10 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) struct host_if_drv *wfi_drv = priv->hif_drv; u32 header, pkt_offset; s32 freq; + __le16 fc; memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); - + le32_to_cpus(&header); pkt_offset = GET_PKT_OFFSET(header); if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { @@ -1383,7 +1384,8 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ); - if (!ieee80211_is_action(buff[FRAME_TYPE_ID])) { + fc = ((struct ieee80211_hdr *)buff)->frame_control; + if (!ieee80211_is_action(fc)) { cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0); return; } diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index eb5f32f6d607..b9760e825dd5 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -536,7 +536,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) vmm_table[i] = vmm_sz / 4; if (tqe->type == WILC_CFG_PKT) vmm_table[i] |= BIT(10); - vmm_table[i] = cpu_to_le32(vmm_table[i]); + cpu_to_le32s(&vmm_table[i]); i++; sum += vmm_sz; @@ -639,7 +639,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) if (vmm_table[i] == 0) break; - vmm_table[i] = cpu_to_le32(vmm_table[i]); + le32_to_cpus(&vmm_table[i]); vmm_sz = (vmm_table[i] & 0x3ff); vmm_sz *= 4; header = (tqe->type << 31) | @@ -650,7 +650,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) else header &= ~BIT(30); - header = cpu_to_le32(header); + cpu_to_le32s(&header); memcpy(&txb[offset], &header, 4); if (tqe->type == WILC_CFG_PKT) { buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; @@ -705,7 +705,7 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size) do { buff_ptr = buffer + offset; memcpy(&header, buff_ptr, 4); - header = cpu_to_le32(header); + le32_to_cpus(&header); is_cfg_packet = (header >> 31) & 0x1; pkt_offset = (header >> 22) & 0x1ff; @@ -880,8 +880,8 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, do { memcpy(&addr, &buffer[offset], 4); memcpy(&size, &buffer[offset + 4], 4); - addr = cpu_to_le32(addr); - size = cpu_to_le32(size); + le32_to_cpus(&addr); + le32_to_cpus(&size); acquire_bus(wilc, ACQUIRE_ONLY); offset += 8; while (((int)size) && (offset < buffer_size)) { diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index 331be7b95294..b215f982a246 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -268,16 +268,17 @@ static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 size) * ********************************************/ +#define GET_WID_TYPE(wid) (((wid) >> 12) & 0x7) static void wilc_wlan_parse_response_frame(u8 *info, int size) { - u32 wid, len = 0, i = 0; + u16 wid; + u32 len = 0, i = 0; while (size > 0) { i = 0; wid = info[0] | (info[1] << 8); - wid = cpu_to_le32(wid); - switch ((wid >> 12) & 0x7) { + switch (GET_WID_TYPE(wid)) { case WID_CHAR: do { if (g_cfg_byte[i].id == WID_NIL) @@ -298,9 +299,8 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size) break; if (g_cfg_hword[i].id == wid) { - g_cfg_hword[i].val = - cpu_to_le16(info[4] | - (info[5] << 8)); + g_cfg_hword[i].val = (info[4] | + (info[5] << 8)); break; } i++; @@ -314,11 +314,10 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size) break; if (g_cfg_word[i].id == wid) { - g_cfg_word[i].val = - cpu_to_le32(info[4] | - (info[5] << 8) | - (info[6] << 16) | - (info[7] << 24)); + g_cfg_word[i].val = (info[4] | + (info[5] << 8) | + (info[6] << 16) | + (info[7] << 24)); break; } i++; From 90615f9f173a3c796c1c07ca61e98381b9ad1d35 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 31 Jul 2018 12:02:46 -0500 Subject: [PATCH 776/903] staging: fsl-dpaa2/eth: convert documentation to .rst format Convert the DPAA2 Ethernet driver documentation to .rst format and rename the file accordingly. Also add a SPDX tag to the new rst file. Signed-off-by: Ioana Ciornei Signed-off-by: Greg Kroah-Hartman --- .../ethernet/{README => ethernet-driver.rst} | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) rename drivers/staging/fsl-dpaa2/ethernet/{README => ethernet-driver.rst} (94%) diff --git a/drivers/staging/fsl-dpaa2/ethernet/README b/drivers/staging/fsl-dpaa2/ethernet/ethernet-driver.rst similarity index 94% rename from drivers/staging/fsl-dpaa2/ethernet/README rename to drivers/staging/fsl-dpaa2/ethernet/ethernet-driver.rst index e3b5c90197e4..90ec940749e8 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/README +++ b/drivers/staging/fsl-dpaa2/ethernet/ethernet-driver.rst @@ -1,17 +1,14 @@ -Freescale DPAA2 Ethernet driver +.. SPDX-License-Identifier: GPL-2.0 +.. include:: + +=============================== +DPAA2 Ethernet driver =============================== +:Copyright: |copy| 2017-2018 NXP + This file provides documentation for the Freescale DPAA2 Ethernet driver. - -Contents -======== - Supported Platforms - Architecture Overview - Creating a Network Interface - Features & Offloads - - Supported Platforms =================== This driver provides networking support for Freescale DPAA2 SoCs, e.g. @@ -23,10 +20,11 @@ Architecture Overview Unlike regular NICs, in the DPAA2 architecture there is no single hardware block representing network interfaces; instead, several separate hardware resources concur to provide the networking functionality: - - network interfaces - - queues, channels - - buffer pools - - MAC/PHY + +- network interfaces +- queues, channels +- buffer pools +- MAC/PHY All hardware resources are allocated and configured through the Management Complex (MC) portals. MC abstracts most of these resources as DPAA2 objects @@ -35,14 +33,13 @@ hardware resources, like queues, do not have a corresponding MC object and are treated as internal resources of other objects. For a more detailed description of the DPAA2 architecture and its object -abstractions see: - Documentation/networking/dpaa2/overview.rst +abstractions see *Documentation/networking/dpaa2/overview.rst*. Each Linux net device is built on top of a Datapath Network Interface (DPNI) object and uses Buffer Pools (DPBPs), I/O Portals (DPIOs) and Concentrators (DPCONs). -Configuration interface: +Configuration interface:: ----------------------- | DPAA2 Ethernet Driver | @@ -56,7 +53,7 @@ Configuration interface: | DPBP API | | DPNI API | | DPCON API | ---------- ---------- ----------- . . . software -=========== . ========== . ============ . =================== + ======= . ========== . ============ . =================== . . . hardware ------------------------------------------ | MC hardware portals | @@ -72,11 +69,11 @@ DPBPs represent hardware buffer pools. Packet I/O is performed in the context of DPCON objects, using DPIO portals for managing and communicating with the hardware resources. -Datapath (I/O) interface: +Datapath (I/O) interface:: ----------------------------------------------- | DPAA2 Ethernet Driver | - ----------------------------------------------- + ----------------------------------------------- | ^ ^ | | | | | | | enqueue| dequeue| data | dequeue| seed | @@ -132,6 +129,8 @@ DPNIs are decoupled from PHYs; a DPNI can be connected to a PHY through a DPMAC object or to another DPNI through an internal link, but the connection is managed by MC and completely transparent to the Ethernet driver. +:: + --------- --------- --------- | eth if1 | | eth if2 | | eth ifn | --------- --------- --------- From 0bb29b25a008fe9d3a0f1ad3f9773225add35f08 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 31 Jul 2018 12:02:47 -0500 Subject: [PATCH 777/903] staging: fsl-dpaa2/eth: add SPDX license identifiers The DPAA2 Ethernet driver files use a GPL-2.0+ OR BSD-3-Clause license. Add SPDX tags and delete the full license text, keeping the existing licenses for each file. Add a GPL-2.0 tag for the Makefile. Signed-off-by: Ioana Ciornei Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/Makefile | 1 + .../fsl-dpaa2/ethernet/dpaa2-eth-trace.h | 29 +----------------- .../staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 29 +----------------- .../staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 29 +----------------- .../fsl-dpaa2/ethernet/dpaa2-ethtool.c | 29 +----------------- drivers/staging/fsl-dpaa2/ethernet/dpkg.h | 30 +------------------ drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h | 30 +------------------ drivers/staging/fsl-dpaa2/ethernet/dpni.c | 30 +------------------ drivers/staging/fsl-dpaa2/ethernet/dpni.h | 30 +------------------ drivers/staging/fsl-dpaa2/ethernet/net.h | 30 +------------------ 10 files changed, 10 insertions(+), 257 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/Makefile b/drivers/staging/fsl-dpaa2/ethernet/Makefile index 77b0b74f835a..9315ecdba612 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/Makefile +++ b/drivers/staging/fsl-dpaa2/ethernet/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 # # Makefile for the Freescale DPAA2 Ethernet controller # diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h index 3b040e8d6a4e..9801528db2a5 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h @@ -1,32 +1,5 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ /* Copyright 2014-2015 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #undef TRACE_SYSTEM diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 41dd6d88ffc6..e2dac44eccbe 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -1,33 +1,6 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* Copyright 2014-2016 Freescale Semiconductor Inc. * Copyright 2016-2017 NXP - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index 6cf8a4bf23a9..6b70c663a8b3 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -1,33 +1,6 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ /* Copyright 2014-2016 Freescale Semiconductor Inc. * Copyright 2016 NXP - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __DPAA2_ETH_H diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c index 8a3c3da7dd5b..8056a95e1265 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c @@ -1,33 +1,6 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* Copyright 2014-2016 Freescale Semiconductor Inc. * Copyright 2016 NXP - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h index 8057a25b1766..099ff02b4b1a 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h @@ -1,33 +1,5 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ /* Copyright 2013-2015 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the above-listed copyright holders nor the - * names of any contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. */ #ifndef __FSL_DPKG_H_ #define __FSL_DPKG_H_ diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h index d6f96f302cc6..83698abce8b4 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h @@ -1,34 +1,6 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ /* Copyright 2013-2016 Freescale Semiconductor Inc. * Copyright 2016 NXP - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the above-listed copyright holders nor the - * names of any contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FSL_DPNI_CMD_H #define _FSL_DPNI_CMD_H diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni.c b/drivers/staging/fsl-dpaa2/ethernet/dpni.c index 1a721c95a67a..d6ac26797cec 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpni.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpni.c @@ -1,34 +1,6 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* Copyright 2013-2016 Freescale Semiconductor Inc. * Copyright 2016 NXP - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the above-listed copyright holders nor the - * names of any contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. */ #include #include diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni.h b/drivers/staging/fsl-dpaa2/ethernet/dpni.h index 8eef4ee90490..b378a00c7c53 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpni.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpni.h @@ -1,34 +1,6 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ /* Copyright 2013-2016 Freescale Semiconductor Inc. * Copyright 2016 NXP - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the above-listed copyright holders nor the - * names of any contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. */ #ifndef __FSL_DPNI_H #define __FSL_DPNI_H diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h b/drivers/staging/fsl-dpaa2/ethernet/net.h index 5020dee1730c..75a2d3ad936d 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/net.h +++ b/drivers/staging/fsl-dpaa2/ethernet/net.h @@ -1,33 +1,5 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ /* Copyright 2013-2015 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the above-listed copyright holders nor the - * names of any contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. */ #ifndef __FSL_NET_H #define __FSL_NET_H From ef134e9c19797740c259cbd3834c31299580b740 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Wed, 1 Aug 2018 11:09:48 -0500 Subject: [PATCH 778/903] staging: fsl-dpaa2/eth: Cleanup comments Comments in file net.h are too fancy for their own good, so convert them to the regular format. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/net.h | 76 ++++++++++++------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h b/drivers/staging/fsl-dpaa2/ethernet/net.h index 75a2d3ad936d..ddea9400d265 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/net.h +++ b/drivers/staging/fsl-dpaa2/ethernet/net.h @@ -6,11 +6,9 @@ #define LAST_HDR_INDEX 0xFFFFFFFF -/*****************************************************************************/ -/* Protocol fields */ -/*****************************************************************************/ +/* Protocol fields */ -/************************* Ethernet fields *********************************/ +/* Ethernet fields */ #define NH_FLD_ETH_DA (1) #define NH_FLD_ETH_SA (NH_FLD_ETH_DA << 1) #define NH_FLD_ETH_LENGTH (NH_FLD_ETH_DA << 2) @@ -21,7 +19,7 @@ #define NH_FLD_ETH_ADDR_SIZE 6 -/*************************** VLAN fields ***********************************/ +/* VLAN fields */ #define NH_FLD_VLAN_VPRI (1) #define NH_FLD_VLAN_CFI (NH_FLD_VLAN_VPRI << 1) #define NH_FLD_VLAN_VID (NH_FLD_VLAN_VPRI << 2) @@ -33,7 +31,7 @@ NH_FLD_VLAN_CFI | \ NH_FLD_VLAN_VID) -/************************ IP (generic) fields ******************************/ +/* IP (generic) fields */ #define NH_FLD_IP_VER (1) #define NH_FLD_IP_DSCP (NH_FLD_IP_VER << 2) #define NH_FLD_IP_ECN (NH_FLD_IP_VER << 3) @@ -46,7 +44,7 @@ #define NH_FLD_IP_PROTO_SIZE 1 -/***************************** IPV4 fields *********************************/ +/* IPV4 fields */ #define NH_FLD_IPV4_VER (1) #define NH_FLD_IPV4_HDR_LEN (NH_FLD_IPV4_VER << 1) #define NH_FLD_IPV4_TOS (NH_FLD_IPV4_VER << 2) @@ -67,7 +65,7 @@ #define NH_FLD_IPV4_ADDR_SIZE 4 #define NH_FLD_IPV4_PROTO_SIZE 1 -/***************************** IPV6 fields *********************************/ +/* IPV6 fields */ #define NH_FLD_IPV6_VER (1) #define NH_FLD_IPV6_TC (NH_FLD_IPV6_VER << 1) #define NH_FLD_IPV6_SRC_IP (NH_FLD_IPV6_VER << 2) @@ -81,7 +79,7 @@ #define NH_FLD_IPV6_ADDR_SIZE 16 #define NH_FLD_IPV6_NEXT_HDR_SIZE 1 -/***************************** ICMP fields *********************************/ +/* ICMP fields */ #define NH_FLD_ICMP_TYPE (1) #define NH_FLD_ICMP_CODE (NH_FLD_ICMP_TYPE << 1) #define NH_FLD_ICMP_CKSUM (NH_FLD_ICMP_TYPE << 2) @@ -92,14 +90,14 @@ #define NH_FLD_ICMP_CODE_SIZE 1 #define NH_FLD_ICMP_TYPE_SIZE 1 -/***************************** IGMP fields *********************************/ +/* IGMP fields */ #define NH_FLD_IGMP_VERSION (1) #define NH_FLD_IGMP_TYPE (NH_FLD_IGMP_VERSION << 1) #define NH_FLD_IGMP_CKSUM (NH_FLD_IGMP_VERSION << 2) #define NH_FLD_IGMP_DATA (NH_FLD_IGMP_VERSION << 3) #define NH_FLD_IGMP_ALL_FIELDS ((NH_FLD_IGMP_VERSION << 4) - 1) -/***************************** TCP fields **********************************/ +/* TCP fields */ #define NH_FLD_TCP_PORT_SRC (1) #define NH_FLD_TCP_PORT_DST (NH_FLD_TCP_PORT_SRC << 1) #define NH_FLD_TCP_SEQ (NH_FLD_TCP_PORT_SRC << 2) @@ -115,7 +113,7 @@ #define NH_FLD_TCP_PORT_SIZE 2 -/***************************** UDP fields **********************************/ +/* UDP fields */ #define NH_FLD_UDP_PORT_SRC (1) #define NH_FLD_UDP_PORT_DST (NH_FLD_UDP_PORT_SRC << 1) #define NH_FLD_UDP_LEN (NH_FLD_UDP_PORT_SRC << 2) @@ -124,7 +122,7 @@ #define NH_FLD_UDP_PORT_SIZE 2 -/*************************** UDP-lite fields *******************************/ +/* UDP-lite fields */ #define NH_FLD_UDP_LITE_PORT_SRC (1) #define NH_FLD_UDP_LITE_PORT_DST (NH_FLD_UDP_LITE_PORT_SRC << 1) #define NH_FLD_UDP_LITE_ALL_FIELDS \ @@ -132,7 +130,7 @@ #define NH_FLD_UDP_LITE_PORT_SIZE 2 -/*************************** UDP-encap-ESP fields **************************/ +/* UDP-encap-ESP fields */ #define NH_FLD_UDP_ENC_ESP_PORT_SRC (1) #define NH_FLD_UDP_ENC_ESP_PORT_DST (NH_FLD_UDP_ENC_ESP_PORT_SRC << 1) #define NH_FLD_UDP_ENC_ESP_LEN (NH_FLD_UDP_ENC_ESP_PORT_SRC << 2) @@ -145,7 +143,7 @@ #define NH_FLD_UDP_ENC_ESP_PORT_SIZE 2 #define NH_FLD_UDP_ENC_ESP_SPI_SIZE 4 -/***************************** SCTP fields *********************************/ +/* SCTP fields */ #define NH_FLD_SCTP_PORT_SRC (1) #define NH_FLD_SCTP_PORT_DST (NH_FLD_SCTP_PORT_SRC << 1) #define NH_FLD_SCTP_VER_TAG (NH_FLD_SCTP_PORT_SRC << 2) @@ -154,14 +152,14 @@ #define NH_FLD_SCTP_PORT_SIZE 2 -/***************************** DCCP fields *********************************/ +/* DCCP fields */ #define NH_FLD_DCCP_PORT_SRC (1) #define NH_FLD_DCCP_PORT_DST (NH_FLD_DCCP_PORT_SRC << 1) #define NH_FLD_DCCP_ALL_FIELDS ((NH_FLD_DCCP_PORT_SRC << 2) - 1) #define NH_FLD_DCCP_PORT_SIZE 2 -/***************************** IPHC fields *********************************/ +/* IPHC fields */ #define NH_FLD_IPHC_CID (1) #define NH_FLD_IPHC_CID_TYPE (NH_FLD_IPHC_CID << 1) #define NH_FLD_IPHC_HCINDEX (NH_FLD_IPHC_CID << 2) @@ -169,7 +167,7 @@ #define NH_FLD_IPHC_D_BIT (NH_FLD_IPHC_CID << 4) #define NH_FLD_IPHC_ALL_FIELDS ((NH_FLD_IPHC_CID << 5) - 1) -/***************************** SCTP fields *********************************/ +/* SCTP fields */ #define NH_FLD_SCTP_CHUNK_DATA_TYPE (1) #define NH_FLD_SCTP_CHUNK_DATA_FLAGS (NH_FLD_SCTP_CHUNK_DATA_TYPE << 1) #define NH_FLD_SCTP_CHUNK_DATA_LENGTH (NH_FLD_SCTP_CHUNK_DATA_TYPE << 2) @@ -183,7 +181,7 @@ #define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS \ ((NH_FLD_SCTP_CHUNK_DATA_TYPE << 10) - 1) -/*************************** L2TPV2 fields *********************************/ +/* L2TPV2 fields */ #define NH_FLD_L2TPV2_TYPE_BIT (1) #define NH_FLD_L2TPV2_LENGTH_BIT (NH_FLD_L2TPV2_TYPE_BIT << 1) #define NH_FLD_L2TPV2_SEQUENCE_BIT (NH_FLD_L2TPV2_TYPE_BIT << 2) @@ -200,7 +198,7 @@ #define NH_FLD_L2TPV2_ALL_FIELDS \ ((NH_FLD_L2TPV2_TYPE_BIT << 13) - 1) -/*************************** L2TPV3 fields *********************************/ +/* L2TPV3 fields */ #define NH_FLD_L2TPV3_CTRL_TYPE_BIT (1) #define NH_FLD_L2TPV3_CTRL_LENGTH_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 1) #define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 2) @@ -220,12 +218,12 @@ #define NH_FLD_L2TPV3_SESS_ALL_FIELDS \ ((NH_FLD_L2TPV3_SESS_TYPE_BIT << 4) - 1) -/**************************** PPP fields ***********************************/ +/* PPP fields */ #define NH_FLD_PPP_PID (1) #define NH_FLD_PPP_COMPRESSED (NH_FLD_PPP_PID << 1) #define NH_FLD_PPP_ALL_FIELDS ((NH_FLD_PPP_PID << 2) - 1) -/************************** PPPoE fields ***********************************/ +/* PPPoE fields */ #define NH_FLD_PPPOE_VER (1) #define NH_FLD_PPPOE_TYPE (NH_FLD_PPPOE_VER << 1) #define NH_FLD_PPPOE_CODE (NH_FLD_PPPOE_VER << 2) @@ -235,13 +233,13 @@ #define NH_FLD_PPPOE_PID (NH_FLD_PPPOE_VER << 6) #define NH_FLD_PPPOE_ALL_FIELDS ((NH_FLD_PPPOE_VER << 7) - 1) -/************************* PPP-Mux fields **********************************/ +/* PPP-Mux fields */ #define NH_FLD_PPPMUX_PID (1) #define NH_FLD_PPPMUX_CKSUM (NH_FLD_PPPMUX_PID << 1) #define NH_FLD_PPPMUX_COMPRESSED (NH_FLD_PPPMUX_PID << 2) #define NH_FLD_PPPMUX_ALL_FIELDS ((NH_FLD_PPPMUX_PID << 3) - 1) -/*********************** PPP-Mux sub-frame fields **************************/ +/* PPP-Mux sub-frame fields */ #define NH_FLD_PPPMUX_SUBFRM_PFF (1) #define NH_FLD_PPPMUX_SUBFRM_LXT (NH_FLD_PPPMUX_SUBFRM_PFF << 1) #define NH_FLD_PPPMUX_SUBFRM_LEN (NH_FLD_PPPMUX_SUBFRM_PFF << 2) @@ -250,25 +248,26 @@ #define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS \ ((NH_FLD_PPPMUX_SUBFRM_PFF << 5) - 1) -/*************************** LLC fields ************************************/ +/* LLC fields */ #define NH_FLD_LLC_DSAP (1) #define NH_FLD_LLC_SSAP (NH_FLD_LLC_DSAP << 1) #define NH_FLD_LLC_CTRL (NH_FLD_LLC_DSAP << 2) #define NH_FLD_LLC_ALL_FIELDS ((NH_FLD_LLC_DSAP << 3) - 1) -/*************************** NLPID fields **********************************/ +/* NLPID fields */ #define NH_FLD_NLPID_NLPID (1) #define NH_FLD_NLPID_ALL_FIELDS ((NH_FLD_NLPID_NLPID << 1) - 1) -/*************************** SNAP fields ***********************************/ +/* SNAP fields */ #define NH_FLD_SNAP_OUI (1) #define NH_FLD_SNAP_PID (NH_FLD_SNAP_OUI << 1) #define NH_FLD_SNAP_ALL_FIELDS ((NH_FLD_SNAP_OUI << 2) - 1) -/*************************** LLC SNAP fields *******************************/ +/* LLC SNAP fields */ #define NH_FLD_LLC_SNAP_TYPE (1) #define NH_FLD_LLC_SNAP_ALL_FIELDS ((NH_FLD_LLC_SNAP_TYPE << 1) - 1) +/* ARP fields */ #define NH_FLD_ARP_HTYPE (1) #define NH_FLD_ARP_PTYPE (NH_FLD_ARP_HTYPE << 1) #define NH_FLD_ARP_HLEN (NH_FLD_ARP_HTYPE << 2) @@ -280,7 +279,7 @@ #define NH_FLD_ARP_TPA (NH_FLD_ARP_HTYPE << 8) #define NH_FLD_ARP_ALL_FIELDS ((NH_FLD_ARP_HTYPE << 9) - 1) -/*************************** RFC2684 fields ********************************/ +/* RFC2684 fields */ #define NH_FLD_RFC2684_LLC (1) #define NH_FLD_RFC2684_NLPID (NH_FLD_RFC2684_LLC << 1) #define NH_FLD_RFC2684_OUI (NH_FLD_RFC2684_LLC << 2) @@ -289,13 +288,13 @@ #define NH_FLD_RFC2684_VPN_IDX (NH_FLD_RFC2684_LLC << 5) #define NH_FLD_RFC2684_ALL_FIELDS ((NH_FLD_RFC2684_LLC << 6) - 1) -/*************************** User defined fields ***************************/ +/* User defined fields */ #define NH_FLD_USER_DEFINED_SRCPORT (1) #define NH_FLD_USER_DEFINED_PCDID (NH_FLD_USER_DEFINED_SRCPORT << 1) #define NH_FLD_USER_DEFINED_ALL_FIELDS \ ((NH_FLD_USER_DEFINED_SRCPORT << 2) - 1) -/*************************** Payload fields ********************************/ +/* Payload fields */ #define NH_FLD_PAYLOAD_BUFFER (1) #define NH_FLD_PAYLOAD_SIZE (NH_FLD_PAYLOAD_BUFFER << 1) #define NH_FLD_MAX_FRM_SIZE (NH_FLD_PAYLOAD_BUFFER << 2) @@ -304,39 +303,39 @@ #define NH_FLD_FRAME_SIZE (NH_FLD_PAYLOAD_BUFFER << 5) #define NH_FLD_PAYLOAD_ALL_FIELDS ((NH_FLD_PAYLOAD_BUFFER << 6) - 1) -/*************************** GRE fields ************************************/ +/* GRE fields */ #define NH_FLD_GRE_TYPE (1) #define NH_FLD_GRE_ALL_FIELDS ((NH_FLD_GRE_TYPE << 1) - 1) -/*************************** MINENCAP fields *******************************/ +/* MINENCAP fields */ #define NH_FLD_MINENCAP_SRC_IP (1) #define NH_FLD_MINENCAP_DST_IP (NH_FLD_MINENCAP_SRC_IP << 1) #define NH_FLD_MINENCAP_TYPE (NH_FLD_MINENCAP_SRC_IP << 2) #define NH_FLD_MINENCAP_ALL_FIELDS \ ((NH_FLD_MINENCAP_SRC_IP << 3) - 1) -/*************************** IPSEC AH fields *******************************/ +/* IPSEC AH fields */ #define NH_FLD_IPSEC_AH_SPI (1) #define NH_FLD_IPSEC_AH_NH (NH_FLD_IPSEC_AH_SPI << 1) #define NH_FLD_IPSEC_AH_ALL_FIELDS ((NH_FLD_IPSEC_AH_SPI << 2) - 1) -/*************************** IPSEC ESP fields ******************************/ +/* IPSEC ESP fields */ #define NH_FLD_IPSEC_ESP_SPI (1) #define NH_FLD_IPSEC_ESP_SEQUENCE_NUM (NH_FLD_IPSEC_ESP_SPI << 1) #define NH_FLD_IPSEC_ESP_ALL_FIELDS ((NH_FLD_IPSEC_ESP_SPI << 2) - 1) #define NH_FLD_IPSEC_ESP_SPI_SIZE 4 -/*************************** MPLS fields ***********************************/ +/* MPLS fields */ #define NH_FLD_MPLS_LABEL_STACK (1) #define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS \ ((NH_FLD_MPLS_LABEL_STACK << 1) - 1) -/*************************** MACSEC fields *********************************/ +/* MACSEC fields */ #define NH_FLD_MACSEC_SECTAG (1) #define NH_FLD_MACSEC_ALL_FIELDS ((NH_FLD_MACSEC_SECTAG << 1) - 1) -/*************************** GTP fields ************************************/ +/* GTP fields */ #define NH_FLD_GTP_TEID (1) /* Protocol options */ @@ -387,6 +386,7 @@ /* CAPWAP options */ #define NH_OPT_CAPWAP_DTLS 1 +/* Supported protocols */ enum net_prot { NET_PROT_NONE = 0, NET_PROT_PAYLOAD, From d9cc92670b357a5bf2a507a7c8ebd59086a80865 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Wed, 1 Aug 2018 11:09:49 -0500 Subject: [PATCH 779/903] staging: fsl-dpaa2/eth: Remove dead code File net.h contains unused defines, so remove them. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/net.h | 85 ------------------------ 1 file changed, 85 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h b/drivers/staging/fsl-dpaa2/ethernet/net.h index ddea9400d265..2461d6ee7aac 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/net.h +++ b/drivers/staging/fsl-dpaa2/ethernet/net.h @@ -4,8 +4,6 @@ #ifndef __FSL_NET_H #define __FSL_NET_H -#define LAST_HDR_INDEX 0xFFFFFFFF - /* Protocol fields */ /* Ethernet fields */ @@ -17,8 +15,6 @@ #define NH_FLD_ETH_PADDING (NH_FLD_ETH_DA << 5) #define NH_FLD_ETH_ALL_FIELDS ((NH_FLD_ETH_DA << 6) - 1) -#define NH_FLD_ETH_ADDR_SIZE 6 - /* VLAN fields */ #define NH_FLD_VLAN_VPRI (1) #define NH_FLD_VLAN_CFI (NH_FLD_VLAN_VPRI << 1) @@ -42,8 +38,6 @@ #define NH_FLD_IP_ID (NH_FLD_IP_VER << 8) #define NH_FLD_IP_ALL_FIELDS ((NH_FLD_IP_VER << 9) - 1) -#define NH_FLD_IP_PROTO_SIZE 1 - /* IPV4 fields */ #define NH_FLD_IPV4_VER (1) #define NH_FLD_IPV4_HDR_LEN (NH_FLD_IPV4_VER << 1) @@ -62,9 +56,6 @@ #define NH_FLD_IPV4_OPTS_COUNT (NH_FLD_IPV4_VER << 14) #define NH_FLD_IPV4_ALL_FIELDS ((NH_FLD_IPV4_VER << 15) - 1) -#define NH_FLD_IPV4_ADDR_SIZE 4 -#define NH_FLD_IPV4_PROTO_SIZE 1 - /* IPV6 fields */ #define NH_FLD_IPV6_VER (1) #define NH_FLD_IPV6_TC (NH_FLD_IPV6_VER << 1) @@ -76,9 +67,6 @@ #define NH_FLD_IPV6_ID (NH_FLD_IPV6_VER << 7) #define NH_FLD_IPV6_ALL_FIELDS ((NH_FLD_IPV6_VER << 8) - 1) -#define NH_FLD_IPV6_ADDR_SIZE 16 -#define NH_FLD_IPV6_NEXT_HDR_SIZE 1 - /* ICMP fields */ #define NH_FLD_ICMP_TYPE (1) #define NH_FLD_ICMP_CODE (NH_FLD_ICMP_TYPE << 1) @@ -87,9 +75,6 @@ #define NH_FLD_ICMP_SQ_NUM (NH_FLD_ICMP_TYPE << 4) #define NH_FLD_ICMP_ALL_FIELDS ((NH_FLD_ICMP_TYPE << 5) - 1) -#define NH_FLD_ICMP_CODE_SIZE 1 -#define NH_FLD_ICMP_TYPE_SIZE 1 - /* IGMP fields */ #define NH_FLD_IGMP_VERSION (1) #define NH_FLD_IGMP_TYPE (NH_FLD_IGMP_VERSION << 1) @@ -111,8 +96,6 @@ #define NH_FLD_TCP_OPTS_COUNT (NH_FLD_TCP_PORT_SRC << 10) #define NH_FLD_TCP_ALL_FIELDS ((NH_FLD_TCP_PORT_SRC << 11) - 1) -#define NH_FLD_TCP_PORT_SIZE 2 - /* UDP fields */ #define NH_FLD_UDP_PORT_SRC (1) #define NH_FLD_UDP_PORT_DST (NH_FLD_UDP_PORT_SRC << 1) @@ -120,16 +103,12 @@ #define NH_FLD_UDP_CKSUM (NH_FLD_UDP_PORT_SRC << 3) #define NH_FLD_UDP_ALL_FIELDS ((NH_FLD_UDP_PORT_SRC << 4) - 1) -#define NH_FLD_UDP_PORT_SIZE 2 - /* UDP-lite fields */ #define NH_FLD_UDP_LITE_PORT_SRC (1) #define NH_FLD_UDP_LITE_PORT_DST (NH_FLD_UDP_LITE_PORT_SRC << 1) #define NH_FLD_UDP_LITE_ALL_FIELDS \ ((NH_FLD_UDP_LITE_PORT_SRC << 2) - 1) -#define NH_FLD_UDP_LITE_PORT_SIZE 2 - /* UDP-encap-ESP fields */ #define NH_FLD_UDP_ENC_ESP_PORT_SRC (1) #define NH_FLD_UDP_ENC_ESP_PORT_DST (NH_FLD_UDP_ENC_ESP_PORT_SRC << 1) @@ -140,9 +119,6 @@ #define NH_FLD_UDP_ENC_ESP_ALL_FIELDS \ ((NH_FLD_UDP_ENC_ESP_PORT_SRC << 6) - 1) -#define NH_FLD_UDP_ENC_ESP_PORT_SIZE 2 -#define NH_FLD_UDP_ENC_ESP_SPI_SIZE 4 - /* SCTP fields */ #define NH_FLD_SCTP_PORT_SRC (1) #define NH_FLD_SCTP_PORT_DST (NH_FLD_SCTP_PORT_SRC << 1) @@ -150,15 +126,11 @@ #define NH_FLD_SCTP_CKSUM (NH_FLD_SCTP_PORT_SRC << 3) #define NH_FLD_SCTP_ALL_FIELDS ((NH_FLD_SCTP_PORT_SRC << 4) - 1) -#define NH_FLD_SCTP_PORT_SIZE 2 - /* DCCP fields */ #define NH_FLD_DCCP_PORT_SRC (1) #define NH_FLD_DCCP_PORT_DST (NH_FLD_DCCP_PORT_SRC << 1) #define NH_FLD_DCCP_ALL_FIELDS ((NH_FLD_DCCP_PORT_SRC << 2) - 1) -#define NH_FLD_DCCP_PORT_SIZE 2 - /* IPHC fields */ #define NH_FLD_IPHC_CID (1) #define NH_FLD_IPHC_CID_TYPE (NH_FLD_IPHC_CID << 1) @@ -324,7 +296,6 @@ #define NH_FLD_IPSEC_ESP_SEQUENCE_NUM (NH_FLD_IPSEC_ESP_SPI << 1) #define NH_FLD_IPSEC_ESP_ALL_FIELDS ((NH_FLD_IPSEC_ESP_SPI << 2) - 1) -#define NH_FLD_IPSEC_ESP_SPI_SIZE 4 /* MPLS fields */ #define NH_FLD_MPLS_LABEL_STACK (1) @@ -338,54 +309,6 @@ /* GTP fields */ #define NH_FLD_GTP_TEID (1) -/* Protocol options */ - -/* Ethernet options */ -#define NH_OPT_ETH_BROADCAST 1 -#define NH_OPT_ETH_MULTICAST 2 -#define NH_OPT_ETH_UNICAST 3 -#define NH_OPT_ETH_BPDU 4 - -#define NH_ETH_IS_MULTICAST_ADDR(addr) (addr[0] & 0x01) -/* also applicable for broadcast */ - -/* VLAN options */ -#define NH_OPT_VLAN_CFI 1 - -/* IPV4 options */ -#define NH_OPT_IPV4_UNICAST 1 -#define NH_OPT_IPV4_MULTICAST 2 -#define NH_OPT_IPV4_BROADCAST 3 -#define NH_OPT_IPV4_OPTION 4 -#define NH_OPT_IPV4_FRAG 5 -#define NH_OPT_IPV4_INITIAL_FRAG 6 - -/* IPV6 options */ -#define NH_OPT_IPV6_UNICAST 1 -#define NH_OPT_IPV6_MULTICAST 2 -#define NH_OPT_IPV6_OPTION 3 -#define NH_OPT_IPV6_FRAG 4 -#define NH_OPT_IPV6_INITIAL_FRAG 5 - -/* General IP options (may be used for any version) */ -#define NH_OPT_IP_FRAG 1 -#define NH_OPT_IP_INITIAL_FRAG 2 -#define NH_OPT_IP_OPTION 3 - -/* Minenc. options */ -#define NH_OPT_MINENCAP_SRC_ADDR_PRESENT 1 - -/* GRE. options */ -#define NH_OPT_GRE_ROUTING_PRESENT 1 - -/* TCP options */ -#define NH_OPT_TCP_OPTIONS 1 -#define NH_OPT_TCP_CONTROL_HIGH_BITS 2 -#define NH_OPT_TCP_CONTROL_LOW_BITS 3 - -/* CAPWAP options */ -#define NH_OPT_CAPWAP_DTLS 1 - /* Supported protocols */ enum net_prot { NET_PROT_NONE = 0, @@ -441,12 +364,4 @@ enum net_prot { NET_PROT_DUMMY_LAST }; -/*! IEEE8021.Q */ -#define NH_IEEE8021Q_ETYPE 0x8100 -#define NH_IEEE8021Q_HDR(etype, pcp, dei, vlan_id) \ - ((((u32)((etype) & 0xFFFF)) << 16) | \ - (((u32)((pcp) & 0x07)) << 13) | \ - (((u32)((dei) & 0x01)) << 12) | \ - (((u32)((vlan_id) & 0xFFF)))) - #endif /* __FSL_NET_H */ From 0035698dcd7815d17b6c8c0f6c29fdf8d29fcaca Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Wed, 1 Aug 2018 11:09:50 -0500 Subject: [PATCH 780/903] staging: fsl-dpaa2/eth: Use BIT() macro File net.h has several bitmask defines that could be implemented more clearly using the BIT() macro. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/net.h | 446 +++++++++++------------ 1 file changed, 218 insertions(+), 228 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h b/drivers/staging/fsl-dpaa2/ethernet/net.h index 2461d6ee7aac..81f5a91f4a93 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/net.h +++ b/drivers/staging/fsl-dpaa2/ethernet/net.h @@ -7,307 +7,297 @@ /* Protocol fields */ /* Ethernet fields */ -#define NH_FLD_ETH_DA (1) -#define NH_FLD_ETH_SA (NH_FLD_ETH_DA << 1) -#define NH_FLD_ETH_LENGTH (NH_FLD_ETH_DA << 2) -#define NH_FLD_ETH_TYPE (NH_FLD_ETH_DA << 3) -#define NH_FLD_ETH_FINAL_CKSUM (NH_FLD_ETH_DA << 4) -#define NH_FLD_ETH_PADDING (NH_FLD_ETH_DA << 5) -#define NH_FLD_ETH_ALL_FIELDS ((NH_FLD_ETH_DA << 6) - 1) +#define NH_FLD_ETH_DA BIT(0) +#define NH_FLD_ETH_SA BIT(1) +#define NH_FLD_ETH_LENGTH BIT(2) +#define NH_FLD_ETH_TYPE BIT(3) +#define NH_FLD_ETH_FINAL_CKSUM BIT(4) +#define NH_FLD_ETH_PADDING BIT(5) +#define NH_FLD_ETH_ALL_FIELDS (BIT(6) - 1) /* VLAN fields */ -#define NH_FLD_VLAN_VPRI (1) -#define NH_FLD_VLAN_CFI (NH_FLD_VLAN_VPRI << 1) -#define NH_FLD_VLAN_VID (NH_FLD_VLAN_VPRI << 2) -#define NH_FLD_VLAN_LENGTH (NH_FLD_VLAN_VPRI << 3) -#define NH_FLD_VLAN_TYPE (NH_FLD_VLAN_VPRI << 4) -#define NH_FLD_VLAN_ALL_FIELDS ((NH_FLD_VLAN_VPRI << 5) - 1) +#define NH_FLD_VLAN_VPRI BIT(0) +#define NH_FLD_VLAN_CFI BIT(1) +#define NH_FLD_VLAN_VID BIT(2) +#define NH_FLD_VLAN_LENGTH BIT(3) +#define NH_FLD_VLAN_TYPE BIT(4) +#define NH_FLD_VLAN_ALL_FIELDS (BIT(5) - 1) -#define NH_FLD_VLAN_TCI (NH_FLD_VLAN_VPRI | \ - NH_FLD_VLAN_CFI | \ - NH_FLD_VLAN_VID) +#define NH_FLD_VLAN_TCI (NH_FLD_VLAN_VPRI | \ + NH_FLD_VLAN_CFI | \ + NH_FLD_VLAN_VID) /* IP (generic) fields */ -#define NH_FLD_IP_VER (1) -#define NH_FLD_IP_DSCP (NH_FLD_IP_VER << 2) -#define NH_FLD_IP_ECN (NH_FLD_IP_VER << 3) -#define NH_FLD_IP_PROTO (NH_FLD_IP_VER << 4) -#define NH_FLD_IP_SRC (NH_FLD_IP_VER << 5) -#define NH_FLD_IP_DST (NH_FLD_IP_VER << 6) -#define NH_FLD_IP_TOS_TC (NH_FLD_IP_VER << 7) -#define NH_FLD_IP_ID (NH_FLD_IP_VER << 8) -#define NH_FLD_IP_ALL_FIELDS ((NH_FLD_IP_VER << 9) - 1) +#define NH_FLD_IP_VER BIT(0) +#define NH_FLD_IP_DSCP BIT(2) +#define NH_FLD_IP_ECN BIT(3) +#define NH_FLD_IP_PROTO BIT(4) +#define NH_FLD_IP_SRC BIT(5) +#define NH_FLD_IP_DST BIT(6) +#define NH_FLD_IP_TOS_TC BIT(7) +#define NH_FLD_IP_ID BIT(8) +#define NH_FLD_IP_ALL_FIELDS (BIT(9) - 1) /* IPV4 fields */ -#define NH_FLD_IPV4_VER (1) -#define NH_FLD_IPV4_HDR_LEN (NH_FLD_IPV4_VER << 1) -#define NH_FLD_IPV4_TOS (NH_FLD_IPV4_VER << 2) -#define NH_FLD_IPV4_TOTAL_LEN (NH_FLD_IPV4_VER << 3) -#define NH_FLD_IPV4_ID (NH_FLD_IPV4_VER << 4) -#define NH_FLD_IPV4_FLAG_D (NH_FLD_IPV4_VER << 5) -#define NH_FLD_IPV4_FLAG_M (NH_FLD_IPV4_VER << 6) -#define NH_FLD_IPV4_OFFSET (NH_FLD_IPV4_VER << 7) -#define NH_FLD_IPV4_TTL (NH_FLD_IPV4_VER << 8) -#define NH_FLD_IPV4_PROTO (NH_FLD_IPV4_VER << 9) -#define NH_FLD_IPV4_CKSUM (NH_FLD_IPV4_VER << 10) -#define NH_FLD_IPV4_SRC_IP (NH_FLD_IPV4_VER << 11) -#define NH_FLD_IPV4_DST_IP (NH_FLD_IPV4_VER << 12) -#define NH_FLD_IPV4_OPTS (NH_FLD_IPV4_VER << 13) -#define NH_FLD_IPV4_OPTS_COUNT (NH_FLD_IPV4_VER << 14) -#define NH_FLD_IPV4_ALL_FIELDS ((NH_FLD_IPV4_VER << 15) - 1) +#define NH_FLD_IPV4_VER BIT(0) +#define NH_FLD_IPV4_HDR_LEN BIT(1) +#define NH_FLD_IPV4_TOS BIT(2) +#define NH_FLD_IPV4_TOTAL_LEN BIT(3) +#define NH_FLD_IPV4_ID BIT(4) +#define NH_FLD_IPV4_FLAG_D BIT(5) +#define NH_FLD_IPV4_FLAG_M BIT(6) +#define NH_FLD_IPV4_OFFSET BIT(7) +#define NH_FLD_IPV4_TTL BIT(8) +#define NH_FLD_IPV4_PROTO BIT(9) +#define NH_FLD_IPV4_CKSUM BIT(10) +#define NH_FLD_IPV4_SRC_IP BIT(11) +#define NH_FLD_IPV4_DST_IP BIT(12) +#define NH_FLD_IPV4_OPTS BIT(13) +#define NH_FLD_IPV4_OPTS_COUNT BIT(14) +#define NH_FLD_IPV4_ALL_FIELDS (BIT(15) - 1) /* IPV6 fields */ -#define NH_FLD_IPV6_VER (1) -#define NH_FLD_IPV6_TC (NH_FLD_IPV6_VER << 1) -#define NH_FLD_IPV6_SRC_IP (NH_FLD_IPV6_VER << 2) -#define NH_FLD_IPV6_DST_IP (NH_FLD_IPV6_VER << 3) -#define NH_FLD_IPV6_NEXT_HDR (NH_FLD_IPV6_VER << 4) -#define NH_FLD_IPV6_FL (NH_FLD_IPV6_VER << 5) -#define NH_FLD_IPV6_HOP_LIMIT (NH_FLD_IPV6_VER << 6) -#define NH_FLD_IPV6_ID (NH_FLD_IPV6_VER << 7) -#define NH_FLD_IPV6_ALL_FIELDS ((NH_FLD_IPV6_VER << 8) - 1) +#define NH_FLD_IPV6_VER BIT(0) +#define NH_FLD_IPV6_TC BIT(1) +#define NH_FLD_IPV6_SRC_IP BIT(2) +#define NH_FLD_IPV6_DST_IP BIT(3) +#define NH_FLD_IPV6_NEXT_HDR BIT(4) +#define NH_FLD_IPV6_FL BIT(5) +#define NH_FLD_IPV6_HOP_LIMIT BIT(6) +#define NH_FLD_IPV6_ID BIT(7) +#define NH_FLD_IPV6_ALL_FIELDS (BIT(8) - 1) /* ICMP fields */ -#define NH_FLD_ICMP_TYPE (1) -#define NH_FLD_ICMP_CODE (NH_FLD_ICMP_TYPE << 1) -#define NH_FLD_ICMP_CKSUM (NH_FLD_ICMP_TYPE << 2) -#define NH_FLD_ICMP_ID (NH_FLD_ICMP_TYPE << 3) -#define NH_FLD_ICMP_SQ_NUM (NH_FLD_ICMP_TYPE << 4) -#define NH_FLD_ICMP_ALL_FIELDS ((NH_FLD_ICMP_TYPE << 5) - 1) +#define NH_FLD_ICMP_TYPE BIT(0) +#define NH_FLD_ICMP_CODE BIT(1) +#define NH_FLD_ICMP_CKSUM BIT(2) +#define NH_FLD_ICMP_ID BIT(3) +#define NH_FLD_ICMP_SQ_NUM BIT(4) +#define NH_FLD_ICMP_ALL_FIELDS (BIT(5) - 1) /* IGMP fields */ -#define NH_FLD_IGMP_VERSION (1) -#define NH_FLD_IGMP_TYPE (NH_FLD_IGMP_VERSION << 1) -#define NH_FLD_IGMP_CKSUM (NH_FLD_IGMP_VERSION << 2) -#define NH_FLD_IGMP_DATA (NH_FLD_IGMP_VERSION << 3) -#define NH_FLD_IGMP_ALL_FIELDS ((NH_FLD_IGMP_VERSION << 4) - 1) +#define NH_FLD_IGMP_VERSION BIT(0) +#define NH_FLD_IGMP_TYPE BIT(1) +#define NH_FLD_IGMP_CKSUM BIT(2) +#define NH_FLD_IGMP_DATA BIT(3) +#define NH_FLD_IGMP_ALL_FIELDS (BIT(4) - 1) /* TCP fields */ -#define NH_FLD_TCP_PORT_SRC (1) -#define NH_FLD_TCP_PORT_DST (NH_FLD_TCP_PORT_SRC << 1) -#define NH_FLD_TCP_SEQ (NH_FLD_TCP_PORT_SRC << 2) -#define NH_FLD_TCP_ACK (NH_FLD_TCP_PORT_SRC << 3) -#define NH_FLD_TCP_OFFSET (NH_FLD_TCP_PORT_SRC << 4) -#define NH_FLD_TCP_FLAGS (NH_FLD_TCP_PORT_SRC << 5) -#define NH_FLD_TCP_WINDOW (NH_FLD_TCP_PORT_SRC << 6) -#define NH_FLD_TCP_CKSUM (NH_FLD_TCP_PORT_SRC << 7) -#define NH_FLD_TCP_URGPTR (NH_FLD_TCP_PORT_SRC << 8) -#define NH_FLD_TCP_OPTS (NH_FLD_TCP_PORT_SRC << 9) -#define NH_FLD_TCP_OPTS_COUNT (NH_FLD_TCP_PORT_SRC << 10) -#define NH_FLD_TCP_ALL_FIELDS ((NH_FLD_TCP_PORT_SRC << 11) - 1) +#define NH_FLD_TCP_PORT_SRC BIT(0) +#define NH_FLD_TCP_PORT_DST BIT(1) +#define NH_FLD_TCP_SEQ BIT(2) +#define NH_FLD_TCP_ACK BIT(3) +#define NH_FLD_TCP_OFFSET BIT(4) +#define NH_FLD_TCP_FLAGS BIT(5) +#define NH_FLD_TCP_WINDOW BIT(6) +#define NH_FLD_TCP_CKSUM BIT(7) +#define NH_FLD_TCP_URGPTR BIT(8) +#define NH_FLD_TCP_OPTS BIT(9) +#define NH_FLD_TCP_OPTS_COUNT BIT(10) +#define NH_FLD_TCP_ALL_FIELDS (BIT(11) - 1) /* UDP fields */ -#define NH_FLD_UDP_PORT_SRC (1) -#define NH_FLD_UDP_PORT_DST (NH_FLD_UDP_PORT_SRC << 1) -#define NH_FLD_UDP_LEN (NH_FLD_UDP_PORT_SRC << 2) -#define NH_FLD_UDP_CKSUM (NH_FLD_UDP_PORT_SRC << 3) -#define NH_FLD_UDP_ALL_FIELDS ((NH_FLD_UDP_PORT_SRC << 4) - 1) +#define NH_FLD_UDP_PORT_SRC BIT(0) +#define NH_FLD_UDP_PORT_DST BIT(1) +#define NH_FLD_UDP_LEN BIT(2) +#define NH_FLD_UDP_CKSUM BIT(3) +#define NH_FLD_UDP_ALL_FIELDS (BIT(4) - 1) /* UDP-lite fields */ -#define NH_FLD_UDP_LITE_PORT_SRC (1) -#define NH_FLD_UDP_LITE_PORT_DST (NH_FLD_UDP_LITE_PORT_SRC << 1) -#define NH_FLD_UDP_LITE_ALL_FIELDS \ - ((NH_FLD_UDP_LITE_PORT_SRC << 2) - 1) +#define NH_FLD_UDP_LITE_PORT_SRC BIT(0) +#define NH_FLD_UDP_LITE_PORT_DST BIT(1) +#define NH_FLD_UDP_LITE_ALL_FIELDS (BIT(2) - 1) /* UDP-encap-ESP fields */ -#define NH_FLD_UDP_ENC_ESP_PORT_SRC (1) -#define NH_FLD_UDP_ENC_ESP_PORT_DST (NH_FLD_UDP_ENC_ESP_PORT_SRC << 1) -#define NH_FLD_UDP_ENC_ESP_LEN (NH_FLD_UDP_ENC_ESP_PORT_SRC << 2) -#define NH_FLD_UDP_ENC_ESP_CKSUM (NH_FLD_UDP_ENC_ESP_PORT_SRC << 3) -#define NH_FLD_UDP_ENC_ESP_SPI (NH_FLD_UDP_ENC_ESP_PORT_SRC << 4) -#define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM (NH_FLD_UDP_ENC_ESP_PORT_SRC << 5) -#define NH_FLD_UDP_ENC_ESP_ALL_FIELDS \ - ((NH_FLD_UDP_ENC_ESP_PORT_SRC << 6) - 1) +#define NH_FLD_UDP_ENC_ESP_PORT_SRC BIT(0) +#define NH_FLD_UDP_ENC_ESP_PORT_DST BIT(1) +#define NH_FLD_UDP_ENC_ESP_LEN BIT(2) +#define NH_FLD_UDP_ENC_ESP_CKSUM BIT(3) +#define NH_FLD_UDP_ENC_ESP_SPI BIT(4) +#define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM BIT(5) +#define NH_FLD_UDP_ENC_ESP_ALL_FIELDS (BIT(6) - 1) /* SCTP fields */ -#define NH_FLD_SCTP_PORT_SRC (1) -#define NH_FLD_SCTP_PORT_DST (NH_FLD_SCTP_PORT_SRC << 1) -#define NH_FLD_SCTP_VER_TAG (NH_FLD_SCTP_PORT_SRC << 2) -#define NH_FLD_SCTP_CKSUM (NH_FLD_SCTP_PORT_SRC << 3) -#define NH_FLD_SCTP_ALL_FIELDS ((NH_FLD_SCTP_PORT_SRC << 4) - 1) +#define NH_FLD_SCTP_PORT_SRC BIT(0) +#define NH_FLD_SCTP_PORT_DST BIT(1) +#define NH_FLD_SCTP_VER_TAG BIT(2) +#define NH_FLD_SCTP_CKSUM BIT(3) +#define NH_FLD_SCTP_ALL_FIELDS (BIT(4) - 1) /* DCCP fields */ -#define NH_FLD_DCCP_PORT_SRC (1) -#define NH_FLD_DCCP_PORT_DST (NH_FLD_DCCP_PORT_SRC << 1) -#define NH_FLD_DCCP_ALL_FIELDS ((NH_FLD_DCCP_PORT_SRC << 2) - 1) +#define NH_FLD_DCCP_PORT_SRC BIT(0) +#define NH_FLD_DCCP_PORT_DST BIT(1) +#define NH_FLD_DCCP_ALL_FIELDS (BIT(2) - 1) /* IPHC fields */ -#define NH_FLD_IPHC_CID (1) -#define NH_FLD_IPHC_CID_TYPE (NH_FLD_IPHC_CID << 1) -#define NH_FLD_IPHC_HCINDEX (NH_FLD_IPHC_CID << 2) -#define NH_FLD_IPHC_GEN (NH_FLD_IPHC_CID << 3) -#define NH_FLD_IPHC_D_BIT (NH_FLD_IPHC_CID << 4) -#define NH_FLD_IPHC_ALL_FIELDS ((NH_FLD_IPHC_CID << 5) - 1) +#define NH_FLD_IPHC_CID BIT(0) +#define NH_FLD_IPHC_CID_TYPE BIT(1) +#define NH_FLD_IPHC_HCINDEX BIT(2) +#define NH_FLD_IPHC_GEN BIT(3) +#define NH_FLD_IPHC_D_BIT BIT(4) +#define NH_FLD_IPHC_ALL_FIELDS (BIT(5) - 1) /* SCTP fields */ -#define NH_FLD_SCTP_CHUNK_DATA_TYPE (1) -#define NH_FLD_SCTP_CHUNK_DATA_FLAGS (NH_FLD_SCTP_CHUNK_DATA_TYPE << 1) -#define NH_FLD_SCTP_CHUNK_DATA_LENGTH (NH_FLD_SCTP_CHUNK_DATA_TYPE << 2) -#define NH_FLD_SCTP_CHUNK_DATA_TSN (NH_FLD_SCTP_CHUNK_DATA_TYPE << 3) -#define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID (NH_FLD_SCTP_CHUNK_DATA_TYPE << 4) -#define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN (NH_FLD_SCTP_CHUNK_DATA_TYPE << 5) -#define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID (NH_FLD_SCTP_CHUNK_DATA_TYPE << 6) -#define NH_FLD_SCTP_CHUNK_DATA_UNORDERED (NH_FLD_SCTP_CHUNK_DATA_TYPE << 7) -#define NH_FLD_SCTP_CHUNK_DATA_BEGGINING (NH_FLD_SCTP_CHUNK_DATA_TYPE << 8) -#define NH_FLD_SCTP_CHUNK_DATA_END (NH_FLD_SCTP_CHUNK_DATA_TYPE << 9) -#define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS \ - ((NH_FLD_SCTP_CHUNK_DATA_TYPE << 10) - 1) +#define NH_FLD_SCTP_CHUNK_DATA_TYPE BIT(0) +#define NH_FLD_SCTP_CHUNK_DATA_FLAGS BIT(1) +#define NH_FLD_SCTP_CHUNK_DATA_LENGTH BIT(2) +#define NH_FLD_SCTP_CHUNK_DATA_TSN BIT(3) +#define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID BIT(4) +#define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN BIT(5) +#define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID BIT(6) +#define NH_FLD_SCTP_CHUNK_DATA_UNORDERED BIT(7) +#define NH_FLD_SCTP_CHUNK_DATA_BEGGINING BIT(8) +#define NH_FLD_SCTP_CHUNK_DATA_END BIT(9) +#define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS (BIT(10) - 1) /* L2TPV2 fields */ -#define NH_FLD_L2TPV2_TYPE_BIT (1) -#define NH_FLD_L2TPV2_LENGTH_BIT (NH_FLD_L2TPV2_TYPE_BIT << 1) -#define NH_FLD_L2TPV2_SEQUENCE_BIT (NH_FLD_L2TPV2_TYPE_BIT << 2) -#define NH_FLD_L2TPV2_OFFSET_BIT (NH_FLD_L2TPV2_TYPE_BIT << 3) -#define NH_FLD_L2TPV2_PRIORITY_BIT (NH_FLD_L2TPV2_TYPE_BIT << 4) -#define NH_FLD_L2TPV2_VERSION (NH_FLD_L2TPV2_TYPE_BIT << 5) -#define NH_FLD_L2TPV2_LEN (NH_FLD_L2TPV2_TYPE_BIT << 6) -#define NH_FLD_L2TPV2_TUNNEL_ID (NH_FLD_L2TPV2_TYPE_BIT << 7) -#define NH_FLD_L2TPV2_SESSION_ID (NH_FLD_L2TPV2_TYPE_BIT << 8) -#define NH_FLD_L2TPV2_NS (NH_FLD_L2TPV2_TYPE_BIT << 9) -#define NH_FLD_L2TPV2_NR (NH_FLD_L2TPV2_TYPE_BIT << 10) -#define NH_FLD_L2TPV2_OFFSET_SIZE (NH_FLD_L2TPV2_TYPE_BIT << 11) -#define NH_FLD_L2TPV2_FIRST_BYTE (NH_FLD_L2TPV2_TYPE_BIT << 12) -#define NH_FLD_L2TPV2_ALL_FIELDS \ - ((NH_FLD_L2TPV2_TYPE_BIT << 13) - 1) +#define NH_FLD_L2TPV2_TYPE_BIT BIT(0) +#define NH_FLD_L2TPV2_LENGTH_BIT BIT(1) +#define NH_FLD_L2TPV2_SEQUENCE_BIT BIT(2) +#define NH_FLD_L2TPV2_OFFSET_BIT BIT(3) +#define NH_FLD_L2TPV2_PRIORITY_BIT BIT(4) +#define NH_FLD_L2TPV2_VERSION BIT(5) +#define NH_FLD_L2TPV2_LEN BIT(6) +#define NH_FLD_L2TPV2_TUNNEL_ID BIT(7) +#define NH_FLD_L2TPV2_SESSION_ID BIT(8) +#define NH_FLD_L2TPV2_NS BIT(9) +#define NH_FLD_L2TPV2_NR BIT(10) +#define NH_FLD_L2TPV2_OFFSET_SIZE BIT(11) +#define NH_FLD_L2TPV2_FIRST_BYTE BIT(12) +#define NH_FLD_L2TPV2_ALL_FIELDS (BIT(13) - 1) /* L2TPV3 fields */ -#define NH_FLD_L2TPV3_CTRL_TYPE_BIT (1) -#define NH_FLD_L2TPV3_CTRL_LENGTH_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 1) -#define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 2) -#define NH_FLD_L2TPV3_CTRL_VERSION (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 3) -#define NH_FLD_L2TPV3_CTRL_LENGTH (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 4) -#define NH_FLD_L2TPV3_CTRL_CONTROL (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 5) -#define NH_FLD_L2TPV3_CTRL_SENT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 6) -#define NH_FLD_L2TPV3_CTRL_RECV (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 7) -#define NH_FLD_L2TPV3_CTRL_FIRST_BYTE (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 8) -#define NH_FLD_L2TPV3_CTRL_ALL_FIELDS \ - ((NH_FLD_L2TPV3_CTRL_TYPE_BIT << 9) - 1) +#define NH_FLD_L2TPV3_CTRL_TYPE_BIT BIT(0) +#define NH_FLD_L2TPV3_CTRL_LENGTH_BIT BIT(1) +#define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT BIT(2) +#define NH_FLD_L2TPV3_CTRL_VERSION BIT(3) +#define NH_FLD_L2TPV3_CTRL_LENGTH BIT(4) +#define NH_FLD_L2TPV3_CTRL_CONTROL BIT(5) +#define NH_FLD_L2TPV3_CTRL_SENT BIT(6) +#define NH_FLD_L2TPV3_CTRL_RECV BIT(7) +#define NH_FLD_L2TPV3_CTRL_FIRST_BYTE BIT(8) +#define NH_FLD_L2TPV3_CTRL_ALL_FIELDS (BIT(9) - 1) -#define NH_FLD_L2TPV3_SESS_TYPE_BIT (1) -#define NH_FLD_L2TPV3_SESS_VERSION (NH_FLD_L2TPV3_SESS_TYPE_BIT << 1) -#define NH_FLD_L2TPV3_SESS_ID (NH_FLD_L2TPV3_SESS_TYPE_BIT << 2) -#define NH_FLD_L2TPV3_SESS_COOKIE (NH_FLD_L2TPV3_SESS_TYPE_BIT << 3) -#define NH_FLD_L2TPV3_SESS_ALL_FIELDS \ - ((NH_FLD_L2TPV3_SESS_TYPE_BIT << 4) - 1) +#define NH_FLD_L2TPV3_SESS_TYPE_BIT BIT(0) +#define NH_FLD_L2TPV3_SESS_VERSION BIT(1) +#define NH_FLD_L2TPV3_SESS_ID BIT(2) +#define NH_FLD_L2TPV3_SESS_COOKIE BIT(3) +#define NH_FLD_L2TPV3_SESS_ALL_FIELDS (BIT(4) - 1) /* PPP fields */ -#define NH_FLD_PPP_PID (1) -#define NH_FLD_PPP_COMPRESSED (NH_FLD_PPP_PID << 1) -#define NH_FLD_PPP_ALL_FIELDS ((NH_FLD_PPP_PID << 2) - 1) +#define NH_FLD_PPP_PID BIT(0) +#define NH_FLD_PPP_COMPRESSED BIT(1) +#define NH_FLD_PPP_ALL_FIELDS (BIT(2) - 1) /* PPPoE fields */ -#define NH_FLD_PPPOE_VER (1) -#define NH_FLD_PPPOE_TYPE (NH_FLD_PPPOE_VER << 1) -#define NH_FLD_PPPOE_CODE (NH_FLD_PPPOE_VER << 2) -#define NH_FLD_PPPOE_SID (NH_FLD_PPPOE_VER << 3) -#define NH_FLD_PPPOE_LEN (NH_FLD_PPPOE_VER << 4) -#define NH_FLD_PPPOE_SESSION (NH_FLD_PPPOE_VER << 5) -#define NH_FLD_PPPOE_PID (NH_FLD_PPPOE_VER << 6) -#define NH_FLD_PPPOE_ALL_FIELDS ((NH_FLD_PPPOE_VER << 7) - 1) +#define NH_FLD_PPPOE_VER BIT(0) +#define NH_FLD_PPPOE_TYPE BIT(1) +#define NH_FLD_PPPOE_CODE BIT(2) +#define NH_FLD_PPPOE_SID BIT(3) +#define NH_FLD_PPPOE_LEN BIT(4) +#define NH_FLD_PPPOE_SESSION BIT(5) +#define NH_FLD_PPPOE_PID BIT(6) +#define NH_FLD_PPPOE_ALL_FIELDS (BIT(7) - 1) /* PPP-Mux fields */ -#define NH_FLD_PPPMUX_PID (1) -#define NH_FLD_PPPMUX_CKSUM (NH_FLD_PPPMUX_PID << 1) -#define NH_FLD_PPPMUX_COMPRESSED (NH_FLD_PPPMUX_PID << 2) -#define NH_FLD_PPPMUX_ALL_FIELDS ((NH_FLD_PPPMUX_PID << 3) - 1) +#define NH_FLD_PPPMUX_PID BIT(0) +#define NH_FLD_PPPMUX_CKSUM BIT(1) +#define NH_FLD_PPPMUX_COMPRESSED BIT(2) +#define NH_FLD_PPPMUX_ALL_FIELDS (BIT(3) - 1) /* PPP-Mux sub-frame fields */ -#define NH_FLD_PPPMUX_SUBFRM_PFF (1) -#define NH_FLD_PPPMUX_SUBFRM_LXT (NH_FLD_PPPMUX_SUBFRM_PFF << 1) -#define NH_FLD_PPPMUX_SUBFRM_LEN (NH_FLD_PPPMUX_SUBFRM_PFF << 2) -#define NH_FLD_PPPMUX_SUBFRM_PID (NH_FLD_PPPMUX_SUBFRM_PFF << 3) -#define NH_FLD_PPPMUX_SUBFRM_USE_PID (NH_FLD_PPPMUX_SUBFRM_PFF << 4) -#define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS \ - ((NH_FLD_PPPMUX_SUBFRM_PFF << 5) - 1) +#define NH_FLD_PPPMUX_SUBFRM_PFF BIT(0) +#define NH_FLD_PPPMUX_SUBFRM_LXT BIT(1) +#define NH_FLD_PPPMUX_SUBFRM_LEN BIT(2) +#define NH_FLD_PPPMUX_SUBFRM_PID BIT(3) +#define NH_FLD_PPPMUX_SUBFRM_USE_PID BIT(4) +#define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS (BIT(5) - 1) /* LLC fields */ -#define NH_FLD_LLC_DSAP (1) -#define NH_FLD_LLC_SSAP (NH_FLD_LLC_DSAP << 1) -#define NH_FLD_LLC_CTRL (NH_FLD_LLC_DSAP << 2) -#define NH_FLD_LLC_ALL_FIELDS ((NH_FLD_LLC_DSAP << 3) - 1) +#define NH_FLD_LLC_DSAP BIT(0) +#define NH_FLD_LLC_SSAP BIT(1) +#define NH_FLD_LLC_CTRL BIT(2) +#define NH_FLD_LLC_ALL_FIELDS (BIT(3) - 1) /* NLPID fields */ -#define NH_FLD_NLPID_NLPID (1) -#define NH_FLD_NLPID_ALL_FIELDS ((NH_FLD_NLPID_NLPID << 1) - 1) +#define NH_FLD_NLPID_NLPID BIT(0) +#define NH_FLD_NLPID_ALL_FIELDS (BIT(1) - 1) /* SNAP fields */ -#define NH_FLD_SNAP_OUI (1) -#define NH_FLD_SNAP_PID (NH_FLD_SNAP_OUI << 1) -#define NH_FLD_SNAP_ALL_FIELDS ((NH_FLD_SNAP_OUI << 2) - 1) +#define NH_FLD_SNAP_OUI BIT(0) +#define NH_FLD_SNAP_PID BIT(1) +#define NH_FLD_SNAP_ALL_FIELDS (BIT(2) - 1) /* LLC SNAP fields */ -#define NH_FLD_LLC_SNAP_TYPE (1) -#define NH_FLD_LLC_SNAP_ALL_FIELDS ((NH_FLD_LLC_SNAP_TYPE << 1) - 1) +#define NH_FLD_LLC_SNAP_TYPE BIT(0) +#define NH_FLD_LLC_SNAP_ALL_FIELDS (BIT(1) - 1) /* ARP fields */ -#define NH_FLD_ARP_HTYPE (1) -#define NH_FLD_ARP_PTYPE (NH_FLD_ARP_HTYPE << 1) -#define NH_FLD_ARP_HLEN (NH_FLD_ARP_HTYPE << 2) -#define NH_FLD_ARP_PLEN (NH_FLD_ARP_HTYPE << 3) -#define NH_FLD_ARP_OPER (NH_FLD_ARP_HTYPE << 4) -#define NH_FLD_ARP_SHA (NH_FLD_ARP_HTYPE << 5) -#define NH_FLD_ARP_SPA (NH_FLD_ARP_HTYPE << 6) -#define NH_FLD_ARP_THA (NH_FLD_ARP_HTYPE << 7) -#define NH_FLD_ARP_TPA (NH_FLD_ARP_HTYPE << 8) -#define NH_FLD_ARP_ALL_FIELDS ((NH_FLD_ARP_HTYPE << 9) - 1) +#define NH_FLD_ARP_HTYPE BIT(0) +#define NH_FLD_ARP_PTYPE BIT(1) +#define NH_FLD_ARP_HLEN BIT(2) +#define NH_FLD_ARP_PLEN BIT(3) +#define NH_FLD_ARP_OPER BIT(4) +#define NH_FLD_ARP_SHA BIT(5) +#define NH_FLD_ARP_SPA BIT(6) +#define NH_FLD_ARP_THA BIT(7) +#define NH_FLD_ARP_TPA BIT(8) +#define NH_FLD_ARP_ALL_FIELDS (BIT(9) - 1) /* RFC2684 fields */ -#define NH_FLD_RFC2684_LLC (1) -#define NH_FLD_RFC2684_NLPID (NH_FLD_RFC2684_LLC << 1) -#define NH_FLD_RFC2684_OUI (NH_FLD_RFC2684_LLC << 2) -#define NH_FLD_RFC2684_PID (NH_FLD_RFC2684_LLC << 3) -#define NH_FLD_RFC2684_VPN_OUI (NH_FLD_RFC2684_LLC << 4) -#define NH_FLD_RFC2684_VPN_IDX (NH_FLD_RFC2684_LLC << 5) -#define NH_FLD_RFC2684_ALL_FIELDS ((NH_FLD_RFC2684_LLC << 6) - 1) +#define NH_FLD_RFC2684_LLC BIT(0) +#define NH_FLD_RFC2684_NLPID BIT(1) +#define NH_FLD_RFC2684_OUI BIT(2) +#define NH_FLD_RFC2684_PID BIT(3) +#define NH_FLD_RFC2684_VPN_OUI BIT(4) +#define NH_FLD_RFC2684_VPN_IDX BIT(5) +#define NH_FLD_RFC2684_ALL_FIELDS (BIT(6) - 1) /* User defined fields */ -#define NH_FLD_USER_DEFINED_SRCPORT (1) -#define NH_FLD_USER_DEFINED_PCDID (NH_FLD_USER_DEFINED_SRCPORT << 1) -#define NH_FLD_USER_DEFINED_ALL_FIELDS \ - ((NH_FLD_USER_DEFINED_SRCPORT << 2) - 1) +#define NH_FLD_USER_DEFINED_SRCPORT BIT(0) +#define NH_FLD_USER_DEFINED_PCDID BIT(1) +#define NH_FLD_USER_DEFINED_ALL_FIELDS (BIT(2) - 1) /* Payload fields */ -#define NH_FLD_PAYLOAD_BUFFER (1) -#define NH_FLD_PAYLOAD_SIZE (NH_FLD_PAYLOAD_BUFFER << 1) -#define NH_FLD_MAX_FRM_SIZE (NH_FLD_PAYLOAD_BUFFER << 2) -#define NH_FLD_MIN_FRM_SIZE (NH_FLD_PAYLOAD_BUFFER << 3) -#define NH_FLD_PAYLOAD_TYPE (NH_FLD_PAYLOAD_BUFFER << 4) -#define NH_FLD_FRAME_SIZE (NH_FLD_PAYLOAD_BUFFER << 5) -#define NH_FLD_PAYLOAD_ALL_FIELDS ((NH_FLD_PAYLOAD_BUFFER << 6) - 1) +#define NH_FLD_PAYLOAD_BUFFER BIT(0) +#define NH_FLD_PAYLOAD_SIZE BIT(1) +#define NH_FLD_MAX_FRM_SIZE BIT(2) +#define NH_FLD_MIN_FRM_SIZE BIT(3) +#define NH_FLD_PAYLOAD_TYPE BIT(4) +#define NH_FLD_FRAME_SIZE BIT(5) +#define NH_FLD_PAYLOAD_ALL_FIELDS (BIT(6) - 1) /* GRE fields */ -#define NH_FLD_GRE_TYPE (1) -#define NH_FLD_GRE_ALL_FIELDS ((NH_FLD_GRE_TYPE << 1) - 1) +#define NH_FLD_GRE_TYPE BIT(0) +#define NH_FLD_GRE_ALL_FIELDS (BIT(1) - 1) /* MINENCAP fields */ -#define NH_FLD_MINENCAP_SRC_IP (1) -#define NH_FLD_MINENCAP_DST_IP (NH_FLD_MINENCAP_SRC_IP << 1) -#define NH_FLD_MINENCAP_TYPE (NH_FLD_MINENCAP_SRC_IP << 2) -#define NH_FLD_MINENCAP_ALL_FIELDS \ - ((NH_FLD_MINENCAP_SRC_IP << 3) - 1) +#define NH_FLD_MINENCAP_SRC_IP BIT(0) +#define NH_FLD_MINENCAP_DST_IP BIT(1) +#define NH_FLD_MINENCAP_TYPE BIT(2) +#define NH_FLD_MINENCAP_ALL_FIELDS (BIT(3) - 1) /* IPSEC AH fields */ -#define NH_FLD_IPSEC_AH_SPI (1) -#define NH_FLD_IPSEC_AH_NH (NH_FLD_IPSEC_AH_SPI << 1) -#define NH_FLD_IPSEC_AH_ALL_FIELDS ((NH_FLD_IPSEC_AH_SPI << 2) - 1) +#define NH_FLD_IPSEC_AH_SPI BIT(0) +#define NH_FLD_IPSEC_AH_NH BIT(1) +#define NH_FLD_IPSEC_AH_ALL_FIELDS (BIT(2) - 1) /* IPSEC ESP fields */ -#define NH_FLD_IPSEC_ESP_SPI (1) -#define NH_FLD_IPSEC_ESP_SEQUENCE_NUM (NH_FLD_IPSEC_ESP_SPI << 1) -#define NH_FLD_IPSEC_ESP_ALL_FIELDS ((NH_FLD_IPSEC_ESP_SPI << 2) - 1) +#define NH_FLD_IPSEC_ESP_SPI BIT(0) +#define NH_FLD_IPSEC_ESP_SEQUENCE_NUM BIT(1) +#define NH_FLD_IPSEC_ESP_ALL_FIELDS (BIT(2) - 1) /* MPLS fields */ -#define NH_FLD_MPLS_LABEL_STACK (1) -#define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS \ - ((NH_FLD_MPLS_LABEL_STACK << 1) - 1) +#define NH_FLD_MPLS_LABEL_STACK BIT(0) +#define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS (BIT(1) - 1) /* MACSEC fields */ -#define NH_FLD_MACSEC_SECTAG (1) -#define NH_FLD_MACSEC_ALL_FIELDS ((NH_FLD_MACSEC_SECTAG << 1) - 1) +#define NH_FLD_MACSEC_SECTAG BIT(0) +#define NH_FLD_MACSEC_ALL_FIELDS (BIT(1) - 1) /* GTP fields */ -#define NH_FLD_GTP_TEID (1) +#define NH_FLD_GTP_TEID BIT(0) /* Supported protocols */ enum net_prot { From c3e39b07f64d56992080f8f634632dcfa7dfc85d Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Wed, 1 Aug 2018 11:09:51 -0500 Subject: [PATCH 781/903] staging: fsl-dpaa2/eth: Merge header files File net.h contains definitions that are exclusively used by the key generator/classification API. Merge its contents with dpkg.h in order to reduce the number of private headers. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpkg.h | 350 ++++++++++++++++++++- drivers/staging/fsl-dpaa2/ethernet/net.h | 357 ---------------------- 2 files changed, 349 insertions(+), 358 deletions(-) delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/net.h diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h index 099ff02b4b1a..6de613b13e4d 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h @@ -5,7 +5,6 @@ #define __FSL_DPKG_H_ #include -#include "net.h" /* Data Path Key Generator API * Contains initialization APIs and runtime APIs for the Key Generator @@ -58,6 +57,355 @@ struct dpkg_mask { u8 offset; }; +/* Protocol fields */ + +/* Ethernet fields */ +#define NH_FLD_ETH_DA BIT(0) +#define NH_FLD_ETH_SA BIT(1) +#define NH_FLD_ETH_LENGTH BIT(2) +#define NH_FLD_ETH_TYPE BIT(3) +#define NH_FLD_ETH_FINAL_CKSUM BIT(4) +#define NH_FLD_ETH_PADDING BIT(5) +#define NH_FLD_ETH_ALL_FIELDS (BIT(6) - 1) + +/* VLAN fields */ +#define NH_FLD_VLAN_VPRI BIT(0) +#define NH_FLD_VLAN_CFI BIT(1) +#define NH_FLD_VLAN_VID BIT(2) +#define NH_FLD_VLAN_LENGTH BIT(3) +#define NH_FLD_VLAN_TYPE BIT(4) +#define NH_FLD_VLAN_ALL_FIELDS (BIT(5) - 1) + +#define NH_FLD_VLAN_TCI (NH_FLD_VLAN_VPRI | \ + NH_FLD_VLAN_CFI | \ + NH_FLD_VLAN_VID) + +/* IP (generic) fields */ +#define NH_FLD_IP_VER BIT(0) +#define NH_FLD_IP_DSCP BIT(2) +#define NH_FLD_IP_ECN BIT(3) +#define NH_FLD_IP_PROTO BIT(4) +#define NH_FLD_IP_SRC BIT(5) +#define NH_FLD_IP_DST BIT(6) +#define NH_FLD_IP_TOS_TC BIT(7) +#define NH_FLD_IP_ID BIT(8) +#define NH_FLD_IP_ALL_FIELDS (BIT(9) - 1) + +/* IPV4 fields */ +#define NH_FLD_IPV4_VER BIT(0) +#define NH_FLD_IPV4_HDR_LEN BIT(1) +#define NH_FLD_IPV4_TOS BIT(2) +#define NH_FLD_IPV4_TOTAL_LEN BIT(3) +#define NH_FLD_IPV4_ID BIT(4) +#define NH_FLD_IPV4_FLAG_D BIT(5) +#define NH_FLD_IPV4_FLAG_M BIT(6) +#define NH_FLD_IPV4_OFFSET BIT(7) +#define NH_FLD_IPV4_TTL BIT(8) +#define NH_FLD_IPV4_PROTO BIT(9) +#define NH_FLD_IPV4_CKSUM BIT(10) +#define NH_FLD_IPV4_SRC_IP BIT(11) +#define NH_FLD_IPV4_DST_IP BIT(12) +#define NH_FLD_IPV4_OPTS BIT(13) +#define NH_FLD_IPV4_OPTS_COUNT BIT(14) +#define NH_FLD_IPV4_ALL_FIELDS (BIT(15) - 1) + +/* IPV6 fields */ +#define NH_FLD_IPV6_VER BIT(0) +#define NH_FLD_IPV6_TC BIT(1) +#define NH_FLD_IPV6_SRC_IP BIT(2) +#define NH_FLD_IPV6_DST_IP BIT(3) +#define NH_FLD_IPV6_NEXT_HDR BIT(4) +#define NH_FLD_IPV6_FL BIT(5) +#define NH_FLD_IPV6_HOP_LIMIT BIT(6) +#define NH_FLD_IPV6_ID BIT(7) +#define NH_FLD_IPV6_ALL_FIELDS (BIT(8) - 1) + +/* ICMP fields */ +#define NH_FLD_ICMP_TYPE BIT(0) +#define NH_FLD_ICMP_CODE BIT(1) +#define NH_FLD_ICMP_CKSUM BIT(2) +#define NH_FLD_ICMP_ID BIT(3) +#define NH_FLD_ICMP_SQ_NUM BIT(4) +#define NH_FLD_ICMP_ALL_FIELDS (BIT(5) - 1) + +/* IGMP fields */ +#define NH_FLD_IGMP_VERSION BIT(0) +#define NH_FLD_IGMP_TYPE BIT(1) +#define NH_FLD_IGMP_CKSUM BIT(2) +#define NH_FLD_IGMP_DATA BIT(3) +#define NH_FLD_IGMP_ALL_FIELDS (BIT(4) - 1) + +/* TCP fields */ +#define NH_FLD_TCP_PORT_SRC BIT(0) +#define NH_FLD_TCP_PORT_DST BIT(1) +#define NH_FLD_TCP_SEQ BIT(2) +#define NH_FLD_TCP_ACK BIT(3) +#define NH_FLD_TCP_OFFSET BIT(4) +#define NH_FLD_TCP_FLAGS BIT(5) +#define NH_FLD_TCP_WINDOW BIT(6) +#define NH_FLD_TCP_CKSUM BIT(7) +#define NH_FLD_TCP_URGPTR BIT(8) +#define NH_FLD_TCP_OPTS BIT(9) +#define NH_FLD_TCP_OPTS_COUNT BIT(10) +#define NH_FLD_TCP_ALL_FIELDS (BIT(11) - 1) + +/* UDP fields */ +#define NH_FLD_UDP_PORT_SRC BIT(0) +#define NH_FLD_UDP_PORT_DST BIT(1) +#define NH_FLD_UDP_LEN BIT(2) +#define NH_FLD_UDP_CKSUM BIT(3) +#define NH_FLD_UDP_ALL_FIELDS (BIT(4) - 1) + +/* UDP-lite fields */ +#define NH_FLD_UDP_LITE_PORT_SRC BIT(0) +#define NH_FLD_UDP_LITE_PORT_DST BIT(1) +#define NH_FLD_UDP_LITE_ALL_FIELDS (BIT(2) - 1) + +/* UDP-encap-ESP fields */ +#define NH_FLD_UDP_ENC_ESP_PORT_SRC BIT(0) +#define NH_FLD_UDP_ENC_ESP_PORT_DST BIT(1) +#define NH_FLD_UDP_ENC_ESP_LEN BIT(2) +#define NH_FLD_UDP_ENC_ESP_CKSUM BIT(3) +#define NH_FLD_UDP_ENC_ESP_SPI BIT(4) +#define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM BIT(5) +#define NH_FLD_UDP_ENC_ESP_ALL_FIELDS (BIT(6) - 1) + +/* SCTP fields */ +#define NH_FLD_SCTP_PORT_SRC BIT(0) +#define NH_FLD_SCTP_PORT_DST BIT(1) +#define NH_FLD_SCTP_VER_TAG BIT(2) +#define NH_FLD_SCTP_CKSUM BIT(3) +#define NH_FLD_SCTP_ALL_FIELDS (BIT(4) - 1) + +/* DCCP fields */ +#define NH_FLD_DCCP_PORT_SRC BIT(0) +#define NH_FLD_DCCP_PORT_DST BIT(1) +#define NH_FLD_DCCP_ALL_FIELDS (BIT(2) - 1) + +/* IPHC fields */ +#define NH_FLD_IPHC_CID BIT(0) +#define NH_FLD_IPHC_CID_TYPE BIT(1) +#define NH_FLD_IPHC_HCINDEX BIT(2) +#define NH_FLD_IPHC_GEN BIT(3) +#define NH_FLD_IPHC_D_BIT BIT(4) +#define NH_FLD_IPHC_ALL_FIELDS (BIT(5) - 1) + +/* SCTP fields */ +#define NH_FLD_SCTP_CHUNK_DATA_TYPE BIT(0) +#define NH_FLD_SCTP_CHUNK_DATA_FLAGS BIT(1) +#define NH_FLD_SCTP_CHUNK_DATA_LENGTH BIT(2) +#define NH_FLD_SCTP_CHUNK_DATA_TSN BIT(3) +#define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID BIT(4) +#define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN BIT(5) +#define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID BIT(6) +#define NH_FLD_SCTP_CHUNK_DATA_UNORDERED BIT(7) +#define NH_FLD_SCTP_CHUNK_DATA_BEGGINING BIT(8) +#define NH_FLD_SCTP_CHUNK_DATA_END BIT(9) +#define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS (BIT(10) - 1) + +/* L2TPV2 fields */ +#define NH_FLD_L2TPV2_TYPE_BIT BIT(0) +#define NH_FLD_L2TPV2_LENGTH_BIT BIT(1) +#define NH_FLD_L2TPV2_SEQUENCE_BIT BIT(2) +#define NH_FLD_L2TPV2_OFFSET_BIT BIT(3) +#define NH_FLD_L2TPV2_PRIORITY_BIT BIT(4) +#define NH_FLD_L2TPV2_VERSION BIT(5) +#define NH_FLD_L2TPV2_LEN BIT(6) +#define NH_FLD_L2TPV2_TUNNEL_ID BIT(7) +#define NH_FLD_L2TPV2_SESSION_ID BIT(8) +#define NH_FLD_L2TPV2_NS BIT(9) +#define NH_FLD_L2TPV2_NR BIT(10) +#define NH_FLD_L2TPV2_OFFSET_SIZE BIT(11) +#define NH_FLD_L2TPV2_FIRST_BYTE BIT(12) +#define NH_FLD_L2TPV2_ALL_FIELDS (BIT(13) - 1) + +/* L2TPV3 fields */ +#define NH_FLD_L2TPV3_CTRL_TYPE_BIT BIT(0) +#define NH_FLD_L2TPV3_CTRL_LENGTH_BIT BIT(1) +#define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT BIT(2) +#define NH_FLD_L2TPV3_CTRL_VERSION BIT(3) +#define NH_FLD_L2TPV3_CTRL_LENGTH BIT(4) +#define NH_FLD_L2TPV3_CTRL_CONTROL BIT(5) +#define NH_FLD_L2TPV3_CTRL_SENT BIT(6) +#define NH_FLD_L2TPV3_CTRL_RECV BIT(7) +#define NH_FLD_L2TPV3_CTRL_FIRST_BYTE BIT(8) +#define NH_FLD_L2TPV3_CTRL_ALL_FIELDS (BIT(9) - 1) + +#define NH_FLD_L2TPV3_SESS_TYPE_BIT BIT(0) +#define NH_FLD_L2TPV3_SESS_VERSION BIT(1) +#define NH_FLD_L2TPV3_SESS_ID BIT(2) +#define NH_FLD_L2TPV3_SESS_COOKIE BIT(3) +#define NH_FLD_L2TPV3_SESS_ALL_FIELDS (BIT(4) - 1) + +/* PPP fields */ +#define NH_FLD_PPP_PID BIT(0) +#define NH_FLD_PPP_COMPRESSED BIT(1) +#define NH_FLD_PPP_ALL_FIELDS (BIT(2) - 1) + +/* PPPoE fields */ +#define NH_FLD_PPPOE_VER BIT(0) +#define NH_FLD_PPPOE_TYPE BIT(1) +#define NH_FLD_PPPOE_CODE BIT(2) +#define NH_FLD_PPPOE_SID BIT(3) +#define NH_FLD_PPPOE_LEN BIT(4) +#define NH_FLD_PPPOE_SESSION BIT(5) +#define NH_FLD_PPPOE_PID BIT(6) +#define NH_FLD_PPPOE_ALL_FIELDS (BIT(7) - 1) + +/* PPP-Mux fields */ +#define NH_FLD_PPPMUX_PID BIT(0) +#define NH_FLD_PPPMUX_CKSUM BIT(1) +#define NH_FLD_PPPMUX_COMPRESSED BIT(2) +#define NH_FLD_PPPMUX_ALL_FIELDS (BIT(3) - 1) + +/* PPP-Mux sub-frame fields */ +#define NH_FLD_PPPMUX_SUBFRM_PFF BIT(0) +#define NH_FLD_PPPMUX_SUBFRM_LXT BIT(1) +#define NH_FLD_PPPMUX_SUBFRM_LEN BIT(2) +#define NH_FLD_PPPMUX_SUBFRM_PID BIT(3) +#define NH_FLD_PPPMUX_SUBFRM_USE_PID BIT(4) +#define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS (BIT(5) - 1) + +/* LLC fields */ +#define NH_FLD_LLC_DSAP BIT(0) +#define NH_FLD_LLC_SSAP BIT(1) +#define NH_FLD_LLC_CTRL BIT(2) +#define NH_FLD_LLC_ALL_FIELDS (BIT(3) - 1) + +/* NLPID fields */ +#define NH_FLD_NLPID_NLPID BIT(0) +#define NH_FLD_NLPID_ALL_FIELDS (BIT(1) - 1) + +/* SNAP fields */ +#define NH_FLD_SNAP_OUI BIT(0) +#define NH_FLD_SNAP_PID BIT(1) +#define NH_FLD_SNAP_ALL_FIELDS (BIT(2) - 1) + +/* LLC SNAP fields */ +#define NH_FLD_LLC_SNAP_TYPE BIT(0) +#define NH_FLD_LLC_SNAP_ALL_FIELDS (BIT(1) - 1) + +/* ARP fields */ +#define NH_FLD_ARP_HTYPE BIT(0) +#define NH_FLD_ARP_PTYPE BIT(1) +#define NH_FLD_ARP_HLEN BIT(2) +#define NH_FLD_ARP_PLEN BIT(3) +#define NH_FLD_ARP_OPER BIT(4) +#define NH_FLD_ARP_SHA BIT(5) +#define NH_FLD_ARP_SPA BIT(6) +#define NH_FLD_ARP_THA BIT(7) +#define NH_FLD_ARP_TPA BIT(8) +#define NH_FLD_ARP_ALL_FIELDS (BIT(9) - 1) + +/* RFC2684 fields */ +#define NH_FLD_RFC2684_LLC BIT(0) +#define NH_FLD_RFC2684_NLPID BIT(1) +#define NH_FLD_RFC2684_OUI BIT(2) +#define NH_FLD_RFC2684_PID BIT(3) +#define NH_FLD_RFC2684_VPN_OUI BIT(4) +#define NH_FLD_RFC2684_VPN_IDX BIT(5) +#define NH_FLD_RFC2684_ALL_FIELDS (BIT(6) - 1) + +/* User defined fields */ +#define NH_FLD_USER_DEFINED_SRCPORT BIT(0) +#define NH_FLD_USER_DEFINED_PCDID BIT(1) +#define NH_FLD_USER_DEFINED_ALL_FIELDS (BIT(2) - 1) + +/* Payload fields */ +#define NH_FLD_PAYLOAD_BUFFER BIT(0) +#define NH_FLD_PAYLOAD_SIZE BIT(1) +#define NH_FLD_MAX_FRM_SIZE BIT(2) +#define NH_FLD_MIN_FRM_SIZE BIT(3) +#define NH_FLD_PAYLOAD_TYPE BIT(4) +#define NH_FLD_FRAME_SIZE BIT(5) +#define NH_FLD_PAYLOAD_ALL_FIELDS (BIT(6) - 1) + +/* GRE fields */ +#define NH_FLD_GRE_TYPE BIT(0) +#define NH_FLD_GRE_ALL_FIELDS (BIT(1) - 1) + +/* MINENCAP fields */ +#define NH_FLD_MINENCAP_SRC_IP BIT(0) +#define NH_FLD_MINENCAP_DST_IP BIT(1) +#define NH_FLD_MINENCAP_TYPE BIT(2) +#define NH_FLD_MINENCAP_ALL_FIELDS (BIT(3) - 1) + +/* IPSEC AH fields */ +#define NH_FLD_IPSEC_AH_SPI BIT(0) +#define NH_FLD_IPSEC_AH_NH BIT(1) +#define NH_FLD_IPSEC_AH_ALL_FIELDS (BIT(2) - 1) + +/* IPSEC ESP fields */ +#define NH_FLD_IPSEC_ESP_SPI BIT(0) +#define NH_FLD_IPSEC_ESP_SEQUENCE_NUM BIT(1) +#define NH_FLD_IPSEC_ESP_ALL_FIELDS (BIT(2) - 1) + +/* MPLS fields */ +#define NH_FLD_MPLS_LABEL_STACK BIT(0) +#define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS (BIT(1) - 1) + +/* MACSEC fields */ +#define NH_FLD_MACSEC_SECTAG BIT(0) +#define NH_FLD_MACSEC_ALL_FIELDS (BIT(1) - 1) + +/* GTP fields */ +#define NH_FLD_GTP_TEID BIT(0) + +/* Supported protocols */ +enum net_prot { + NET_PROT_NONE = 0, + NET_PROT_PAYLOAD, + NET_PROT_ETH, + NET_PROT_VLAN, + NET_PROT_IPV4, + NET_PROT_IPV6, + NET_PROT_IP, + NET_PROT_TCP, + NET_PROT_UDP, + NET_PROT_UDP_LITE, + NET_PROT_IPHC, + NET_PROT_SCTP, + NET_PROT_SCTP_CHUNK_DATA, + NET_PROT_PPPOE, + NET_PROT_PPP, + NET_PROT_PPPMUX, + NET_PROT_PPPMUX_SUBFRM, + NET_PROT_L2TPV2, + NET_PROT_L2TPV3_CTRL, + NET_PROT_L2TPV3_SESS, + NET_PROT_LLC, + NET_PROT_LLC_SNAP, + NET_PROT_NLPID, + NET_PROT_SNAP, + NET_PROT_MPLS, + NET_PROT_IPSEC_AH, + NET_PROT_IPSEC_ESP, + NET_PROT_UDP_ENC_ESP, /* RFC 3948 */ + NET_PROT_MACSEC, + NET_PROT_GRE, + NET_PROT_MINENCAP, + NET_PROT_DCCP, + NET_PROT_ICMP, + NET_PROT_IGMP, + NET_PROT_ARP, + NET_PROT_CAPWAP_DATA, + NET_PROT_CAPWAP_CTRL, + NET_PROT_RFC2684, + NET_PROT_ICMPV6, + NET_PROT_FCOE, + NET_PROT_FIP, + NET_PROT_ISCSI, + NET_PROT_GTP, + NET_PROT_USER_DEFINED_L2, + NET_PROT_USER_DEFINED_L3, + NET_PROT_USER_DEFINED_L4, + NET_PROT_USER_DEFINED_L5, + NET_PROT_USER_DEFINED_SHIM1, + NET_PROT_USER_DEFINED_SHIM2, + + NET_PROT_DUMMY_LAST +}; + /** * struct dpkg_extract - A structure for defining a single extraction * @type: Determines how the union below is interpreted: diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h b/drivers/staging/fsl-dpaa2/ethernet/net.h deleted file mode 100644 index 81f5a91f4a93..000000000000 --- a/drivers/staging/fsl-dpaa2/ethernet/net.h +++ /dev/null @@ -1,357 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ -/* Copyright 2013-2015 Freescale Semiconductor Inc. - */ -#ifndef __FSL_NET_H -#define __FSL_NET_H - -/* Protocol fields */ - -/* Ethernet fields */ -#define NH_FLD_ETH_DA BIT(0) -#define NH_FLD_ETH_SA BIT(1) -#define NH_FLD_ETH_LENGTH BIT(2) -#define NH_FLD_ETH_TYPE BIT(3) -#define NH_FLD_ETH_FINAL_CKSUM BIT(4) -#define NH_FLD_ETH_PADDING BIT(5) -#define NH_FLD_ETH_ALL_FIELDS (BIT(6) - 1) - -/* VLAN fields */ -#define NH_FLD_VLAN_VPRI BIT(0) -#define NH_FLD_VLAN_CFI BIT(1) -#define NH_FLD_VLAN_VID BIT(2) -#define NH_FLD_VLAN_LENGTH BIT(3) -#define NH_FLD_VLAN_TYPE BIT(4) -#define NH_FLD_VLAN_ALL_FIELDS (BIT(5) - 1) - -#define NH_FLD_VLAN_TCI (NH_FLD_VLAN_VPRI | \ - NH_FLD_VLAN_CFI | \ - NH_FLD_VLAN_VID) - -/* IP (generic) fields */ -#define NH_FLD_IP_VER BIT(0) -#define NH_FLD_IP_DSCP BIT(2) -#define NH_FLD_IP_ECN BIT(3) -#define NH_FLD_IP_PROTO BIT(4) -#define NH_FLD_IP_SRC BIT(5) -#define NH_FLD_IP_DST BIT(6) -#define NH_FLD_IP_TOS_TC BIT(7) -#define NH_FLD_IP_ID BIT(8) -#define NH_FLD_IP_ALL_FIELDS (BIT(9) - 1) - -/* IPV4 fields */ -#define NH_FLD_IPV4_VER BIT(0) -#define NH_FLD_IPV4_HDR_LEN BIT(1) -#define NH_FLD_IPV4_TOS BIT(2) -#define NH_FLD_IPV4_TOTAL_LEN BIT(3) -#define NH_FLD_IPV4_ID BIT(4) -#define NH_FLD_IPV4_FLAG_D BIT(5) -#define NH_FLD_IPV4_FLAG_M BIT(6) -#define NH_FLD_IPV4_OFFSET BIT(7) -#define NH_FLD_IPV4_TTL BIT(8) -#define NH_FLD_IPV4_PROTO BIT(9) -#define NH_FLD_IPV4_CKSUM BIT(10) -#define NH_FLD_IPV4_SRC_IP BIT(11) -#define NH_FLD_IPV4_DST_IP BIT(12) -#define NH_FLD_IPV4_OPTS BIT(13) -#define NH_FLD_IPV4_OPTS_COUNT BIT(14) -#define NH_FLD_IPV4_ALL_FIELDS (BIT(15) - 1) - -/* IPV6 fields */ -#define NH_FLD_IPV6_VER BIT(0) -#define NH_FLD_IPV6_TC BIT(1) -#define NH_FLD_IPV6_SRC_IP BIT(2) -#define NH_FLD_IPV6_DST_IP BIT(3) -#define NH_FLD_IPV6_NEXT_HDR BIT(4) -#define NH_FLD_IPV6_FL BIT(5) -#define NH_FLD_IPV6_HOP_LIMIT BIT(6) -#define NH_FLD_IPV6_ID BIT(7) -#define NH_FLD_IPV6_ALL_FIELDS (BIT(8) - 1) - -/* ICMP fields */ -#define NH_FLD_ICMP_TYPE BIT(0) -#define NH_FLD_ICMP_CODE BIT(1) -#define NH_FLD_ICMP_CKSUM BIT(2) -#define NH_FLD_ICMP_ID BIT(3) -#define NH_FLD_ICMP_SQ_NUM BIT(4) -#define NH_FLD_ICMP_ALL_FIELDS (BIT(5) - 1) - -/* IGMP fields */ -#define NH_FLD_IGMP_VERSION BIT(0) -#define NH_FLD_IGMP_TYPE BIT(1) -#define NH_FLD_IGMP_CKSUM BIT(2) -#define NH_FLD_IGMP_DATA BIT(3) -#define NH_FLD_IGMP_ALL_FIELDS (BIT(4) - 1) - -/* TCP fields */ -#define NH_FLD_TCP_PORT_SRC BIT(0) -#define NH_FLD_TCP_PORT_DST BIT(1) -#define NH_FLD_TCP_SEQ BIT(2) -#define NH_FLD_TCP_ACK BIT(3) -#define NH_FLD_TCP_OFFSET BIT(4) -#define NH_FLD_TCP_FLAGS BIT(5) -#define NH_FLD_TCP_WINDOW BIT(6) -#define NH_FLD_TCP_CKSUM BIT(7) -#define NH_FLD_TCP_URGPTR BIT(8) -#define NH_FLD_TCP_OPTS BIT(9) -#define NH_FLD_TCP_OPTS_COUNT BIT(10) -#define NH_FLD_TCP_ALL_FIELDS (BIT(11) - 1) - -/* UDP fields */ -#define NH_FLD_UDP_PORT_SRC BIT(0) -#define NH_FLD_UDP_PORT_DST BIT(1) -#define NH_FLD_UDP_LEN BIT(2) -#define NH_FLD_UDP_CKSUM BIT(3) -#define NH_FLD_UDP_ALL_FIELDS (BIT(4) - 1) - -/* UDP-lite fields */ -#define NH_FLD_UDP_LITE_PORT_SRC BIT(0) -#define NH_FLD_UDP_LITE_PORT_DST BIT(1) -#define NH_FLD_UDP_LITE_ALL_FIELDS (BIT(2) - 1) - -/* UDP-encap-ESP fields */ -#define NH_FLD_UDP_ENC_ESP_PORT_SRC BIT(0) -#define NH_FLD_UDP_ENC_ESP_PORT_DST BIT(1) -#define NH_FLD_UDP_ENC_ESP_LEN BIT(2) -#define NH_FLD_UDP_ENC_ESP_CKSUM BIT(3) -#define NH_FLD_UDP_ENC_ESP_SPI BIT(4) -#define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM BIT(5) -#define NH_FLD_UDP_ENC_ESP_ALL_FIELDS (BIT(6) - 1) - -/* SCTP fields */ -#define NH_FLD_SCTP_PORT_SRC BIT(0) -#define NH_FLD_SCTP_PORT_DST BIT(1) -#define NH_FLD_SCTP_VER_TAG BIT(2) -#define NH_FLD_SCTP_CKSUM BIT(3) -#define NH_FLD_SCTP_ALL_FIELDS (BIT(4) - 1) - -/* DCCP fields */ -#define NH_FLD_DCCP_PORT_SRC BIT(0) -#define NH_FLD_DCCP_PORT_DST BIT(1) -#define NH_FLD_DCCP_ALL_FIELDS (BIT(2) - 1) - -/* IPHC fields */ -#define NH_FLD_IPHC_CID BIT(0) -#define NH_FLD_IPHC_CID_TYPE BIT(1) -#define NH_FLD_IPHC_HCINDEX BIT(2) -#define NH_FLD_IPHC_GEN BIT(3) -#define NH_FLD_IPHC_D_BIT BIT(4) -#define NH_FLD_IPHC_ALL_FIELDS (BIT(5) - 1) - -/* SCTP fields */ -#define NH_FLD_SCTP_CHUNK_DATA_TYPE BIT(0) -#define NH_FLD_SCTP_CHUNK_DATA_FLAGS BIT(1) -#define NH_FLD_SCTP_CHUNK_DATA_LENGTH BIT(2) -#define NH_FLD_SCTP_CHUNK_DATA_TSN BIT(3) -#define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID BIT(4) -#define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN BIT(5) -#define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID BIT(6) -#define NH_FLD_SCTP_CHUNK_DATA_UNORDERED BIT(7) -#define NH_FLD_SCTP_CHUNK_DATA_BEGGINING BIT(8) -#define NH_FLD_SCTP_CHUNK_DATA_END BIT(9) -#define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS (BIT(10) - 1) - -/* L2TPV2 fields */ -#define NH_FLD_L2TPV2_TYPE_BIT BIT(0) -#define NH_FLD_L2TPV2_LENGTH_BIT BIT(1) -#define NH_FLD_L2TPV2_SEQUENCE_BIT BIT(2) -#define NH_FLD_L2TPV2_OFFSET_BIT BIT(3) -#define NH_FLD_L2TPV2_PRIORITY_BIT BIT(4) -#define NH_FLD_L2TPV2_VERSION BIT(5) -#define NH_FLD_L2TPV2_LEN BIT(6) -#define NH_FLD_L2TPV2_TUNNEL_ID BIT(7) -#define NH_FLD_L2TPV2_SESSION_ID BIT(8) -#define NH_FLD_L2TPV2_NS BIT(9) -#define NH_FLD_L2TPV2_NR BIT(10) -#define NH_FLD_L2TPV2_OFFSET_SIZE BIT(11) -#define NH_FLD_L2TPV2_FIRST_BYTE BIT(12) -#define NH_FLD_L2TPV2_ALL_FIELDS (BIT(13) - 1) - -/* L2TPV3 fields */ -#define NH_FLD_L2TPV3_CTRL_TYPE_BIT BIT(0) -#define NH_FLD_L2TPV3_CTRL_LENGTH_BIT BIT(1) -#define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT BIT(2) -#define NH_FLD_L2TPV3_CTRL_VERSION BIT(3) -#define NH_FLD_L2TPV3_CTRL_LENGTH BIT(4) -#define NH_FLD_L2TPV3_CTRL_CONTROL BIT(5) -#define NH_FLD_L2TPV3_CTRL_SENT BIT(6) -#define NH_FLD_L2TPV3_CTRL_RECV BIT(7) -#define NH_FLD_L2TPV3_CTRL_FIRST_BYTE BIT(8) -#define NH_FLD_L2TPV3_CTRL_ALL_FIELDS (BIT(9) - 1) - -#define NH_FLD_L2TPV3_SESS_TYPE_BIT BIT(0) -#define NH_FLD_L2TPV3_SESS_VERSION BIT(1) -#define NH_FLD_L2TPV3_SESS_ID BIT(2) -#define NH_FLD_L2TPV3_SESS_COOKIE BIT(3) -#define NH_FLD_L2TPV3_SESS_ALL_FIELDS (BIT(4) - 1) - -/* PPP fields */ -#define NH_FLD_PPP_PID BIT(0) -#define NH_FLD_PPP_COMPRESSED BIT(1) -#define NH_FLD_PPP_ALL_FIELDS (BIT(2) - 1) - -/* PPPoE fields */ -#define NH_FLD_PPPOE_VER BIT(0) -#define NH_FLD_PPPOE_TYPE BIT(1) -#define NH_FLD_PPPOE_CODE BIT(2) -#define NH_FLD_PPPOE_SID BIT(3) -#define NH_FLD_PPPOE_LEN BIT(4) -#define NH_FLD_PPPOE_SESSION BIT(5) -#define NH_FLD_PPPOE_PID BIT(6) -#define NH_FLD_PPPOE_ALL_FIELDS (BIT(7) - 1) - -/* PPP-Mux fields */ -#define NH_FLD_PPPMUX_PID BIT(0) -#define NH_FLD_PPPMUX_CKSUM BIT(1) -#define NH_FLD_PPPMUX_COMPRESSED BIT(2) -#define NH_FLD_PPPMUX_ALL_FIELDS (BIT(3) - 1) - -/* PPP-Mux sub-frame fields */ -#define NH_FLD_PPPMUX_SUBFRM_PFF BIT(0) -#define NH_FLD_PPPMUX_SUBFRM_LXT BIT(1) -#define NH_FLD_PPPMUX_SUBFRM_LEN BIT(2) -#define NH_FLD_PPPMUX_SUBFRM_PID BIT(3) -#define NH_FLD_PPPMUX_SUBFRM_USE_PID BIT(4) -#define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS (BIT(5) - 1) - -/* LLC fields */ -#define NH_FLD_LLC_DSAP BIT(0) -#define NH_FLD_LLC_SSAP BIT(1) -#define NH_FLD_LLC_CTRL BIT(2) -#define NH_FLD_LLC_ALL_FIELDS (BIT(3) - 1) - -/* NLPID fields */ -#define NH_FLD_NLPID_NLPID BIT(0) -#define NH_FLD_NLPID_ALL_FIELDS (BIT(1) - 1) - -/* SNAP fields */ -#define NH_FLD_SNAP_OUI BIT(0) -#define NH_FLD_SNAP_PID BIT(1) -#define NH_FLD_SNAP_ALL_FIELDS (BIT(2) - 1) - -/* LLC SNAP fields */ -#define NH_FLD_LLC_SNAP_TYPE BIT(0) -#define NH_FLD_LLC_SNAP_ALL_FIELDS (BIT(1) - 1) - -/* ARP fields */ -#define NH_FLD_ARP_HTYPE BIT(0) -#define NH_FLD_ARP_PTYPE BIT(1) -#define NH_FLD_ARP_HLEN BIT(2) -#define NH_FLD_ARP_PLEN BIT(3) -#define NH_FLD_ARP_OPER BIT(4) -#define NH_FLD_ARP_SHA BIT(5) -#define NH_FLD_ARP_SPA BIT(6) -#define NH_FLD_ARP_THA BIT(7) -#define NH_FLD_ARP_TPA BIT(8) -#define NH_FLD_ARP_ALL_FIELDS (BIT(9) - 1) - -/* RFC2684 fields */ -#define NH_FLD_RFC2684_LLC BIT(0) -#define NH_FLD_RFC2684_NLPID BIT(1) -#define NH_FLD_RFC2684_OUI BIT(2) -#define NH_FLD_RFC2684_PID BIT(3) -#define NH_FLD_RFC2684_VPN_OUI BIT(4) -#define NH_FLD_RFC2684_VPN_IDX BIT(5) -#define NH_FLD_RFC2684_ALL_FIELDS (BIT(6) - 1) - -/* User defined fields */ -#define NH_FLD_USER_DEFINED_SRCPORT BIT(0) -#define NH_FLD_USER_DEFINED_PCDID BIT(1) -#define NH_FLD_USER_DEFINED_ALL_FIELDS (BIT(2) - 1) - -/* Payload fields */ -#define NH_FLD_PAYLOAD_BUFFER BIT(0) -#define NH_FLD_PAYLOAD_SIZE BIT(1) -#define NH_FLD_MAX_FRM_SIZE BIT(2) -#define NH_FLD_MIN_FRM_SIZE BIT(3) -#define NH_FLD_PAYLOAD_TYPE BIT(4) -#define NH_FLD_FRAME_SIZE BIT(5) -#define NH_FLD_PAYLOAD_ALL_FIELDS (BIT(6) - 1) - -/* GRE fields */ -#define NH_FLD_GRE_TYPE BIT(0) -#define NH_FLD_GRE_ALL_FIELDS (BIT(1) - 1) - -/* MINENCAP fields */ -#define NH_FLD_MINENCAP_SRC_IP BIT(0) -#define NH_FLD_MINENCAP_DST_IP BIT(1) -#define NH_FLD_MINENCAP_TYPE BIT(2) -#define NH_FLD_MINENCAP_ALL_FIELDS (BIT(3) - 1) - -/* IPSEC AH fields */ -#define NH_FLD_IPSEC_AH_SPI BIT(0) -#define NH_FLD_IPSEC_AH_NH BIT(1) -#define NH_FLD_IPSEC_AH_ALL_FIELDS (BIT(2) - 1) - -/* IPSEC ESP fields */ -#define NH_FLD_IPSEC_ESP_SPI BIT(0) -#define NH_FLD_IPSEC_ESP_SEQUENCE_NUM BIT(1) -#define NH_FLD_IPSEC_ESP_ALL_FIELDS (BIT(2) - 1) - - -/* MPLS fields */ -#define NH_FLD_MPLS_LABEL_STACK BIT(0) -#define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS (BIT(1) - 1) - -/* MACSEC fields */ -#define NH_FLD_MACSEC_SECTAG BIT(0) -#define NH_FLD_MACSEC_ALL_FIELDS (BIT(1) - 1) - -/* GTP fields */ -#define NH_FLD_GTP_TEID BIT(0) - -/* Supported protocols */ -enum net_prot { - NET_PROT_NONE = 0, - NET_PROT_PAYLOAD, - NET_PROT_ETH, - NET_PROT_VLAN, - NET_PROT_IPV4, - NET_PROT_IPV6, - NET_PROT_IP, - NET_PROT_TCP, - NET_PROT_UDP, - NET_PROT_UDP_LITE, - NET_PROT_IPHC, - NET_PROT_SCTP, - NET_PROT_SCTP_CHUNK_DATA, - NET_PROT_PPPOE, - NET_PROT_PPP, - NET_PROT_PPPMUX, - NET_PROT_PPPMUX_SUBFRM, - NET_PROT_L2TPV2, - NET_PROT_L2TPV3_CTRL, - NET_PROT_L2TPV3_SESS, - NET_PROT_LLC, - NET_PROT_LLC_SNAP, - NET_PROT_NLPID, - NET_PROT_SNAP, - NET_PROT_MPLS, - NET_PROT_IPSEC_AH, - NET_PROT_IPSEC_ESP, - NET_PROT_UDP_ENC_ESP, /* RFC 3948 */ - NET_PROT_MACSEC, - NET_PROT_GRE, - NET_PROT_MINENCAP, - NET_PROT_DCCP, - NET_PROT_ICMP, - NET_PROT_IGMP, - NET_PROT_ARP, - NET_PROT_CAPWAP_DATA, - NET_PROT_CAPWAP_CTRL, - NET_PROT_RFC2684, - NET_PROT_ICMPV6, - NET_PROT_FCOE, - NET_PROT_FIP, - NET_PROT_ISCSI, - NET_PROT_GTP, - NET_PROT_USER_DEFINED_L2, - NET_PROT_USER_DEFINED_L3, - NET_PROT_USER_DEFINED_L4, - NET_PROT_USER_DEFINED_L5, - NET_PROT_USER_DEFINED_SHIM1, - NET_PROT_USER_DEFINED_SHIM2, - - NET_PROT_DUMMY_LAST -}; - -#endif /* __FSL_NET_H */ From 328cf8e7790c852fc887ce067e53900f2c423afa Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 1 Aug 2018 21:10:50 +0200 Subject: [PATCH 782/903] staging: rtl8188eu: use is_multicast_ether_addr Use is_multicast_ether_addr instead of custom IS_MCAST. The variable for the result of IS_MCAST was only used in the if conditional. So remove the extra variable and move the call to is_multicast_ether_addr into the conditional. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 80f55937e3be..eca06f05c0c4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -2022,9 +2022,9 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr struct sta_info *psta = NULL; struct ht_priv *phtpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; - s32 bmcst = IS_MCAST(pattrib->ra); - if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100)) + if (is_multicast_ether_addr(pattrib->ra) || + padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100) return; priority = pattrib->priority; From 8663b2e02c1b5d5767ebaa38f72128658b6da1e9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 31 Jul 2018 13:34:09 +0200 Subject: [PATCH 783/903] staging: rtl8188eu: use is_broadcast_ether_addr Use is_broadcast_ether_addr instead of checking each byte of the address array for 0xff. Shortens the code and improves readability. As required by is_broadcast_ether_addr, the address array sta_addr is properly aligned in all uses. Thanks to Joe Perches. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 221fae22bab6..4a8124570e6e 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -361,9 +361,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, goto exit; } - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (is_broadcast_ether_addr(param->sta_addr)) { if (param->u.crypt.idx >= WEP_KEYS) { ret = -EINVAL; goto exit; @@ -2208,9 +2206,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ret = -EINVAL; goto exit; } - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (is_broadcast_ether_addr(param->sta_addr)) { if (param->u.crypt.idx >= WEP_KEYS) { ret = -EINVAL; goto exit; @@ -2471,9 +2467,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) return -EINVAL; - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + if (is_broadcast_ether_addr(param->sta_addr)) return -EINVAL; psta = rtw_get_stainfo(pstapriv, param->sta_addr); @@ -2528,9 +2522,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) return -EINVAL; - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + if (is_broadcast_ether_addr(param->sta_addr)) return -EINVAL; psta = rtw_get_stainfo(pstapriv, param->sta_addr); @@ -2566,9 +2558,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) return -EINVAL; - if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff && - param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff && - param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) + if (is_broadcast_ether_addr(param_ex->sta_addr)) return -EINVAL; psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); @@ -2622,9 +2612,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) return -EINVAL; - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + if (is_broadcast_ether_addr(param->sta_addr)) return -EINVAL; psta = rtw_get_stainfo(pstapriv, param->sta_addr); @@ -2779,10 +2767,9 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + if (is_broadcast_ether_addr(param->sta_addr)) return -EINVAL; + return rtw_acl_remove_sta(padapter, param->sta_addr); } @@ -2794,10 +2781,9 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + if (is_broadcast_ether_addr(param->sta_addr)) return -EINVAL; + return rtw_acl_add_sta(padapter, param->sta_addr); } From 4235d7d88a5a823e217abb4e3a6dd9bf1f457ae6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 31 Jul 2018 13:34:10 +0200 Subject: [PATCH 784/903] staging: rtl8188eu: fix indentation - style Fix indentation to clear checkpatch warnings. WARNING: suspect code indent for conditional statements Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++-- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 4a8124570e6e..19387d87185d 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -142,7 +142,7 @@ static char *translate_scan(struct adapter *padapter, if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates))) { if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); @@ -2299,7 +2299,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, psecuritypriv->dot118021XGrpPrivacy = _WEP40_; if (param->u.crypt.key_len == 13) - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { DBG_88E("%s, set group_key, TKIP\n", __func__); psecuritypriv->dot118021XGrpPrivacy = _TKIP_; diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 025cd0f59718..69f04fa0a189 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -380,7 +380,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, /* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto * suspend influence */ if (usb_autopm_get_interface(pusb_intf) < 0) - pr_debug("can't get autopm:\n"); + pr_debug("can't get autopm:\n"); /* alloc dev name after read efuse. */ rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname); From 55e12d6451c9218d7e251241aa17bc3b6917a864 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 31 Jul 2018 13:34:11 +0200 Subject: [PATCH 785/903] staging: rtl8188eu: fix comparsions to NULL - style Use x instead of x != NULL. Use !x instead of x == NULL. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 6 +++--- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 10 +++++----- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 9b810c76d6de..62294bdc465e 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -311,7 +311,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); - if (old_padapter != NULL) + if (old_padapter) pnetdev = rtw_alloc_etherdev_with_old_priv((void *)old_padapter); if (!pnetdev) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 69f04fa0a189..28cbd6b3d26c 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -325,7 +325,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, int status = _FAIL; padapter = vzalloc(sizeof(*padapter)); - if (padapter == NULL) + if (!padapter) goto exit; padapter->dvobj = dvobj; dvobj->if1 = padapter; @@ -334,14 +334,14 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, mutex_init(&padapter->hw_init_mutex); pnetdev = rtw_init_netdev(padapter); - if (pnetdev == NULL) + if (!pnetdev) goto free_adapter; SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); padapter = rtw_netdev_priv(pnetdev); if (padapter->registrypriv.monitor_enable) { pmondev = rtl88eu_mon_init(); - if (pmondev == NULL) + if (!pmondev) netdev_warn(pnetdev, "Failed to initialize monitor interface"); padapter->pmondev = pmondev; } diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index c69edb7d174c..a59eb017227f 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -58,7 +58,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) prxstat = (struct recv_stat *)pbuf; precvframe = rtw_alloc_recvframe(pfree_recv_queue); - if (precvframe == NULL) { + if (!precvframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); goto _exit_recvbuf2recvframe; @@ -436,16 +436,16 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf) return _FAIL; } - if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + if ((!precvbuf->reuse) || (!precvbuf->pskb)) { precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); - if (precvbuf->pskb != NULL) + if (precvbuf->pskb) precvbuf->reuse = true; } /* re-assign for linux based on skb */ - if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + if ((!precvbuf->reuse) || (!precvbuf->pskb)) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ); - if (precvbuf->pskb == NULL) { + if (!precvbuf->pskb) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); return _FAIL; diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 85cde696d369..d8ef9b5d81a8 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -19,7 +19,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb int i; pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL); - if (pxmitbuf->pallocated_buf == NULL) + if (!pxmitbuf->pallocated_buf) return _FAIL; pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ); From ee34b7cb0f0e6acbdc094786dba7ca1158175436 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 31 Jul 2018 13:34:12 +0200 Subject: [PATCH 786/903] staging: rtl8188eu: remove unnecessary parentheses - style Remove unnecessary parentheses to improve readability. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index a59eb017227f..5ddfc2ead127 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -436,14 +436,14 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf) return _FAIL; } - if ((!precvbuf->reuse) || (!precvbuf->pskb)) { + if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); if (precvbuf->pskb) precvbuf->reuse = true; } /* re-assign for linux based on skb */ - if ((!precvbuf->reuse) || (!precvbuf->pskb)) { + if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ); if (!precvbuf->pskb) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); From 96b0b75941183fc4101d46a38efbc639a5dc6cb3 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 31 Jul 2018 13:34:13 +0200 Subject: [PATCH 787/903] staging: rtl8188eu: remove unused rtw_add_bcn_ie() The function rtw_add_bcn_ie() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 66 ---------------------- drivers/staging/rtl8188eu/include/rtw_ap.h | 2 - 2 files changed, 68 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 220b4bbe1f84..82fb1b028fa0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -145,72 +145,6 @@ static void update_BCNTIM(struct adapter *padapter) set_tx_beacon_cmd(padapter); } -void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, - u8 index, u8 *data, u8 len) -{ - struct ndis_802_11_var_ie *pIE; - u8 bmatch = false; - u8 *pie = pnetwork->ies; - u8 *p = NULL, *dst_ie = NULL, *premainder_ie = NULL; - u8 *pbackup_remainder_ie = NULL; - u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0; - - for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->ie_length;) { - pIE = (struct ndis_802_11_var_ie *)(pnetwork->ies + i); - - if (pIE->ElementID > index) { - break; - /* already exist the same IE */ - } else if (pIE->ElementID == index) { - p = (u8 *)pIE; - ielen = pIE->Length; - bmatch = true; - break; - } - p = (u8 *)pIE; - ielen = pIE->Length; - i += (pIE->Length + 2); - } - - if (p && ielen > 0) { - ielen += 2; - - premainder_ie = p + ielen; - - ie_offset = (int)(p - pie); - - remainder_ielen = pnetwork->ie_length - ie_offset - ielen; - - if (bmatch) - dst_ie = p; - else - dst_ie = p + ielen; - } - - if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); - if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, - remainder_ielen); - } - - *dst_ie++ = index; - *dst_ie++ = len; - - memcpy(dst_ie, data, len); - dst_ie += len; - - /* copy remainder IE */ - if (pbackup_remainder_ie) { - memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); - - kfree(pbackup_remainder_ie); - } - - offset = (uint)(dst_ie - pie); - pnetwork->ie_length = offset + remainder_ielen; -} - void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index) { diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h b/drivers/staging/rtl8188eu/include/rtw_ap.h index bca41d68ce9d..f8f07257976c 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ap.h +++ b/drivers/staging/rtl8188eu/include/rtw_ap.h @@ -19,8 +19,6 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta); void init_mlme_ap_info(struct adapter *padapter); void free_mlme_ap_info(struct adapter *padapter); -void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, - u8 index, u8 *data, u8 len); void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index); void update_beacon(struct adapter *padapter, u8 ie_id, From 1a5c3d83c009393c27451e265fe21310b218211c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 31 Jul 2018 13:34:14 +0200 Subject: [PATCH 788/903] staging: rtl8188eu: remove unused rtw_remove_bcn_ie() The function rtw_remove_bcn_ie() is never used, so remove it. Discovered by cppcheck. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 40 ---------------------- drivers/staging/rtl8188eu/include/rtw_ap.h | 2 -- 2 files changed, 42 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 82fb1b028fa0..676d549ef786 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -145,46 +145,6 @@ static void update_BCNTIM(struct adapter *padapter) set_tx_beacon_cmd(padapter); } -void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, - u8 index) -{ - u8 *p, *dst_ie = NULL, *premainder_ie = NULL; - u8 *pbackup_remainder_ie = NULL; - uint offset, ielen, ie_offset, remainder_ielen = 0; - u8 *pie = pnetwork->ies; - - p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, &ielen, - pnetwork->ie_length - _FIXED_IE_LENGTH_); - if (p && ielen > 0) { - ielen += 2; - - premainder_ie = p + ielen; - - ie_offset = (int)(p - pie); - - remainder_ielen = pnetwork->ie_length - ie_offset - ielen; - - dst_ie = p; - } - - if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); - if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, - remainder_ielen); - } - - /* copy remainder IE */ - if (pbackup_remainder_ie) { - memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); - - kfree(pbackup_remainder_ie); - } - - offset = (uint)(dst_ie - pie); - pnetwork->ie_length = offset + remainder_ielen; -} - static u8 chk_sta_is_alive(struct sta_info *psta) { u8 ret = false; diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h b/drivers/staging/rtl8188eu/include/rtw_ap.h index f8f07257976c..7a4203bce473 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ap.h +++ b/drivers/staging/rtl8188eu/include/rtw_ap.h @@ -19,8 +19,6 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta); void init_mlme_ap_info(struct adapter *padapter); void free_mlme_ap_info(struct adapter *padapter); -void rtw_remove_bcn_ie(struct adapter *padapter, - struct wlan_bssid_ex *pnetwork, u8 index); void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx); void add_RATid(struct adapter *padapter, struct sta_info *psta, From d36255f14876063748094eef3eb3676496f69ffe Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 31 Jul 2018 13:34:15 +0200 Subject: [PATCH 789/903] staging: rtl8188eu: rename odm_RTL8188E - style Rename source and header file to avoid CamelCase. odm_RTL8188E.c -> odm_rtl8188e.c odm_RTL8188E.h -> odm_rtl8188e.h Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/Makefile | 2 +- .../staging/rtl8188eu/hal/{odm_RTL8188E.c => odm_rtl8188e.c} | 0 drivers/staging/rtl8188eu/include/odm_precomp.h | 2 +- .../rtl8188eu/include/{odm_RTL8188E.h => odm_rtl8188e.h} | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename drivers/staging/rtl8188eu/hal/{odm_RTL8188E.c => odm_rtl8188e.c} (100%) rename drivers/staging/rtl8188eu/include/{odm_RTL8188E.h => odm_rtl8188e.h} (100%) diff --git a/drivers/staging/rtl8188eu/Makefile b/drivers/staging/rtl8188eu/Makefile index aa6ea65d05fe..4e606b03ec03 100644 --- a/drivers/staging/rtl8188eu/Makefile +++ b/drivers/staging/rtl8188eu/Makefile @@ -29,7 +29,7 @@ r8188eu-y := \ hal/hal_com.o \ hal/odm.o \ hal/odm_HWConfig.o \ - hal/odm_RTL8188E.o \ + hal/odm_rtl8188e.o \ hal/rtl8188e_cmd.o \ hal/rtl8188e_dm.o \ hal/rtl8188e_hal_init.o \ diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c b/drivers/staging/rtl8188eu/hal/odm_rtl8188e.c similarity index 100% rename from drivers/staging/rtl8188eu/hal/odm_RTL8188E.c rename to drivers/staging/rtl8188eu/hal/odm_rtl8188e.c diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h index f00967fd9599..4d0dd12645bd 100644 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -31,7 +31,7 @@ #include "odm_reg.h" -#include "odm_RTL8188E.h" +#include "odm_rtl8188e.h" void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm); void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm); diff --git a/drivers/staging/rtl8188eu/include/odm_RTL8188E.h b/drivers/staging/rtl8188eu/include/odm_rtl8188e.h similarity index 100% rename from drivers/staging/rtl8188eu/include/odm_RTL8188E.h rename to drivers/staging/rtl8188eu/include/odm_rtl8188e.h From 7f40eb132c470b8ee61c17d223edbb787befb184 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:52 +0100 Subject: [PATCH 790/903] staging:rtl8192u: Clean cmpk_counttxstatistic() comments - Style The only useful piece of information in the header comment of this static function was the name of the function and parameters. That is not useful information, given that they are in the C Source of the function declaration, a few lines below the comment. The block comment has been removed. This is a coding style change, there should be no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index d2293a335ed1..900f7866d381 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -60,24 +60,6 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) return RT_STATUS_SUCCESS; } -/*----------------------------------------------------------------------------- - * Function: cmpk_counttxstatistic() - * - * Overview: - * - * Input: PADAPTER pAdapter - * STRUCT CMD_PKT_TX_FEEDBACK *psTx_FB - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. - * - *--------------------------------------------------------------------------- - */ static void cmpk_count_txstatistic(struct net_device *dev, struct cmd_pkt_tx_feedback *pstx_fb) { struct r8192_priv *priv = ieee80211_priv(dev); From ab9a066577f9529fa112743078e60ce7afbc194e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:53 +0100 Subject: [PATCH 791/903] staging:rtl8192u: Remove union from aci_aifsn - Style The union aci_aifsn is not used as a union, but only as a struct. The union seems to have been used to ensure that the size of the structure was only a single byte. That size is set by the bitfield structure, adding a union with an unused byte adds nothing. The union has been removed. This is a coding style change and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 23 ++++++++----------- drivers/staging/rtl8192u/r8192U_dm.c | 4 ++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 810d81addcf6..1f16d1692c03 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -2,19 +2,16 @@ #ifndef __INC_QOS_TYPE_H #define __INC_QOS_TYPE_H -// -// ACI/AIFSN Field. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.12. -// -union aci_aifsn { - u8 char_data; - - struct { - u8 aifsn:4; - u8 acm:1; - u8 aci:2; - u8 reserved:1; - } f; // Field +/* + * ACI/AIFSN Field. + * Ref: WMM spec 2.2.2: WME Parameter Element, p.12. + * Note: 1 Byte Length + */ +struct aci_aifsn { + u8 aifsn:4; + u8 acm:1; + u8 aci:2; + u8:1; }; // diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 92ba1fdd9831..0ba1b1e2bc6e 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2242,12 +2242,12 @@ static void dm_check_edca_turbo( { /* TODO: Modified this part and try to set acm control in only 1 IO processing!! */ - union aci_aifsn *pAciAifsn = (union aci_aifsn *)&(qos_parameters->aifs[0]); + struct aci_aifsn *pAciAifsn = (struct aci_aifsn *)&(qos_parameters->aifs[0]); u8 AcmCtrl; read_nic_byte(dev, AcmHwCtrl, &AcmCtrl); - if (pAciAifsn->f.acm) { /* acm bit is 1. */ + if (pAciAifsn->acm) { /* acm bit is 1. */ AcmCtrl |= AcmHw_BeqEn; } else { /* ACM bit is 0. */ AcmCtrl &= (~AcmHw_BeqEn); From 893ce9394b3cba7722f9ce01ecba84f35c0211a6 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:54 +0100 Subject: [PATCH 792/903] staging:rtl8192u: Remove union from qos_tsinfo - Style The union is never used as a union but only as a bitfield struct. One side of the union (u8 charData[3];) Only seems to be present to ensure that the structures size is 3 bytes in length. That length, of the structure is dictated by the largest element of the union, so the byte array only dictates size if it's the largest element of the union. The byte array and union add nothing. The union has therefore been removed and the structure and access to the structure simplified. Additionally since one of the bitfield variables (ucAccessPolicy) spans a byte boundary the base type of the bitfield has been changed from u8 to u16. Compilers have probably moved on from having an issue with this, call it OCD. The changes are coding style in nature and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 40 +++++++++---------- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 26 ++++++------ 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index e296813203aa..4e8bcc25ad2c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -626,7 +626,7 @@ TsInitAddBA( pBA->DialogToken++; // DialogToken: Only keep the latest dialog token pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!! pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate - pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.field.ucTSID; // TID + pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.ucTSID; // TID // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 1f16d1692c03..4faa89db8355 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -26,26 +26,24 @@ enum direction_value { }; -// -// TS Info field in WMM TSPEC Element. -// Ref: -// 1. WMM spec 2.2.11: WME TSPEC Element, p.18. -// 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h] -// -union qos_tsinfo { - u8 charData[3]; - struct { - u8 ucTrafficType:1; //WMM is reserved - u8 ucTSID:4; - u8 ucDirection:2; - u8 ucAccessPolicy:2; //WMM: bit8=0, bit7=1 - u8 ucAggregation:1; //WMM is reserved - u8 ucPSB:1; //WMMSA is APSD - u8 ucUP:3; - u8 ucTSInfoAckPolicy:2; //WMM is reserved - u8 ucSchedule:1; //WMM is reserved - u8 ucReserved:7; - } field; +/* + * TS Info field in WMM TSPEC Element. + * Ref: + * 1. WMM spec 2.2.11: WME TSPEC Element, p.18. + * 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h] + * Note: sizeof 3 Bytes + */ +struct qos_tsinfo { + u16 ucTrafficType:1; //WMM is reserved + u16 ucTSID:4; + u16 ucDirection:2; + u16 ucAccessPolicy:2; //WMM: bit8=0, bit7=1 + u16 ucAggregation:1; //WMM is reserved + u16 ucPSB:1; //WMMSA is APSD + u16 ucUP:3; + u16 ucTSInfoAckPolicy:2; //WMM is reserved + u8 ucSchedule:1; //WMM is reserved + u8 ucReserved:7; }; // @@ -56,7 +54,7 @@ typedef union _TSPEC_BODY { u8 charData[55]; struct { - union qos_tsinfo TSInfo; //u8 TSInfo[3]; + struct qos_tsinfo TSInfo; //u8 TSInfo[3]; u16 NominalMSDUsize; u16 MaxMSDUsize; u32 MinServiceItv; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index c21bf3d3b242..39a074621b3b 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -246,10 +246,10 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, if (!search_dir[dir]) continue; list_for_each_entry(pRet, psearch_list, list){ - // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); + // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.ucTSID, pRet->TSpec.f.TSInfo.ucDirection); if (memcmp(pRet->addr, Addr, 6) == 0) - if (pRet->t_spec.f.TSInfo.field.ucTSID == TID) - if(pRet->t_spec.f.TSInfo.field.ucDirection == dir) { + if (pRet->t_spec.f.TSInfo.ucTSID == TID) + if(pRet->t_spec.f.TSInfo.ucDirection == dir) { // printk("Bingo! got it\n"); break; } @@ -355,7 +355,7 @@ bool GetTs( // For HCCA or WMMSA, TS cannot be addmit without negotiation. // TSPEC_BODY TSpec; - union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; + struct qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; struct list_head *pUnusedList = (TxRxSelect == TX_DIR)? (&ieee->Tx_TS_Unused_List): @@ -383,15 +383,15 @@ bool GetTs( IEEE80211_DEBUG(IEEE80211_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:%pM\n", UP, Dir, Addr); // Prepare TS Info releated field - pTSInfo->field.ucTrafficType = 0; // Traffic type: WMM is reserved in this field - pTSInfo->field.ucTSID = UP; // TSID - pTSInfo->field.ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration. - pTSInfo->field.ucAccessPolicy = 1; // Access policy - pTSInfo->field.ucAggregation = 0; // Aggregation - pTSInfo->field.ucPSB = 0; // Aggregation - pTSInfo->field.ucUP = UP; // User priority - pTSInfo->field.ucTSInfoAckPolicy = 0; // Ack policy - pTSInfo->field.ucSchedule = 0; // Schedule + pTSInfo->ucTrafficType = 0; // Traffic type: WMM is reserved in this field + pTSInfo->ucTSID = UP; // TSID + pTSInfo->ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration. + pTSInfo->ucAccessPolicy = 1; // Access policy + pTSInfo->ucAggregation = 0; // Aggregation + pTSInfo->ucPSB = 0; // Aggregation + pTSInfo->ucUP = UP; // User priority + pTSInfo->ucTSInfoAckPolicy = 0; // Ack policy + pTSInfo->ucSchedule = 0; // Schedule MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0); AdmitTS(ieee, *ppTS, 0); From 0a679b9359f6b8394e93007e0b530da6bd819355 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:55 +0100 Subject: [PATCH 793/903] staging:rtl8192u: Rename members of struct qos_tsinfo - Style The member variables of struct qos_tsinfo all cause checkpatch issues with CamelCase naming. As the variables are used in so few places the changes are combined into this single patch. Additionally the member variable usReserved is never used in code so has been removed. These are all coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 20 ++++++++--------- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 22 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 4e8bcc25ad2c..96fab43c1cfe 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -626,7 +626,7 @@ TsInitAddBA( pBA->DialogToken++; // DialogToken: Only keep the latest dialog token pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!! pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate - pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.ucTSID; // TID + pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.uc_tsid; // TID // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 4faa89db8355..d36a14197b4c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -34,16 +34,16 @@ enum direction_value { * Note: sizeof 3 Bytes */ struct qos_tsinfo { - u16 ucTrafficType:1; //WMM is reserved - u16 ucTSID:4; - u16 ucDirection:2; - u16 ucAccessPolicy:2; //WMM: bit8=0, bit7=1 - u16 ucAggregation:1; //WMM is reserved - u16 ucPSB:1; //WMMSA is APSD - u16 ucUP:3; - u16 ucTSInfoAckPolicy:2; //WMM is reserved - u8 ucSchedule:1; //WMM is reserved - u8 ucReserved:7; + u16 uc_traffic_type:1; //WMM is reserved + u16 uc_tsid:4; + u16 uc_direction:2; + u16 uc_access_policy:2; //WMM: bit8=0, bit7=1 + u16 uc_aggregation:1; //WMM is reserved + u16 uc_psb:1; //WMMSA is APSD + u16 uc_up:3; + u16 uc_ts_info_ack_policy:2; //WMM is reserved + u8 uc_schedule:1; //WMM is reserved + u8:7; }; // diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 39a074621b3b..076278dae321 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -248,8 +248,8 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, list_for_each_entry(pRet, psearch_list, list){ // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.ucTSID, pRet->TSpec.f.TSInfo.ucDirection); if (memcmp(pRet->addr, Addr, 6) == 0) - if (pRet->t_spec.f.TSInfo.ucTSID == TID) - if(pRet->t_spec.f.TSInfo.ucDirection == dir) { + if (pRet->t_spec.f.TSInfo.uc_tsid == TID) + if(pRet->t_spec.f.TSInfo.uc_direction == dir) { // printk("Bingo! got it\n"); break; } @@ -383,15 +383,15 @@ bool GetTs( IEEE80211_DEBUG(IEEE80211_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:%pM\n", UP, Dir, Addr); // Prepare TS Info releated field - pTSInfo->ucTrafficType = 0; // Traffic type: WMM is reserved in this field - pTSInfo->ucTSID = UP; // TSID - pTSInfo->ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration. - pTSInfo->ucAccessPolicy = 1; // Access policy - pTSInfo->ucAggregation = 0; // Aggregation - pTSInfo->ucPSB = 0; // Aggregation - pTSInfo->ucUP = UP; // User priority - pTSInfo->ucTSInfoAckPolicy = 0; // Ack policy - pTSInfo->ucSchedule = 0; // Schedule + pTSInfo->uc_traffic_type = 0; // Traffic type: WMM is reserved in this field + pTSInfo->uc_tsid = UP; // TSID + pTSInfo->uc_direction = Dir; // Direction: if there is DirectLink, this need additional consideration. + pTSInfo->uc_access_policy = 1; // Access policy + pTSInfo->uc_aggregation = 0; // Aggregation + pTSInfo->uc_psb = 0; // Aggregation + pTSInfo->uc_up = UP; // User priority + pTSInfo->uc_ts_info_ack_policy = 0; // Ack policy + pTSInfo->uc_schedule = 0; // Schedule MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0); AdmitTS(ieee, *ppTS, 0); From 9365607ac1c91e8ee4dbda7e1c015f3d2eca489a Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:56 +0100 Subject: [PATCH 794/903] staging:rtl8192u: Refactor union TSPEC_BODY - Style The union TSPEC_BODY is never used as a union. The union comprises an array of bytes and a bitfield structure, both of which are 55 bytes in length, but the byte array is never used. As a result the union has been truncated to the bitfield struct, which is actually used. Additionally the typedef has been removed from the structure to clear the checkpatch issue with defining new types. Additionally the name has been changed to lowercase to comply with coding style. These changes are all coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 49 +++++++++---------- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 2 +- .../rtl8192u/ieee80211/rtl819x_TSProc.c | 16 +++--- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 96fab43c1cfe..d35f10c695e4 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -626,7 +626,7 @@ TsInitAddBA( pBA->DialogToken++; // DialogToken: Only keep the latest dialog token pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!! pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate - pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.uc_tsid; // TID + pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.TSInfo.uc_tsid; // TID // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index d36a14197b4c..a4cecf4cc756 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -46,32 +46,29 @@ struct qos_tsinfo { u8:7; }; -// -// WMM TSPEC Body. -// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16. -// -typedef union _TSPEC_BODY { - u8 charData[55]; - - struct { - struct qos_tsinfo TSInfo; //u8 TSInfo[3]; - u16 NominalMSDUsize; - u16 MaxMSDUsize; - u32 MinServiceItv; - u32 MaxServiceItv; - u32 InactivityItv; - u32 SuspenItv; - u32 ServiceStartTime; - u32 MinDataRate; - u32 MeanDataRate; - u32 PeakDataRate; - u32 MaxBurstSize; - u32 DelayBound; - u32 MinPhyRate; - u16 SurplusBandwidthAllowance; - u16 MediumTime; - } f; // Field -} TSPEC_BODY, *PTSPEC_BODY; +/* + * WMM TSPEC Body. + * Ref: WMM spec 2.2.11: WME TSPEC Element, p.16. + * Note: sizeof 55 bytes + */ +struct tspec_body { + struct qos_tsinfo TSInfo; //u8 TSInfo[3]; + u16 NominalMSDUsize; + u16 MaxMSDUsize; + u32 MinServiceItv; + u32 MaxServiceItv; + u32 InactivityItv; + u32 SuspenItv; + u32 ServiceStartTime; + u32 MinDataRate; + u32 MeanDataRate; + u32 PeakDataRate; + u32 MaxBurstSize; + u32 DelayBound; + u32 MinPhyRate; + u16 SurplusBandwidthAllowance; + u16 MediumTime; +}; //typedef struct _TCLASS{ // TODO diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index f5e79853fe9c..a9f865f810ce 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -19,7 +19,7 @@ struct ts_common_info { struct timer_list setup_timer; struct timer_list inact_timer; u8 addr[6]; - TSPEC_BODY t_spec; + struct tspec_body t_spec; QOS_TCLAS t_class[TCLAS_NUM]; u8 t_clas_proc; u8 t_clas_num; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 076278dae321..bd2b4e5dfa60 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -104,7 +104,7 @@ static void TsAddBaProcess(struct timer_list *t) static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { eth_zero_addr(pTsCommonInfo->addr); - memset(&pTsCommonInfo->t_spec, 0, sizeof(TSPEC_BODY)); + memset(&pTsCommonInfo->t_spec, 0, sizeof(struct tspec_body)); memset(&pTsCommonInfo->t_class, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); pTsCommonInfo->t_clas_proc = 0; pTsCommonInfo->t_clas_num = 0; @@ -246,10 +246,10 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, if (!search_dir[dir]) continue; list_for_each_entry(pRet, psearch_list, list){ - // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.ucTSID, pRet->TSpec.f.TSInfo.ucDirection); + // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.TSInfo.ucTSID, pRet->TSpec.TSInfo.ucDirection); if (memcmp(pRet->addr, Addr, 6) == 0) - if (pRet->t_spec.f.TSInfo.uc_tsid == TID) - if(pRet->t_spec.f.TSInfo.uc_direction == dir) { + if (pRet->t_spec.TSInfo.uc_tsid == TID) + if(pRet->t_spec.TSInfo.uc_direction == dir) { // printk("Bingo! got it\n"); break; } @@ -265,7 +265,7 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, } static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, - PTSPEC_BODY pTSPEC, PQOS_TCLAS pTCLAS, u8 TCLAS_Num, + struct tspec_body *pTSPEC, PQOS_TCLAS pTCLAS, u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -276,7 +276,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, memcpy(pTsCommonInfo->addr, Addr, 6); if(pTSPEC != NULL) - memcpy((u8 *)(&(pTsCommonInfo->t_spec)), (u8 *)pTSPEC, sizeof(TSPEC_BODY)); + memcpy((u8 *)(&(pTsCommonInfo->t_spec)), (u8 *)pTSPEC, sizeof(struct tspec_body)); for(count = 0; count < TCLAS_Num; count++) memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS)); @@ -354,8 +354,8 @@ bool GetTs( // This is for EDCA and WMM to add a new TS. // For HCCA or WMMSA, TS cannot be addmit without negotiation. // - TSPEC_BODY TSpec; - struct qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; + struct tspec_body TSpec; + struct qos_tsinfo *pTSInfo = &TSpec.TSInfo; struct list_head *pUnusedList = (TxRxSelect == TX_DIR)? (&ieee->Tx_TS_Unused_List): From 73b068f56753fc01e4cfebdcc00c79ff8e7ff4a8 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:57 +0100 Subject: [PATCH 795/903] staging:rtl8192u: Rename TSInfo - Style Rename TSInfo, the memeber variable of struct tspec_body to ts_info. This change clears the checkpatch issue with CamelCase naming. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index d35f10c695e4..01b631c2a180 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -626,7 +626,7 @@ TsInitAddBA( pBA->DialogToken++; // DialogToken: Only keep the latest dialog token pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!! pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate - pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.TSInfo.uc_tsid; // TID + pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.ts_info.uc_tsid; // TID // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index a4cecf4cc756..db0392cfd6d4 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -52,7 +52,7 @@ struct qos_tsinfo { * Note: sizeof 55 bytes */ struct tspec_body { - struct qos_tsinfo TSInfo; //u8 TSInfo[3]; + struct qos_tsinfo ts_info; //u8 TSInfo[3]; u16 NominalMSDUsize; u16 MaxMSDUsize; u32 MinServiceItv; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index bd2b4e5dfa60..e0ccabadec22 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -246,10 +246,10 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, if (!search_dir[dir]) continue; list_for_each_entry(pRet, psearch_list, list){ - // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.TSInfo.ucTSID, pRet->TSpec.TSInfo.ucDirection); + // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.ts_info.ucTSID, pRet->TSpec.ts_info.ucDirection); if (memcmp(pRet->addr, Addr, 6) == 0) - if (pRet->t_spec.TSInfo.uc_tsid == TID) - if(pRet->t_spec.TSInfo.uc_direction == dir) { + if (pRet->t_spec.ts_info.uc_tsid == TID) + if(pRet->t_spec.ts_info.uc_direction == dir) { // printk("Bingo! got it\n"); break; } @@ -355,7 +355,7 @@ bool GetTs( // For HCCA or WMMSA, TS cannot be addmit without negotiation. // struct tspec_body TSpec; - struct qos_tsinfo *pTSInfo = &TSpec.TSInfo; + struct qos_tsinfo *pTSInfo = &TSpec.ts_info; struct list_head *pUnusedList = (TxRxSelect == TX_DIR)? (&ieee->Tx_TS_Unused_List): From 7390ebe9e3d51db98b79c6737beef97ea94250b6 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:58 +0100 Subject: [PATCH 796/903] staging:rtl8192u: Rename tspec_body members - Style The member variables of the tspec_body have been renamed to clear the checkpatch issue with CamelCase naming. As these member variables are never used in the code the changes are combined into this single patch. These changes are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index db0392cfd6d4..025810c93160 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -53,21 +53,21 @@ struct qos_tsinfo { */ struct tspec_body { struct qos_tsinfo ts_info; //u8 TSInfo[3]; - u16 NominalMSDUsize; - u16 MaxMSDUsize; - u32 MinServiceItv; - u32 MaxServiceItv; - u32 InactivityItv; - u32 SuspenItv; - u32 ServiceStartTime; - u32 MinDataRate; - u32 MeanDataRate; - u32 PeakDataRate; - u32 MaxBurstSize; - u32 DelayBound; - u32 MinPhyRate; - u16 SurplusBandwidthAllowance; - u16 MediumTime; + u16 nominal_msd_usize; + u16 max_msd_usize; + u32 min_service_itv; + u32 max_service_itv; + u32 inactivity_itv; + u32 suspen_itv; + u32 service_start_time; + u32 min_data_rate; + u32 mean_data_rate; + u32 peak_data_rate; + u32 max_burst_size; + u32 delay_bound; + u32 min_phy_rate; + u16 surplus_bandwidth_allowance; + u16 medium_time; }; //typedef struct _TCLASS{ From c96dc9b905f21721b3cb191927880161b1190a99 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 21:59:59 +0100 Subject: [PATCH 797/903] staging:rtl8192u: Remove commented out code - Style A number of structures have been commented out of code. Obviously they are not used and as a result have been removed from the code. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 025810c93160..a4b8b577cf79 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -25,7 +25,6 @@ enum direction_value { DIR_BI_DIR = 3, // 0x11 // Bi-Direction }; - /* * TS Info field in WMM TSPEC Element. * Ref: @@ -70,9 +69,6 @@ struct tspec_body { u16 medium_time; }; -//typedef struct _TCLASS{ -// TODO -//} TCLASS, *PTCLASS; typedef union _QOS_TCLAS { struct _TYPE_GENERAL { @@ -124,21 +120,6 @@ typedef union _QOS_TCLAS { } TYPE2_8021Q; } QOS_TCLAS, *PQOS_TCLAS; -//typedef struct _U_APSD{ -//- TriggerEnable [4] -//- MaxSPLength -//- HighestAcBuffered -//} U_APSD, *PU_APSD; - -//joseph TODO: -// UAPSD function should be implemented by 2 data structure -// "Qos control field" and "Qos info field" -//typedef struct _QOS_UAPSD{ -// u8 bTriggerEnable[4]; -// u8 MaxSPLength; -// u8 HighestBufAC; -//} QOS_UAPSD, *PQOS_APSD; - //---------------------------------------------------------------------------- // 802.11 Management frame Status Code field //---------------------------------------------------------------------------- From f40e50c33fa5d1c677509c991450faae12408212 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 22:00:00 +0100 Subject: [PATCH 798/903] staging:rtl8192u: Move QOS_TCLAS to rtl819x_TS.h - Style Move the union QOS_TCLAS from the header file rtl819x_Qos.h to header file rtl819x_TS.h, where the structure is actually used, as the member of another structure. This is a coding style change, which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 51 ------------------- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 51 +++++++++++++++++++ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index a4b8b577cf79..fb055a848d59 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -69,57 +69,6 @@ struct tspec_body { u16 medium_time; }; -typedef union _QOS_TCLAS { - - struct _TYPE_GENERAL { - u8 Priority; - u8 ClassifierType; - u8 Mask; - } TYPE_GENERAL; - - struct _TYPE0_ETH { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 SrcAddr[6]; - u8 DstAddr[6]; - u16 Type; - } TYPE0_ETH; - - struct _TYPE1_IPV4 { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; - u8 SrcIP[4]; - u8 DstIP[4]; - u16 SrcPort; - u16 DstPort; - u8 DSCP; - u8 Protocol; - u8 Reserved; - } TYPE1_IPV4; - - struct _TYPE1_IPV6 { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; - u8 SrcIP[16]; - u8 DstIP[16]; - u16 SrcPort; - u16 DstPort; - u8 FlowLabel[3]; - } TYPE1_IPV6; - - struct _TYPE2_8021Q { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u16 TagType; - } TYPE2_8021Q; -} QOS_TCLAS, *PQOS_TCLAS; - //---------------------------------------------------------------------------- // 802.11 Management frame Status Code field //---------------------------------------------------------------------------- diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index a9f865f810ce..5cf00a2e08ae 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -14,6 +14,57 @@ enum tr_select { RX_DIR = 1, }; +typedef union _QOS_TCLAS { + + struct _TYPE_GENERAL { + u8 Priority; + u8 ClassifierType; + u8 Mask; + } TYPE_GENERAL; + + struct _TYPE0_ETH { + u8 Priority; + u8 ClassifierType; + u8 Mask; + u8 SrcAddr[6]; + u8 DstAddr[6]; + u16 Type; + } TYPE0_ETH; + + struct _TYPE1_IPV4 { + u8 Priority; + u8 ClassifierType; + u8 Mask; + u8 Version; + u8 SrcIP[4]; + u8 DstIP[4]; + u16 SrcPort; + u16 DstPort; + u8 DSCP; + u8 Protocol; + u8 Reserved; + } TYPE1_IPV4; + + struct _TYPE1_IPV6 { + u8 Priority; + u8 ClassifierType; + u8 Mask; + u8 Version; + u8 SrcIP[16]; + u8 DstIP[16]; + u16 SrcPort; + u16 DstPort; + u8 FlowLabel[3]; + } TYPE1_IPV6; + + struct _TYPE2_8021Q { + u8 Priority; + u8 ClassifierType; + u8 Mask; + u16 TagType; + } TYPE2_8021Q; +} QOS_TCLAS, *PQOS_TCLAS; + struct ts_common_info { struct list_head list; struct timer_list setup_timer; From 4f698fc122e2aa0e5f0e0507a5a0022e82d253ce Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 22:00:01 +0100 Subject: [PATCH 799/903] staging:rtl8192u: rename OCTET_STRING - Style Rename the structure OCTET_STRING to octet_string. This is to comply with the coding style of using lowercase for types. In addition the typedef directive is removed to clear the checkpatch issue with defining new types. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++-- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 326a1e47bade..3cfeac0d7214 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1543,14 +1543,14 @@ typedef struct _RT_POWER_SAVE_CONTROL { bool bTmpFilterHiddenAP; bool bTmpUpdateParms; u8 tmpSsidBuf[33]; - OCTET_STRING tmpSsid2Scan; + struct octet_string tmpSsid2Scan; bool bTmpSsid2Scan; u8 tmpNetworkType; u8 tmpChannelNumber; u16 tmpBcnPeriod; u8 tmpDtimPeriod; u16 tmpmCap; - OCTET_STRING tmpSuppRateSet; + struct octet_string tmpSuppRateSet; u8 tmpSuppRateBuf[MAX_NUM_RATES]; bool bTmpSuppRate; IbssParms tmpIbpm; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index ca3a35b8ac07..706b4419e643 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1063,7 +1063,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, if (beacon->bCkipSupported) { static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; // "4500-client" u8 CcxAironetBuf[30]; - OCTET_STRING osCcxAironetIE; + struct octet_string osCcxAironetIE; memset(CcxAironetBuf, 0, 30); osCcxAironetIE.Octet = CcxAironetBuf; @@ -1087,7 +1087,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, if (beacon->bCcxRmEnable) { static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; - OCTET_STRING osCcxRmCap; + struct octet_string osCcxRmCap; osCcxRmCap.Octet = CcxRmCapBuf; osCcxRmCap.Length = sizeof(CcxRmCapBuf); @@ -1100,7 +1100,7 @@ ieee80211_association_req(struct ieee80211_network *beacon, if (beacon->BssCcxVerNumber >= 2) { u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; - OCTET_STRING osCcxVerNum; + struct octet_string osCcxVerNum; CcxVerNumBuf[4] = beacon->BssCcxVerNumber; osCcxVerNum.Octet = CcxVerNumBuf; osCcxVerNum.Length = sizeof(CcxVerNumBuf); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index fb055a848d59..531a3e22e799 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -72,10 +72,10 @@ struct tspec_body { //---------------------------------------------------------------------------- // 802.11 Management frame Status Code field //---------------------------------------------------------------------------- -typedef struct _OCTET_STRING { +struct octet_string { u8 *Octet; u16 Length; -} OCTET_STRING, *POCTET_STRING; +}; //Added by joseph //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP From 4375c036ca0087641e61c3eae830261a10b51b5a Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 22:00:02 +0100 Subject: [PATCH 800/903] staging:rtl8192u: Rename octet_string members - Style Rename the structure octet_string's member variables Octet to octet and Length to length. This change clears the checkpatch issue with CamelCase naming of variables. This is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_softmac.c | 34 +++++++++---------- .../rtl8192u/ieee80211/rtl819x_HTProc.c | 4 +-- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 4 +-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 706b4419e643..51cb5e4658b0 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1066,49 +1066,49 @@ ieee80211_association_req(struct ieee80211_network *beacon, struct octet_string osCcxAironetIE; memset(CcxAironetBuf, 0, 30); - osCcxAironetIE.Octet = CcxAironetBuf; - osCcxAironetIE.Length = sizeof(CcxAironetBuf); + osCcxAironetIE.octet = CcxAironetBuf; + osCcxAironetIE.length = sizeof(CcxAironetBuf); // // Ref. CCX test plan v3.61, 3.2.3.1 step 13. // We want to make the device type as "4500-client". 060926, by CCW. // - memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui)); + memcpy(osCcxAironetIE.octet, AironetIeOui, sizeof(AironetIeOui)); // CCX1 spec V1.13, A01.1 CKIP Negotiation (page23): // "The CKIP negotiation is started with the associate request from the client to the access point, // containing an Aironet element with both the MIC and KP bits set." - osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK | SUPPORT_CKIP_MIC); + osCcxAironetIE.octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK | SUPPORT_CKIP_MIC); tag = skb_put(skb, ckip_ie_len); *tag++ = MFIE_TYPE_AIRONET; - *tag++ = osCcxAironetIE.Length; - memcpy(tag, osCcxAironetIE.Octet, osCcxAironetIE.Length); - tag += osCcxAironetIE.Length; + *tag++ = osCcxAironetIE.length; + memcpy(tag, osCcxAironetIE.octet, osCcxAironetIE.length); + tag += osCcxAironetIE.length; } if (beacon->bCcxRmEnable) { static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; struct octet_string osCcxRmCap; - osCcxRmCap.Octet = CcxRmCapBuf; - osCcxRmCap.Length = sizeof(CcxRmCapBuf); + osCcxRmCap.octet = CcxRmCapBuf; + osCcxRmCap.length = sizeof(CcxRmCapBuf); tag = skb_put(skb, ccxrm_ie_len); *tag++ = MFIE_TYPE_GENERIC; - *tag++ = osCcxRmCap.Length; - memcpy(tag, osCcxRmCap.Octet, osCcxRmCap.Length); - tag += osCcxRmCap.Length; + *tag++ = osCcxRmCap.length; + memcpy(tag, osCcxRmCap.octet, osCcxRmCap.length); + tag += osCcxRmCap.length; } if (beacon->BssCcxVerNumber >= 2) { u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; struct octet_string osCcxVerNum; CcxVerNumBuf[4] = beacon->BssCcxVerNumber; - osCcxVerNum.Octet = CcxVerNumBuf; - osCcxVerNum.Length = sizeof(CcxVerNumBuf); + osCcxVerNum.octet = CcxVerNumBuf; + osCcxVerNum.length = sizeof(CcxVerNumBuf); tag = skb_put(skb, cxvernum_ie_len); *tag++ = MFIE_TYPE_GENERIC; - *tag++ = osCcxVerNum.Length; - memcpy(tag, osCcxVerNum.Octet, osCcxVerNum.Length); - tag += osCcxVerNum.Length; + *tag++ = osCcxVerNum.length; + memcpy(tag, osCcxVerNum.octet, osCcxVerNum.length); + tag += osCcxVerNum.length; } //HT cap element if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 264d15fbcc6b..b948eae5909d 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -738,10 +738,10 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, section of code. if(IS_UNDER_11N_AES_MODE(Adapter)) { - posRT2RTAgg->Octet[5] |= RT_HT_CAP_USE_AMPDU; + posRT2RTAgg->octet[5] |= RT_HT_CAP_USE_AMPDU; }else { - posRT2RTAgg->Octet[5] &= 0xfb; + posRT2RTAgg->octet[5] &= 0xfb; } */ #else diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 531a3e22e799..50b05ee52210 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -73,8 +73,8 @@ struct tspec_body { // 802.11 Management frame Status Code field //---------------------------------------------------------------------------- struct octet_string { - u8 *Octet; - u16 Length; + u8 *octet; + u16 length; }; //Added by joseph From 9e86a12e7b968da44c22b5cf96fe960af88b98d6 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 22:00:03 +0100 Subject: [PATCH 801/903] staging:rtl8192u: Remove unused UP2AC - Style The macro UP2AC is commented out of the header file so the macro and its associated comment are removed. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 50b05ee52210..59a60f86607c 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -77,9 +77,6 @@ struct octet_string { u16 length; }; -//Added by joseph -//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP -//#define UP2AC(up) ((up<3)?((up==0)?1:0):(up>>1)) #define IsACValid(ac) ((ac <= 7) ? true : false) #endif // #ifndef __INC_QOS_TYPE_H From 0b0251ad9becfb96c78d10d2ff414274974f46a9 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 22:00:04 +0100 Subject: [PATCH 802/903] staging:rtl8192u: Rename IsACValid and add parenthesis - Style The macro IsACValid is renamed to resolve the checkpatch issue with CamelCase naming. In addition the parameter has parenthesis added to clear the checkpatch issue with precedence issues. These changes are coding style changes and as such should have not impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 2 +- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 59a60f86607c..77f0e26f5d2d 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -77,6 +77,6 @@ struct octet_string { u16 length; }; -#define IsACValid(ac) ((ac <= 7) ? true : false) +#define is_ac_valid(ac) (((ac) <= 7) ? true : false) #endif // #ifndef __INC_QOS_TYPE_H diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index e0ccabadec22..de06cd11ab65 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -309,7 +309,7 @@ bool GetTs( UP = 0; } else { // In WMM case: we use 4 TID only - if (!IsACValid(TID)) { + if (!is_ac_valid(TID)) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " in %s(), TID(%d) is not valid\n", __func__, TID); return false; } From 84d979bc89e3a982940b85014aab357b25d32882 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 31 Jul 2018 22:00:05 +0100 Subject: [PATCH 803/903] staging:rtl8192u: Change clock comment - Style A number of block comments have been changed to comply with the coding standard. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 77f0e26f5d2d..3052f53d2e7e 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -14,10 +14,10 @@ struct aci_aifsn { u8:1; }; -// -// Direction Field Values. -// Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. -// +/* + * Direction Field Values. + * Ref: WMM spec 2.2.11: WME TSPEC Element, p.18. + */ enum direction_value { DIR_UP = 0, // 0x00 // UpLink DIR_DOWN = 1, // 0x01 // DownLink @@ -69,9 +69,9 @@ struct tspec_body { u16 medium_time; }; -//---------------------------------------------------------------------------- -// 802.11 Management frame Status Code field -//---------------------------------------------------------------------------- +/* + * 802.11 Management frame Status Code field + */ struct octet_string { u8 *octet; u16 length; From 1c65a2e2f68eae5d73b41dee003b8135dfcf6928 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 2 Aug 2018 01:42:43 -0700 Subject: [PATCH 804/903] staging: gasket: remove "reset type" param from framework The "type of reset" parameter to the gasket device reset APIs isn't required by the only gasket device submitted upstream, apex. The framework documents the param as private to the device driver and a pass-through at the gasket layer, but the gasket core calls the device driver with a hardcoded reset type of zero, which is not documented as having a predefined meaning. In light of all this, remove the reset type parameter from the framework. Remove the reset ioctl reset type parameter, and bump the framework version number to reflect the interface change. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket.h | 4 ++-- drivers/staging/gasket/gasket_constants.h | 2 +- drivers/staging/gasket/gasket_core.c | 11 +++++------ drivers/staging/gasket/gasket_core.h | 13 +++---------- drivers/staging/gasket/gasket_ioctl.c | 3 +-- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/staging/gasket/gasket.h b/drivers/staging/gasket/gasket.h index 9f709f0c5a2b..a0f065c517a5 100644 --- a/drivers/staging/gasket/gasket.h +++ b/drivers/staging/gasket/gasket.h @@ -52,8 +52,8 @@ struct gasket_coherent_alloc_config_ioctl { /* Base number for all Gasket-common IOCTLs */ #define GASKET_IOCTL_BASE 0xDC -/* Reset the device using the specified reset type. */ -#define GASKET_IOCTL_RESET _IOW(GASKET_IOCTL_BASE, 0, unsigned long) +/* Reset the device. */ +#define GASKET_IOCTL_RESET _IO(GASKET_IOCTL_BASE, 0) /* Associate the specified [event]fd with the specified interrupt. */ #define GASKET_IOCTL_SET_EVENTFD \ diff --git a/drivers/staging/gasket/gasket_constants.h b/drivers/staging/gasket/gasket_constants.h index 82ed3f21e8ae..50d87c7b178c 100644 --- a/drivers/staging/gasket/gasket_constants.h +++ b/drivers/staging/gasket/gasket_constants.h @@ -3,7 +3,7 @@ #ifndef __GASKET_CONSTANTS_H__ #define __GASKET_CONSTANTS_H__ -#define GASKET_FRAMEWORK_VERSION "1.1.1" +#define GASKET_FRAMEWORK_VERSION "1.1.2" /* * The maximum number of simultaneous device types supported by the framework. diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index f76f4a0ecbac..2b75f100da4d 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1294,7 +1294,7 @@ static int gasket_release(struct inode *inode, struct file *file) ownership->owner = 0; /* Forces chip reset before we unmap the page tables. */ - driver_desc->device_reset_cb(gasket_dev, 0); + driver_desc->device_reset_cb(gasket_dev); for (i = 0; i < driver_desc->num_page_tables; ++i) { gasket_page_table_unmap_all(gasket_dev->page_table[i]); @@ -1622,18 +1622,18 @@ const char *gasket_num_name_lookup(uint num, } EXPORT_SYMBOL(gasket_num_name_lookup); -int gasket_reset(struct gasket_dev *gasket_dev, uint reset_type) +int gasket_reset(struct gasket_dev *gasket_dev) { int ret; mutex_lock(&gasket_dev->mutex); - ret = gasket_reset_nolock(gasket_dev, reset_type); + ret = gasket_reset_nolock(gasket_dev); mutex_unlock(&gasket_dev->mutex); return ret; } EXPORT_SYMBOL(gasket_reset); -int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) +int gasket_reset_nolock(struct gasket_dev *gasket_dev) { int ret; int i; @@ -1643,8 +1643,7 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type) if (!driver_desc->device_reset_cb) return 0; - /* Perform a device reset of the requested type. */ - ret = driver_desc->device_reset_cb(gasket_dev, reset_type); + ret = driver_desc->device_reset_cb(gasket_dev); if (ret) { dev_dbg(gasket_dev->dev, "Device reset cb returned %d.\n", ret); diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 713bf42de41a..67f5960943a8 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -580,17 +580,12 @@ struct gasket_driver_desc { /* * device_reset_cb: Reset the hardware in question. * @dev: Pointer to the gasket_dev structure for this device. - * @type: Integer representing reset type. (All - * Gasket resets have an integer representing their type - * defined in (device)_ioctl.h; the specific resets are - * device-dependent, but are handled in the device-specific - * callback anyways.) * * Called by reset ioctls. This function should not * lock the gasket_dev mutex. It should return 0 on success * and an error on failure. */ - int (*device_reset_cb)(struct gasket_dev *dev, uint reset_type); + int (*device_reset_cb)(struct gasket_dev *dev); }; /* @@ -615,15 +610,13 @@ void gasket_unregister_device(const struct gasket_driver_desc *desc); /* * Reset the Gasket device. * @gasket_dev: Gasket device struct. - * @reset_type: Uint representing requested reset type. Should be - * valid in the underlying callback. * * Calls device_reset_cb. Returns 0 on success and an error code othewrise. * gasket_reset_nolock will not lock the mutex, gasket_reset will. * */ -int gasket_reset(struct gasket_dev *gasket_dev, uint reset_type); -int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type); +int gasket_reset(struct gasket_dev *gasket_dev); +int gasket_reset_nolock(struct gasket_dev *gasket_dev); /* * Memory management functions. These will likely be spun off into their own diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index d3397cc74e69..0ca48e688818 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -304,8 +304,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) */ switch (cmd) { case GASKET_IOCTL_RESET: - trace_gasket_ioctl_integer_data(arg); - retval = gasket_reset(gasket_dev, arg); + retval = gasket_reset(gasket_dev); break; case GASKET_IOCTL_SET_EVENTFD: retval = gasket_set_event_fd(gasket_dev, argp); From d9da1cbd0ba61dca36b96e66194f3f2f5b2e63e8 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 2 Aug 2018 01:42:44 -0700 Subject: [PATCH 805/903] staging: gasket: apex: drop reset type param Apex doesn't implement different types of resets based on the reset type param passed through the gasket layer or from userspace via the gasket_reset ioctl. The reset type is dropped from the gasket framework in a previous patch due to a lack of present need and non-conforming use of this parameter by the framework. Drop the parameter from the apex driver as well. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index dfbff47b4608..9577fde15a53 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -56,10 +56,6 @@ #define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */ -enum apex_reset_types { - APEX_CHIP_REINIT_RESET = 3, -}; - /* Check reset 120 times */ #define APEX_RESET_RETRY 120 /* Wait 100 ms between checks. Total 12 sec wait maximum. */ @@ -258,7 +254,7 @@ static int apex_get_status(struct gasket_dev *gasket_dev) } /* Enter GCB reset state. */ -static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) +static int apex_enter_reset(struct gasket_dev *gasket_dev) { if (bypass_top_level) return 0; @@ -313,7 +309,7 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) } /* Quit GCB reset state. */ -static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) +static int apex_quit_reset(struct gasket_dev *gasket_dev) { u32 val0, val1; @@ -413,7 +409,7 @@ static int apex_device_cleanup(struct gasket_dev *gasket_dev) __func__, gasket_dev, hib_error, scalar_error); if (allow_power_save) - ret = apex_enter_reset(gasket_dev, APEX_CHIP_REINIT_RESET); + ret = apex_enter_reset(gasket_dev); return ret; } @@ -429,7 +425,7 @@ static bool is_gcb_in_reset(struct gasket_dev *gasket_dev) } /* Reset the hardware, then quit reset. Called on device open. */ -static int apex_reset(struct gasket_dev *gasket_dev, uint type) +static int apex_reset(struct gasket_dev *gasket_dev) { int ret; @@ -442,11 +438,11 @@ static int apex_reset(struct gasket_dev *gasket_dev, uint type) */ dev_dbg(gasket_dev->dev, "%s: toggle reset\n", __func__); - ret = apex_enter_reset(gasket_dev, type); + ret = apex_enter_reset(gasket_dev); if (ret) return ret; } - ret = apex_quit_reset(gasket_dev, type); + ret = apex_quit_reset(gasket_dev); return ret; } @@ -456,7 +452,7 @@ static int apex_add_dev_cb(struct gasket_dev *gasket_dev) ulong page_table_ready, msix_table_ready; int retries = 0; - apex_reset(gasket_dev, 0); + apex_reset(gasket_dev); while (retries < APEX_RESET_RETRY) { page_table_ready = @@ -611,7 +607,7 @@ static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev) /* On device open, perform a core reinit reset. */ static int apex_device_open_cb(struct gasket_dev *gasket_dev) { - return gasket_reset_nolock(gasket_dev, APEX_CHIP_REINIT_RESET); + return gasket_reset_nolock(gasket_dev); } static const struct pci_device_id apex_pci_ids[] = { From 025556d55d6edf3b3be1267a481be0890b96cc65 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 2 Aug 2018 01:42:38 -0700 Subject: [PATCH 806/903] staging: gasket: apex: enable power save mode by default Set default value of allow_power_save parameter to enable power save mode, which is expected to be the state usually desired. Signed-off-by: Marty Faltesek Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 9577fde15a53..42cef68eb4c1 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -229,7 +229,7 @@ static struct gasket_interrupt_desc apex_interrupts[] = { /* Allows device to enter power save upon driver close(). */ -static int allow_power_save; +static int allow_power_save = 1; /* Allows SW based clock gating. */ static int allow_sw_clock_gating; From 156c3df8d4db4e693c062978186f44079413d74d Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Thu, 2 Aug 2018 17:39:17 +0800 Subject: [PATCH 807/903] staging: erofs: disable compiling temporarile As Stephen Rothwell reported: "After merging the staging tree, today's linux-next build (x86_64 allmodconfig) failed like this: drivers/staging/erofs/super.c: In function 'erofs_read_super': drivers/staging/erofs/super.c:343:17: error: 'MS_RDONLY' undeclared (first use in this function); did you mean 'IS_RDONLY'? sb->s_flags |= MS_RDONLY | MS_NOATIME; ^~~~~~~~~ IS_RDONLY drivers/staging/erofs/super.c:343:17: note: each undeclared identifier is reported only once for each function it appears in drivers/staging/erofs/super.c:343:29: error: 'MS_NOATIME' undeclared (first use in this function); did you mean 'S_NOATIME'? sb->s_flags |= MS_RDONLY | MS_NOATIME; ^~~~~~~~~~ S_NOATIME drivers/staging/erofs/super.c: In function 'erofs_mount': drivers/staging/erofs/super.c:501:10: warning: passing argument 5 of 'mount_bdev' makes integer from pointer without a cast [-Wint-conversion] &priv, erofs_fill_super); ^~~~~~~~~~~~~~~~ In file included from include/linux/buffer_head.h:12:0, from drivers/staging/erofs/super.c:14: include/linux/fs.h:2151:23: note: expected 'size_t {aka long unsigned int}' but argument is of type 'int (*)(struct super_block *, void *, int)' extern struct dentry *mount_bdev(struct file_system_type *fs_type, ^~~~~~~~~~ drivers/staging/erofs/super.c:500:9: error: too few arguments to function 'mount_bdev' return mount_bdev(fs_type, flags, dev_name, ^~~~~~~~~~ In file included from include/linux/buffer_head.h:12:0, from drivers/staging/erofs/super.c:14: include/linux/fs.h:2151:23: note: declared here extern struct dentry *mount_bdev(struct file_system_type *fs_type, ^~~~~~~~~~ drivers/staging/erofs/super.c: At top level: drivers/staging/erofs/super.c:518:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .mount = erofs_mount, ^~~~~~~~~~~ drivers/staging/erofs/super.c:518:20: note: (near initialization for 'erofs_fs_type.mount') drivers/staging/erofs/super.c: In function 'erofs_remount': drivers/staging/erofs/super.c:630:12: error: 'MS_RDONLY' undeclared (first use in this function); did you mean 'IS_RDONLY'? *flags |= MS_RDONLY; ^~~~~~~~~ IS_RDONLY drivers/staging/erofs/super.c: At top level: drivers/staging/erofs/super.c:640:16: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .remount_fs = erofs_remount, ^~~~~~~~~~~~~ Caused by various commits creating erofs in the staging tree interacting with various commits redoing the mount infrastructure in the vfs tree. I have disabed CONFIG_EROFS_FS for now:" The reason of compiling error is: Since -next collects and merges developing patches including common vfs stuff from multi-trees, but those patches didn't cover erofs, such as: ('vfs: Suppress MS_* flag defs within the kernel unless explicitly enabled") https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git/commit/?h=for-next&id=109b45090d7d3ce2797bb1ef7f70eead5bfe0ff3 ("vfs: Require specification of size of mount data for internal mounts") https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git/commit/?h=for-next&id=0a191e4505a4f255e6513b49426213da69bf0e80 Above vfs related patches has not been merged in staging tree, if we submit those erofs patches to staging mailing list and after including them in staging-{test,nexts} tree, it can easily cause compiling error. We worked out some patches to adjust those vfs change, but now we just submit them to -next tree temporarily to avoid compiling error. For potentail conflict in between erofs and vfs changes in incoming merge window, Stephen suggested that we can disable CONFIG_EROFS_FS temporarily to pass merge window, and after that we can do restore by reenabling CONFIG_EROFS_FS and applying those fixing patches. Also Greg confirmed this solution. So, let's disable compiling erofs for a while. Suggested-by: Stephen Rothwell Signed-off-by: Gao Xiang Reviewed-by: Gao Xiang Signed-off-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index 663b755bf2fb..96f614934df1 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig @@ -2,7 +2,7 @@ config EROFS_FS tristate "EROFS filesystem support" - depends on BLOCK + depends on BROKEN help EROFS(Enhanced Read-Only File System) is a lightweight read-only file system with modern designs (eg. page-sized From 3f285135bcff65c4817541edbee55e5b7f7917d2 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 2 Aug 2018 16:57:02 +0530 Subject: [PATCH 808/903] staging: wilc1000: fix compilation warning for ARCH PowerPC Fix below warning reported for PowerPC arch compilation include/uapi/linux/byteorder/big_endian.h:95:37: warning: passing argument 1 of '__swab32s' makes pointer from integer without a cast [-Wint-conversion] Fixes: 02211edc9a1f ("staging: wilc1000: fix endianness warnings reported by sparse") Reported-by: kbuild test robot Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_sdio.c | 2 +- drivers/staging/wilc1000/wilc_spi.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 8bda55018e3e..1908afa11631 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -563,7 +563,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) } } - le32_to_cpus(*data); + le32_to_cpus(data); return 1; diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 064892d5f132..a85f87bc41d2 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -699,7 +699,7 @@ static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data) return 0; } - le32_to_cpus(*data); + le32_to_cpus(data); return 1; } @@ -778,7 +778,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) return 0; } - le32_to_cpus(*data); + le32_to_cpus(data); return 1; } From 2ec34a4393f1799f1c0fd49afb930e877de27452 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Thu, 2 Aug 2018 12:24:42 -0500 Subject: [PATCH 809/903] staging: fsl-dpaa2/eth: Use named arguments in function definition Checkpatch complains about unnamed arguments in a function prototype, so fix it. Signed-off-by: Ioana Radulescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index 6b70c663a8b3..506466778b2c 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -277,10 +277,10 @@ struct dpaa2_eth_fq { struct dpaa2_eth_channel *channel; enum dpaa2_eth_fq_type type; - void (*consume)(struct dpaa2_eth_priv *, - struct dpaa2_eth_channel *, - const struct dpaa2_fd *, - struct napi_struct *, + void (*consume)(struct dpaa2_eth_priv *priv, + struct dpaa2_eth_channel *ch, + const struct dpaa2_fd *fd, + struct napi_struct *napi, u16 queue_id); struct dpaa2_eth_fq_stats stats; }; From a9df8cd5e3fcd046c20e036073b1f90854b3e863 Mon Sep 17 00:00:00 2001 From: Sohil Ladhani Date: Sun, 5 Aug 2018 16:59:55 +0530 Subject: [PATCH 810/903] Staging: rtlwifi: base: Modified the line ending with a parenthesis This patch fixes the "Lines should not end with a '('" warning reported by checkpatch.pl script. The line containing 'rtl_mrate_idx_to_arfr_id' function previously ended with '(', which did not conform to the linux kernel coding style. Signed-off-by: Sohil Ladhani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/base.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c index e46e47d93d7d..a4e2041a5ead 100644 --- a/drivers/staging/rtlwifi/base.c +++ b/drivers/staging/rtlwifi/base.c @@ -685,9 +685,8 @@ static void _rtl_query_protection_mode(struct ieee80211_hw *hw, } } -u8 rtl_mrate_idx_to_arfr_id( - struct ieee80211_hw *hw, u8 rate_index, - enum wireless_mode wirelessmode) +u8 rtl_mrate_idx_to_arfr_id(struct ieee80211_hw *hw, u8 rate_index, + enum wireless_mode wirelessmode) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &rtlpriv->phy; From ae3b4ed1a23fc197716c4bcf1e32be37f2472d3b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 14:11:54 +0200 Subject: [PATCH 811/903] staging: rtl8188eu: use phydm_regdefine11n.h from rtlwifi Use rtlwifi/phydm/phydm_regdefine11n.h instead of odm_RegDefine11N.h and remove the now unused odm_RegDefine11N.h. The defines from odm_RegDefine11N.h are defined with the same values in rtlwifi/phydm/phydm_regdefine11n.h. There is one define that is named different, but that one is not used in the rtl8188eu code. rtl8188eu: #define ODM_REG_RX_PATH_11N 0xC04 rtlwifi: #defnie ODM_REG_BB_RX_PATH_11N 0xC04 Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../rtl8188eu/include/odm_RegDefine11N.h | 158 ------------------ .../staging/rtl8188eu/include/odm_precomp.h | 2 +- 2 files changed, 1 insertion(+), 159 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/odm_RegDefine11N.h diff --git a/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h b/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h deleted file mode 100644 index 8663a8ccc75d..000000000000 --- a/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h +++ /dev/null @@ -1,158 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __ODM_REGDEFINE11N_H__ -#define __ODM_REGDEFINE11N_H__ - - -/* 2 RF REG LIST */ -#define ODM_REG_RF_MODE_11N 0x00 -#define ODM_REG_RF_0B_11N 0x0B -#define ODM_REG_CHNBW_11N 0x18 -#define ODM_REG_T_METER_11N 0x24 -#define ODM_REG_RF_25_11N 0x25 -#define ODM_REG_RF_26_11N 0x26 -#define ODM_REG_RF_27_11N 0x27 -#define ODM_REG_RF_2B_11N 0x2B -#define ODM_REG_RF_2C_11N 0x2C -#define ODM_REG_RXRF_A3_11N 0x3C -#define ODM_REG_T_METER_92D_11N 0x42 -#define ODM_REG_T_METER_88E_11N 0x42 - - - -/* 2 BB REG LIST */ -/* PAGE 8 */ -#define ODM_REG_BB_CTRL_11N 0x800 -#define ODM_REG_RF_PIN_11N 0x804 -#define ODM_REG_PSD_CTRL_11N 0x808 -#define ODM_REG_TX_ANT_CTRL_11N 0x80C -#define ODM_REG_BB_PWR_SAV5_11N 0x818 -#define ODM_REG_CCK_RPT_FORMAT_11N 0x824 -#define ODM_REG_RX_DEFAULT_A_11N 0x858 -#define ODM_REG_RX_DEFAULT_B_11N 0x85A -#define ODM_REG_BB_PWR_SAV3_11N 0x85C -#define ODM_REG_ANTSEL_CTRL_11N 0x860 -#define ODM_REG_RX_ANT_CTRL_11N 0x864 -#define ODM_REG_PIN_CTRL_11N 0x870 -#define ODM_REG_BB_PWR_SAV1_11N 0x874 -#define ODM_REG_ANTSEL_PATH_11N 0x878 -#define ODM_REG_BB_3WIRE_11N 0x88C -#define ODM_REG_SC_CNT_11N 0x8C4 -#define ODM_REG_PSD_DATA_11N 0x8B4 -/* PAGE 9 */ -#define ODM_REG_ANT_MAPPING1_11N 0x914 -#define ODM_REG_ANT_MAPPING2_11N 0x918 -/* PAGE A */ -#define ODM_REG_CCK_ANTDIV_PARA1_11N 0xA00 -#define ODM_REG_CCK_CCA_11N 0xA0A -#define ODM_REG_CCK_ANTDIV_PARA2_11N 0xA0C -#define ODM_REG_CCK_ANTDIV_PARA3_11N 0xA10 -#define ODM_REG_CCK_ANTDIV_PARA4_11N 0xA14 -#define ODM_REG_CCK_FILTER_PARA1_11N 0xA22 -#define ODM_REG_CCK_FILTER_PARA2_11N 0xA23 -#define ODM_REG_CCK_FILTER_PARA3_11N 0xA24 -#define ODM_REG_CCK_FILTER_PARA4_11N 0xA25 -#define ODM_REG_CCK_FILTER_PARA5_11N 0xA26 -#define ODM_REG_CCK_FILTER_PARA6_11N 0xA27 -#define ODM_REG_CCK_FILTER_PARA7_11N 0xA28 -#define ODM_REG_CCK_FILTER_PARA8_11N 0xA29 -#define ODM_REG_CCK_FA_RST_11N 0xA2C -#define ODM_REG_CCK_FA_MSB_11N 0xA58 -#define ODM_REG_CCK_FA_LSB_11N 0xA5C -#define ODM_REG_CCK_CCA_CNT_11N 0xA60 -#define ODM_REG_BB_PWR_SAV4_11N 0xA74 -/* PAGE B */ -#define ODM_REG_LNA_SWITCH_11N 0xB2C -#define ODM_REG_PATH_SWITCH_11N 0xB30 -#define ODM_REG_RSSI_CTRL_11N 0xB38 -#define ODM_REG_CONFIG_ANTA_11N 0xB68 -#define ODM_REG_RSSI_BT_11N 0xB9C -/* PAGE C */ -#define ODM_REG_OFDM_FA_HOLDC_11N 0xC00 -#define ODM_REG_RX_PATH_11N 0xC04 -#define ODM_REG_TRMUX_11N 0xC08 -#define ODM_REG_OFDM_FA_RSTC_11N 0xC0C -#define ODM_REG_RXIQI_MATRIX_11N 0xC14 -#define ODM_REG_TXIQK_MATRIX_LSB1_11N 0xC4C -#define ODM_REG_IGI_A_11N 0xC50 -#define ODM_REG_ANTDIV_PARA2_11N 0xC54 -#define ODM_REG_IGI_B_11N 0xC58 -#define ODM_REG_ANTDIV_PARA3_11N 0xC5C -#define ODM_REG_BB_PWR_SAV2_11N 0xC70 -#define ODM_REG_RX_OFF_11N 0xC7C -#define ODM_REG_TXIQK_MATRIXA_11N 0xC80 -#define ODM_REG_TXIQK_MATRIXB_11N 0xC88 -#define ODM_REG_TXIQK_MATRIXA_LSB2_11N 0xC94 -#define ODM_REG_TXIQK_MATRIXB_LSB2_11N 0xC9C -#define ODM_REG_RXIQK_MATRIX_LSB_11N 0xCA0 -#define ODM_REG_ANTDIV_PARA1_11N 0xCA4 -#define ODM_REG_OFDM_FA_TYPE1_11N 0xCF0 -/* PAGE D */ -#define ODM_REG_OFDM_FA_RSTD_11N 0xD00 -#define ODM_REG_OFDM_FA_TYPE2_11N 0xDA0 -#define ODM_REG_OFDM_FA_TYPE3_11N 0xDA4 -#define ODM_REG_OFDM_FA_TYPE4_11N 0xDA8 -/* PAGE E */ -#define ODM_REG_TXAGC_A_6_18_11N 0xE00 -#define ODM_REG_TXAGC_A_24_54_11N 0xE04 -#define ODM_REG_TXAGC_A_1_MCS32_11N 0xE08 -#define ODM_REG_TXAGC_A_MCS0_3_11N 0xE10 -#define ODM_REG_TXAGC_A_MCS4_7_11N 0xE14 -#define ODM_REG_TXAGC_A_MCS8_11_11N 0xE18 -#define ODM_REG_TXAGC_A_MCS12_15_11N 0xE1C -#define ODM_REG_FPGA0_IQK_11N 0xE28 -#define ODM_REG_TXIQK_TONE_A_11N 0xE30 -#define ODM_REG_RXIQK_TONE_A_11N 0xE34 -#define ODM_REG_TXIQK_PI_A_11N 0xE38 -#define ODM_REG_RXIQK_PI_A_11N 0xE3C -#define ODM_REG_TXIQK_11N 0xE40 -#define ODM_REG_RXIQK_11N 0xE44 -#define ODM_REG_IQK_AGC_PTS_11N 0xE48 -#define ODM_REG_IQK_AGC_RSP_11N 0xE4C -#define ODM_REG_BLUETOOTH_11N 0xE6C -#define ODM_REG_RX_WAIT_CCA_11N 0xE70 -#define ODM_REG_TX_CCK_RFON_11N 0xE74 -#define ODM_REG_TX_CCK_BBON_11N 0xE78 -#define ODM_REG_OFDM_RFON_11N 0xE7C -#define ODM_REG_OFDM_BBON_11N 0xE80 -#define ODM_REG_TX2RX_11N 0xE84 -#define ODM_REG_TX2TX_11N 0xE88 -#define ODM_REG_RX_CCK_11N 0xE8C -#define ODM_REG_RX_OFDM_11N 0xED0 -#define ODM_REG_RX_WAIT_RIFS_11N 0xED4 -#define ODM_REG_RX2RX_11N 0xED8 -#define ODM_REG_STANDBY_11N 0xEDC -#define ODM_REG_SLEEP_11N 0xEE0 -#define ODM_REG_PMPD_ANAEN_11N 0xEEC - - - - - - - -/* 2 MAC REG LIST */ -#define ODM_REG_BB_RST_11N 0x02 -#define ODM_REG_ANTSEL_PIN_11N 0x4C -#define ODM_REG_EARLY_MODE_11N 0x4D0 -#define ODM_REG_RSSI_MONITOR_11N 0x4FE -#define ODM_REG_EDCA_VO_11N 0x500 -#define ODM_REG_EDCA_VI_11N 0x504 -#define ODM_REG_EDCA_BE_11N 0x508 -#define ODM_REG_EDCA_BK_11N 0x50C -#define ODM_REG_TXPAUSE_11N 0x522 -#define ODM_REG_RESP_TX_11N 0x6D8 -#define ODM_REG_ANT_TRAIN_PARA1_11N 0x7b0 -#define ODM_REG_ANT_TRAIN_PARA2_11N 0x7b4 - - -/* DIG Related */ -#define ODM_BIT_IGI_11N 0x0000007F - - -#endif diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h index 4d0dd12645bd..658a938df4c1 100644 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -24,7 +24,7 @@ #include "odm.h" #include "odm_HWConfig.h" #include "odm_debug.h" -#include "odm_RegDefine11N.h" +#include "../../rtlwifi/phydm/phydm_regdefine11n.h" #include "hal8188e_rate_adaptive.h" /* for RA,Power training */ #include "rtl8188e_hal.h" From a13bb977bca68b2c15a505c60ed6382398ef656d Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 3 Aug 2018 08:44:37 +0100 Subject: [PATCH 812/903] staging: wlan-ng: remove unused definitions from p80211types.h Remove the following unused definitions from p80211types.h: * struct p80211enum * struct p80211enumpair * struct catlistitem declaration and associated function pointer typedefs (along with preceding block comment) Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211types.h | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211types.h b/drivers/staging/wlan-ng/p80211types.h index 7c37d56dd9b7..ac254542fde6 100644 --- a/drivers/staging/wlan-ng/p80211types.h +++ b/drivers/staging/wlan-ng/p80211types.h @@ -193,20 +193,6 @@ P80211DID_MASK_ACCESS, \ P80211DID_LSB_ACCESS) -/*----------------------------------------------------------------*/ -/* The following structure types are used for the representation */ -/* of ENUMint type metadata. */ - -struct p80211enumpair { - u32 val; - char *name; -}; - -struct p80211enum { - int nitems; - struct p80211enumpair *list; -}; - /*----------------------------------------------------------------*/ /* The following structure types are used to store data items in */ /* messages. */ @@ -330,17 +316,4 @@ struct p80211item_unk4096 { u8 data[4096]; } __packed; -struct catlistitem; - -/*----------------------------------------------------------------*/ -/* The following structure type is used to represent all of the */ -/* metadata items. Some components may choose to use more, */ -/* less or different metadata items. */ - -typedef void (*p80211_totext_t) (struct catlistitem *, u32 did, u8 *itembuf, - char *textbuf); -typedef void (*p80211_fromtext_t) (struct catlistitem *, u32 did, u8 *itembuf, - char *textbuf); -typedef u32(*p80211_valid_t) (struct catlistitem *, u32 did, u8 *itembuf); - #endif /* _P80211TYPES_H */ From 5bf553b671cfab548185ee0b75cc80eda816f81c Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 2 Aug 2018 18:49:49 -0700 Subject: [PATCH 813/903] staging: gasket: core: remove registration logs Remove logs for loading gasket drivers. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 2b75f100da4d..fa477d0c3c74 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1758,9 +1758,6 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) } mutex_unlock(&g_mutex); - pr_info("Loaded %s driver, framework version %s\n", - driver_desc->name, GASKET_FRAMEWORK_VERSION); - if (desc_idx == -1) { pr_err("Too many Gasket drivers loaded: %d\n", GASKET_FRAMEWORK_DESC_MAX); @@ -1808,7 +1805,6 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) goto fail2; } - pr_info("Driver registered successfully.\n"); return 0; fail2: From 8445a07db8784cfc5b11d7ceebfe698d1ee086ea Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 2 Aug 2018 18:49:50 -0700 Subject: [PATCH 814/903] staging: gasket: core: device register debug log cleanups At device/driver registration time, convert a not-very-informative info message to a more informative debug message, drop some not overly helpful debug messages. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index fa477d0c3c74..91db71c23880 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1735,7 +1735,8 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) int desc_idx = -1; struct gasket_internal_desc *internal; - pr_info("Initializing Gasket framework device\n"); + pr_debug("Loading %s driver version %s\n", driver_desc->name, + driver_desc->driver_version); /* Check for duplicates and find a free slot. */ mutex_lock(&g_mutex); @@ -1764,8 +1765,6 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) return -EBUSY; } - /* Internal structure setup. */ - pr_debug("Performing initial internal structure setup.\n"); internal = &g_descs[desc_idx]; mutex_init(&internal->mutex); memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX); @@ -1788,7 +1787,6 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) * Not using pci_register_driver() (without underscores), as it * depends on KBUILD_MODNAME, and this is a shared file. */ - pr_debug("Registering PCI driver.\n"); ret = __pci_register_driver(&internal->pci, driver_desc->module, driver_desc->name); if (ret) { @@ -1796,7 +1794,6 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) goto fail1; } - pr_debug("Registering char driver.\n"); ret = register_chrdev_region(MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, driver_desc->name); From a43a98da75ff2821e484e5cb2a7f3ad0354255c8 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 2 Aug 2018 18:49:51 -0700 Subject: [PATCH 815/903] staging: gasket: core: add subsystem and device info to logs Identify gasket as the subsystem printing various messages. Add the driver name to appropriate messages to indicate which driver has a problem. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 91db71c23880..93a4d9f08eaa 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -6,6 +6,9 @@ * * Copyright (C) 2018 Google, Inc. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include "gasket_core.h" #include "gasket_interrupt.h" @@ -208,7 +211,7 @@ static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc, gasket_dev = *pdev = kzalloc(sizeof(*gasket_dev), GFP_KERNEL); if (!gasket_dev) { - pr_err("no memory for device\n"); + pr_err("no memory for device %s\n", kobj_name); return -ENOMEM; } internal_desc->devs[dev_idx] = gasket_dev; @@ -1760,7 +1763,7 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) mutex_unlock(&g_mutex); if (desc_idx == -1) { - pr_err("Too many Gasket drivers loaded: %d\n", + pr_err("too many drivers loaded, max %d\n", GASKET_FRAMEWORK_DESC_MAX); return -EBUSY; } @@ -1790,7 +1793,8 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) ret = __pci_register_driver(&internal->pci, driver_desc->module, driver_desc->name); if (ret) { - pr_err("cannot register pci driver [ret=%d]\n", ret); + pr_err("cannot register %s pci driver [ret=%d]\n", + driver_desc->name, ret); goto fail1; } @@ -1798,7 +1802,8 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) driver_desc->minor), GASKET_DEV_MAX, driver_desc->name); if (ret) { - pr_err("cannot register char driver [ret=%d]\n", ret); + pr_err("cannot register %s char driver [ret=%d]\n", + driver_desc->name, ret); goto fail2; } From 515bc432e4a5b597e36d915df9fb3194c7083078 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 2 Aug 2018 18:49:52 -0700 Subject: [PATCH 816/903] Revert "staging: gasket: core: hold reference to pci_dev while used" There's no need to take an additional reference on the pci_dev structure for the pointer copy saved in gasket data structures. This reverts commit: 8dd8a48b9a7d ("staging: gasket: core: hold reference to pci_dev while used") Reported-by: Dmitry Torokhov Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 93a4d9f08eaa..2d209e36cf37 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -255,7 +255,6 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev) internal_desc->devs[gasket_dev->dev_idx] = NULL; mutex_unlock(&internal_desc->mutex); put_device(gasket_dev->dev); - pci_dev_put(gasket_dev->pci_dev); kfree(gasket_dev); } @@ -1477,7 +1476,7 @@ static int gasket_pci_probe(struct pci_dev *pci_dev, ret = gasket_alloc_dev(internal_desc, parent, &gasket_dev, kobj_name); if (ret) return ret; - gasket_dev->pci_dev = pci_dev_get(pci_dev); + gasket_dev->pci_dev = pci_dev; if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) { pr_err("Cannot create %s device %s [ret = %ld]\n", driver_desc->name, gasket_dev->dev_info.name, From e61c7a1caa97b5e90e7dee927231cdd4cc71d434 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 3 Aug 2018 16:26:13 +0530 Subject: [PATCH 817/903] staging: wilc1000: added Microchip copyright notice header Cleanup the copyright notice header from the WILC1000 files. Replace copyright header of 'Atmel' & 'NewportMedia' with 'Microchip & its subsidiaries'. Also added the same copyright notice header for all wilc1000 driver source and header files. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 5 +++++ drivers/staging/wilc1000/coreconfigurator.h | 5 +++++ drivers/staging/wilc1000/host_interface.c | 5 +++++ drivers/staging/wilc1000/host_interface.h | 5 +++++ drivers/staging/wilc1000/linux_mon.c | 5 +++++ drivers/staging/wilc1000/linux_wlan.c | 5 +++++ drivers/staging/wilc1000/wilc_debugfs.c | 10 ++-------- drivers/staging/wilc1000/wilc_sdio.c | 5 ++--- drivers/staging/wilc1000/wilc_spi.c | 5 ++--- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 5 +++++ drivers/staging/wilc1000/wilc_wfi_cfgoperations.h | 5 +++++ drivers/staging/wilc1000/wilc_wfi_netdevice.h | 5 +++++ drivers/staging/wilc1000/wilc_wlan.c | 5 +++++ drivers/staging/wilc1000/wilc_wlan.h | 5 +++++ drivers/staging/wilc1000/wilc_wlan_cfg.c | 12 ++++-------- drivers/staging/wilc1000/wilc_wlan_cfg.h | 12 ++++-------- drivers/staging/wilc1000/wilc_wlan_if.h | 12 ++++-------- 17 files changed, 73 insertions(+), 38 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index e09f10da036d..e5420676afb3 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -1,4 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #include #include "coreconfigurator.h" diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 90d3d656e8cd..b62acb447383 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -1,4 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #ifndef CORECONFIGURATOR_H #define CORECONFIGURATOR_H diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 86d8aafafb06..42d8accb1f60 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1,4 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #include "wilc_wfi_netdevice.h" #define HOST_IF_SCAN_TIMEOUT 4000 diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 3ddeec2f2f1f..84866a62a4d4 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -1,4 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries + * All rights reserved. + */ + #ifndef HOST_INT_H #define HOST_INT_H #include diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index 9d12a9111213..1afdb9e86bc1 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -1,4 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #include "wilc_wfi_cfgoperations.h" struct wilc_wfi_radiotap_hdr { diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index c9e771a7f7e2..01cf4bd2e192 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1,4 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #include #include #include diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c index ac26e94ae097..edc72876458d 100644 --- a/drivers/staging/wilc1000/wilc_debugfs.c +++ b/drivers/staging/wilc1000/wilc_debugfs.c @@ -1,13 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* - * NewportMedia WiFi chipset driver test tools - wilc-debug - * Copyright (c) 2012 NewportMedia Inc. - * Author: SSW - * - * 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. - * + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. */ #if defined(WILC_DEBUGFS) diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 1908afa11631..b2080d8b801f 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) Atmel Corporation. All rights reserved. - * - * Module Name: wilc_sdio.c + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. */ #include diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index a85f87bc41d2..5517477d875a 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) Atmel Corporation. All rights reserved. - * - * Module Name: wilc_spi.c + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. */ #include diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 0caf89699781..7cd033004651 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1,4 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #include "wilc_wfi_cfgoperations.h" #define NO_ENCRYPT 0 diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index a69103b44958..be412b65926c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -1,4 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #ifndef NM_WFI_CFGOPERATIONS #define NM_WFI_CFGOPERATIONS #include "wilc_wfi_netdevice.h" diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index a0e2e11c1c39..b7eee772f3fe 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -1,4 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #ifndef WILC_WFI_NETDEVICE #define WILC_WFI_NETDEVICE diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index b9760e825dd5..cd273522eabf 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1,4 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #include #include #include "wilc_wfi_netdevice.h" diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index 696cf1f229b6..1a4ac4911324 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -1,4 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + #ifndef WILC_WLAN_H #define WILC_WLAN_H diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index b215f982a246..421576386ab4 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -1,12 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -/* ////////////////////////////////////////////////////////////////////////// */ -/* */ -/* Copyright (c) Atmel Corporation. All rights reserved. */ -/* */ -/* Module Name: wilc_wlan_cfg.c */ -/* */ -/* */ -/* ///////////////////////////////////////////////////////////////////////// */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ #include "wilc_wlan_if.h" #include "wilc_wlan.h" diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h b/drivers/staging/wilc1000/wilc_wlan_cfg.h index 2aa7a9beb8d2..0c649d1f6f11 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.h +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.h @@ -1,12 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* ////////////////////////////////////////////////////////////////////////// */ -/* */ -/* Copyright (c) Atmel Corporation. All rights reserved. */ -/* */ -/* Module Name: wilc_wlan_cfg.h */ -/* */ -/* */ -/* ///////////////////////////////////////////////////////////////////////// */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ #ifndef WILC_WLAN_CFG_H #define WILC_WLAN_CFG_H diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 598c8dc3d07b..00d13b153f80 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -1,12 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* ///////////////////////////////////////////////////////////////////////// */ -/* */ -/* Copyright (c) Atmel Corporation. All rights reserved. */ -/* */ -/* Module Name: wilc_wlan_if.h */ -/* */ -/* */ -/* ///////////////////////////////////////////////////////////////////////// */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ #ifndef WILC_WLAN_IF_H #define WILC_WLAN_IF_H From 2345ef30ea30cdb91f08e54eff3b5e807a0d4cc9 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 3 Aug 2018 16:26:14 +0530 Subject: [PATCH 818/903] staging: wilc1000: replace ISWILC1000() macro with inline function Cleanup patch to avoid below checkpatch issue by replacing the macro with inline function. Macro argument 'id' may be better as '(id)' to avoid precedence issues. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan.c | 9 +++++++-- drivers/staging/wilc1000/wilc_wlan.h | 2 -- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index cd273522eabf..6787b6e9f124 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -11,6 +11,11 @@ static enum chip_ps_states chip_ps_state = CHIP_WAKEDUP; +static inline bool is_wilc1000(u32 id) +{ + return ((id & 0xfffff000) == 0x100000 ? true : false); +} + static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) { mutex_lock(&wilc->hif_cs); @@ -794,7 +799,7 @@ static void wilc_pllupdate_isr_ext(struct wilc *wilc, u32 int_stats) else mdelay(WILC_PLL_TO_SPI); - while (!(ISWILC1000(wilc_get_chipid(wilc, true)) && --trials)) + while (!(is_wilc1000(wilc_get_chipid(wilc, true)) && --trials)) mdelay(1); } @@ -1294,7 +1299,7 @@ u32 wilc_get_chipid(struct wilc *wilc, bool update) if (chipid == 0 || update) { wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid); wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid); - if (!ISWILC1000(tempchipid)) { + if (!is_wilc1000(tempchipid)) { chipid = 0; return chipid; } diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index 1a4ac4911324..7467188dbf2f 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -9,8 +9,6 @@ #include -#define ISWILC1000(id) ((id & 0xfffff000) == 0x100000 ? 1 : 0) - /******************************************** * * Mac eth header length From 5751e4f164c3bc64a7e632b13b14da1d5330853c Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 3 Aug 2018 16:26:15 +0530 Subject: [PATCH 819/903] staging: wilc1000: remove TODO item for comments and code style Remove below item from TODO as these changes were included as part of previous submitted patch series. 'rework comments and function headers(also coding style)' Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO index 6fd3a4c1004f..862e9eac9d60 100644 --- a/drivers/staging/wilc1000/TODO +++ b/drivers/staging/wilc1000/TODO @@ -1,4 +1,3 @@ TODO: -- rework comments and function headers(also coding style) - support soft-ap and p2p mode - support resume/suspend function From 8add1eb548d2867d6c82863823ac37f84bf6952d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:01:54 +0100 Subject: [PATCH 820/903] staging:rtl8192u: Remove debug member from structures - Style Two structures, (struct dig and struct dynamic_rx_path_sel) contain a u8 member variable representing debug setting. In the file r8192U_dm.c these member variables, for both structures, are initialised to an enumerated constant 'DM_DBG_OFF'. The member variables are never assigned another value, other then off. Later in code the member variables are tested to for equality to 'DM_DBG_OFF' and if that is the case an assignment statement is executed. Since the value of the variables is always off the test is redundant and the conditional branch can just be executed without the test. Since the member variables are then actually used both have been removed, along with the enumerated type which defines debug status, on/off. These are coding style changes to remove unused or redundant code, there should be no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 8 ++------ drivers/staging/rtl8192u/r8192U_dm.h | 8 -------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 0ba1b1e2bc6e..3336798310ac 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1635,7 +1635,6 @@ static void dm_dig_init(struct net_device *dev) /* 2007/10/05 MH Disable DIG scheme now. Not tested. */ dm_digtable.dig_enable_flag = true; dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI; - dm_digtable.dbg_mode = DM_DBG_OFF; /* off=by real rssi value, on=by DM_DigTable.Rssi_val for new dig */ dm_digtable.dig_algorithm_switch = 0; /* 2007/10/04 MH Define init gain threshold. */ @@ -1720,8 +1719,7 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi( /*DbgPrint("DM_DigTable.PreConnectState = %d, DM_DigTable.CurConnectState = %d\n", DM_DigTable.PreConnectState, DM_DigTable.CurConnectState);*/ - if (dm_digtable.dbg_mode == DM_DBG_OFF) - dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; + dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb; /*DbgPrint("DM_DigTable.Rssi_val = %d\n", DM_DigTable.Rssi_val);*/ dm_initial_gain(dev); dm_pd_th(dev); @@ -2398,7 +2396,6 @@ static void dm_init_rxpath_selection(struct net_device *dev) DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; else DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; - DM_RxPathSelTable.DbgMode = DM_DBG_OFF; DM_RxPathSelTable.disabledRF = 0; for (i = 0; i < 4; i++) { DM_RxPathSelTable.rf_rssi[i] = 50; @@ -2440,8 +2437,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) /* decide max/sec/min rssi index */ for (i = 0; i < RF90_PATH_MAX; i++) { - if (!DM_RxPathSelTable.DbgMode) - DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i]; + DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i]; if (priv->brfpath_rxenable[i]) { rf_num++; diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 2ba6a4208870..bc736f2f5a5c 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -96,7 +96,6 @@ enum dig_cck_cs_ratio_state { struct dig { u8 dig_enable_flag; enum dig_algorithm dig_algorithm; - u8 dbg_mode; u8 dig_algorithm_switch; long rssi_low_thresh; @@ -133,7 +132,6 @@ enum cck_rx_path_method { struct dynamic_rx_path_sel { u8 Enable; - u8 DbgMode; enum cck_rx_path_method cck_method; u8 cck_Rx_path; @@ -147,12 +145,6 @@ struct dynamic_rx_path_sel { long cck_pwdb_sta[4]; }; -typedef enum tag_DM_DbgMode_Definition { - DM_DBG_OFF = 0, - DM_DBG_ON = 1, - DM_DBG_MAX -} DM_DBG_E; - typedef struct tag_Tx_Config_Cmd_Format { u32 Op; /* Command packet type. */ u32 Length; /* Command packet length. */ From a2351af9f562a77480ca91c970ea151ceba47c36 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:01:55 +0100 Subject: [PATCH 821/903] staging:rtl8192u: Remove member variable rx_gain_range_max - Style The structure 'dig' defines a member variable, (rx_gain_range_max) which is initialised to the value 'DM_DIG_MAX', (a defined constant). The variable is then used to test and set another variable. Since the member rx_gain_range_max is never assigned any other value then the constant 'DM_DIG_MAX' the code might as well simply use that constant, rather the a member variable set to that constant. The member variable has been removed and the constant used directly in the code. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 5 ++--- drivers/staging/rtl8192u/r8192U_dm.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 3336798310ac..8b9d011e9eec 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1650,7 +1650,6 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.rssi_val = 50; /* for new dig debug rssi value */ dm_digtable.backoff_val = DM_DIG_BACKOFF; - dm_digtable.rx_gain_range_max = DM_DIG_MAX; if (priv->CustomerID == RT_CID_819x_Netcore) dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore; else @@ -1968,8 +1967,8 @@ static void dm_initial_gain( if (dm_digtable.pre_connect_state == dm_digtable.cur_connect_state) { if (dm_digtable.cur_connect_state == DIG_CONNECT) { - if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; + if ((dm_digtable.rssi_val + 10 - dm_digtable.backoff_val) > DM_DIG_MAX) + dm_digtable.cur_ig_value = DM_DIG_MAX; else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; else diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index bc736f2f5a5c..f3e3db18fdd0 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -118,7 +118,6 @@ struct dig { u32 cur_ig_value; u8 backoff_val; - u8 rx_gain_range_max; u8 rx_gain_range_min; bool initialgain_lowerbound_state; From 976a4b90931ff929255652bdfba12eb32ef48b7f Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:01:56 +0100 Subject: [PATCH 822/903] staging:rtl8192u: Remove member initialgain_lowerbound_state - Style The structure 'dig' defines a member variable 'initialgain_lowerbound_state', which although initialised to false, is never used in the code. As a result this unused member variable has been removed. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 1 - drivers/staging/rtl8192u/r8192U_dm.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 8b9d011e9eec..ede596a91c03 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1640,7 +1640,6 @@ static void dm_dig_init(struct net_device *dev) /* 2007/10/04 MH Define init gain threshold. */ dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; - dm_digtable.initialgain_lowerbound_state = false; dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW; dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH; diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index f3e3db18fdd0..ba73dd1d1793 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -119,7 +119,6 @@ struct dig { u8 backoff_val; u8 rx_gain_range_min; - bool initialgain_lowerbound_state; long rssi_val; }; From f835f4b38300b4798a90c90bfed73b6a4f05053e Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:01:57 +0100 Subject: [PATCH 823/903] staging:rtl8192u: Rename enum constants - Style Rename the two constants defined in the enumerated type enum cck_rx_path_method so that they are both uppercase, as suggested by the coding style. This is purely a coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 12 ++++++------ drivers/staging/rtl8192u/r8192U_dm.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index ede596a91c03..86f443ad75f5 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2391,9 +2391,9 @@ static void dm_init_rxpath_selection(struct net_device *dev) DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; if (priv->CustomerID == RT_CID_819x_Netcore) - DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; + DM_RxPathSelTable.cck_method = CCK_RX_VERSION_2; else - DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; + DM_RxPathSelTable.cck_method = CCK_RX_VERSION_1; DM_RxPathSelTable.disabledRF = 0; for (i = 0; i < 4; i++) { DM_RxPathSelTable.rf_rssi[i] = 50; @@ -2429,7 +2429,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) DM_RxPathSelTable.disabledRF = ~DM_RxPathSelTable.disabledRF & 0xf; if (priv->ieee80211->mode == WIRELESS_MODE_B) { - DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; /* pure B mode, fixed cck version2 */ + DM_RxPathSelTable.cck_method = CCK_RX_VERSION_2; /* pure B mode, fixed cck version2 */ /*DbgPrint("Pure B mode, use cck rx version2\n");*/ } @@ -2493,7 +2493,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) rf_num = 0; /* decide max/sec/min cck pwdb index */ - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { + if (DM_RxPathSelTable.cck_method == CCK_RX_VERSION_2) { for (i = 0; i < RF90_PATH_MAX; i++) { if (priv->brfpath_rxenable[i]) { rf_num++; @@ -2551,7 +2551,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) * reg0xA07[3:2]=cck default rx path, reg0xa07[1:0]=cck optional rx path. */ update_cck_rx_path = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { + if (DM_RxPathSelTable.cck_method == CCK_RX_VERSION_2) { cck_default_Rx = cck_rx_ver2_max_index; cck_optional_Rx = cck_rx_ver2_sec_index; if (tmp_cck_max_pwdb != -64) @@ -2567,7 +2567,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x1< Date: Fri, 3 Aug 2018 01:01:58 +0100 Subject: [PATCH 824/903] staging:rtl8192u: Remove unused extern DM_RxPathSelTable - Style The file r8192U_dm.h defines the structure DM_RxPathSelTable as being external. The structure is however declared in r8192U_dm.c and only used locally in that file. As a result the external definition has been removed and the declaration in r8192U_dm.c changed to being of type static. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 2 +- drivers/staging/rtl8192u/r8192U_dm.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 86f443ad75f5..54390587ba07 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -41,7 +41,7 @@ struct dig dm_digtable; /* Store current software write register content for MAC PHY. */ u8 dm_shadow[16][256] = { {0} }; /* For Dynamic Rx Path Selection by Signal Strength */ -struct dynamic_rx_path_sel DM_RxPathSelTable; +static struct dynamic_rx_path_sel DM_RxPathSelTable; /*------------------------Define global variable-----------------------------*/ diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index d51c20eafef4..06ebd820de52 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -154,7 +154,6 @@ typedef struct tag_Tx_Config_Cmd_Format { /*------------------------Export global variable----------------------------*/ extern struct dig dm_digtable; extern u8 dm_shadow[16][256]; -extern struct dynamic_rx_path_sel DM_RxPathSelTable; /*------------------------Export global variable----------------------------*/ From 863108d5a06bb896c8a9912fc669ec13176b306d Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:01:59 +0100 Subject: [PATCH 825/903] staging:rtl8192u: Remove member variable Enable - Style The structure dynamic_rx_path_sel defines a member variable 'Enable' which is initialised and later tested. The variable is however never changed to the test is redundant and the member variable is then never used. The member variable, initialisation and test have all been removed. This is a coding style change which should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 3 --- drivers/staging/rtl8192u/r8192U_dm.h | 1 - 2 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 54390587ba07..611bf3e34bf3 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2376,8 +2376,6 @@ void dm_rf_pathcheck_workitemcallback(struct work_struct *work) else priv->brfpath_rxenable[i] = false; } - if (!DM_RxPathSelTable.Enable) - return; dm_rxpath_sel_byrssi(dev); } /* DM_RFPathCheckWorkItemCallBack */ @@ -2387,7 +2385,6 @@ static void dm_init_rxpath_selection(struct net_device *dev) u8 i; struct r8192_priv *priv = ieee80211_priv(dev); - DM_RxPathSelTable.Enable = 1; /* default enabled */ DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; if (priv->CustomerID == RT_CID_819x_Netcore) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 06ebd820de52..53daec820ca7 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -129,7 +129,6 @@ enum cck_rx_path_method { }; struct dynamic_rx_path_sel { - u8 Enable; enum cck_rx_path_method cck_method; u8 cck_Rx_path; From f19a08e76d09bd12b15faedf1eeacd33c7862dbd Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:00 +0100 Subject: [PATCH 826/903] staging:rtl8192u: Rename cck_Rx_path - Style Rename the member variable cck_Rx_path to cck_rx_path. This clears the checkpatch issue with CamelCase naming. This is a coding style change which should have no impact one runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 8 ++++---- drivers/staging/rtl8192u/r8192U_dm.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 611bf3e34bf3..495f563879c8 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2417,8 +2417,8 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) return; if (!cck_Rx_Path_initialized) { - read_nic_byte(dev, 0xa07, &DM_RxPathSelTable.cck_Rx_path); - DM_RxPathSelTable.cck_Rx_path &= 0xf; + read_nic_byte(dev, 0xa07, &DM_RxPathSelTable.cck_rx_path); + DM_RxPathSelTable.cck_rx_path &= 0xf; cck_Rx_Path_initialized = 1; } @@ -2573,8 +2573,8 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) } if (update_cck_rx_path) { - DM_RxPathSelTable.cck_Rx_path = (cck_default_Rx<<2)|(cck_optional_Rx); - rtl8192_setBBreg(dev, rCCK0_AFESetting, 0x0f000000, DM_RxPathSelTable.cck_Rx_path); + DM_RxPathSelTable.cck_rx_path = (cck_default_Rx<<2)|(cck_optional_Rx); + rtl8192_setBBreg(dev, rCCK0_AFESetting, 0x0f000000, DM_RxPathSelTable.cck_rx_path); } if (DM_RxPathSelTable.disabledRF) { diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 53daec820ca7..b1f19bad2c30 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -130,7 +130,7 @@ enum cck_rx_path_method { struct dynamic_rx_path_sel { enum cck_rx_path_method cck_method; - u8 cck_Rx_path; + u8 cck_rx_path; u8 SS_TH_low; u8 diff_TH; From f793836c16a56596d4501f87fec85b7dc6366fb5 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:01 +0100 Subject: [PATCH 827/903] staging:rtl8192u: Remove SS_TH_low - Style The member variable SS_TH_low is assigned a constant and then used in a comparison. This member variable is redundant as the constant can be used directly for the comparison. In addition the constant RxPathSelection_SS_TH_low has been renamed to RX_PATH_SELECTION_SS_TH_LOW, to clear the checkpatch issue with CamelCase naming. These changes are coding style in nature and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 3 +-- drivers/staging/rtl8192u/r8192U_dm.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 495f563879c8..f01d2f8d7fd2 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2385,7 +2385,6 @@ static void dm_init_rxpath_selection(struct net_device *dev) u8 i; struct r8192_priv *priv = ieee80211_priv(dev); - DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; if (priv->CustomerID == RT_CID_819x_Netcore) DM_RxPathSelTable.cck_method = CCK_RX_VERSION_2; @@ -2555,7 +2554,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) update_cck_rx_path = 1; } - if (tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2) { + if (tmp_min_rssi < RX_PATH_SELECTION_SS_TH_LOW && disabled_rf_cnt < 2) { if ((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH) { /* record the enabled rssi threshold */ DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index b1f19bad2c30..0aaac0fca110 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -37,7 +37,7 @@ #define DM_DIG_MIN 0x1c #define DM_DIG_MIN_Netcore 0x12 -#define RxPathSelection_SS_TH_low 30 +#define RX_PATH_SELECTION_SS_TH_LOW 30 #define RxPathSelection_diff_TH 18 #define RateAdaptiveTH_High 50 @@ -132,7 +132,6 @@ struct dynamic_rx_path_sel { enum cck_rx_path_method cck_method; u8 cck_rx_path; - u8 SS_TH_low; u8 diff_TH; u8 disabledRF; u8 reserved; From 2a2271e4ac8792e54989fe2109a63bf34914d0f3 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:02 +0100 Subject: [PATCH 828/903] staging:rtl8192u: Remove member diff_TH - Style The member variable diff_TH is assigned a constant value and then used in a comparison. The variable is never changed so the comparison can as easily be performed directly with the defined constant. The member variable has been removed and the defined constant RxPathSelection_diff_TH renamed to RX_PATH_SELECTION_DIFF_TH, to clear the checkpatch issue with CamelCase naming. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 3 +-- drivers/staging/rtl8192u/r8192U_dm.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index f01d2f8d7fd2..d847adf57f60 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2385,7 +2385,6 @@ static void dm_init_rxpath_selection(struct net_device *dev) u8 i; struct r8192_priv *priv = ieee80211_priv(dev); - DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; if (priv->CustomerID == RT_CID_819x_Netcore) DM_RxPathSelTable.cck_method = CCK_RX_VERSION_2; else @@ -2555,7 +2554,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) } if (tmp_min_rssi < RX_PATH_SELECTION_SS_TH_LOW && disabled_rf_cnt < 2) { - if ((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH) { + if ((tmp_max_rssi - tmp_min_rssi) >= RX_PATH_SELECTION_DIFF_TH) { /* record the enabled rssi threshold */ DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; /* disable the BB Rx path, OFDM */ diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 0aaac0fca110..a7cce1fdd626 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -38,7 +38,7 @@ #define DM_DIG_MIN_Netcore 0x12 #define RX_PATH_SELECTION_SS_TH_LOW 30 -#define RxPathSelection_diff_TH 18 +#define RX_PATH_SELECTION_DIFF_TH 18 #define RateAdaptiveTH_High 50 #define RateAdaptiveTH_Low_20M 30 @@ -132,7 +132,6 @@ struct dynamic_rx_path_sel { enum cck_rx_path_method cck_method; u8 cck_rx_path; - u8 diff_TH; u8 disabledRF; u8 reserved; From 68d84843665cc9d53e08f90537d7be267da7b442 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:03 +0100 Subject: [PATCH 829/903] staging:rtl8192u: Rename member disabledRF - Style Rename the member variable disabledRF to disabled_rf. This change resolves the checkpatch issue with CamelCase naming. The change is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 10 +++++----- drivers/staging/rtl8192u/r8192U_dm.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index d847adf57f60..6f17732d038d 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2389,7 +2389,7 @@ static void dm_init_rxpath_selection(struct net_device *dev) DM_RxPathSelTable.cck_method = CCK_RX_VERSION_2; else DM_RxPathSelTable.cck_method = CCK_RX_VERSION_1; - DM_RxPathSelTable.disabledRF = 0; + DM_RxPathSelTable.disabled_rf = 0; for (i = 0; i < 4; i++) { DM_RxPathSelTable.rf_rssi[i] = 50; DM_RxPathSelTable.cck_pwdb_sta[i] = -64; @@ -2420,8 +2420,8 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) cck_Rx_Path_initialized = 1; } - read_nic_byte(dev, 0xc04, &DM_RxPathSelTable.disabledRF); - DM_RxPathSelTable.disabledRF = ~DM_RxPathSelTable.disabledRF & 0xf; + read_nic_byte(dev, 0xc04, &DM_RxPathSelTable.disabled_rf); + DM_RxPathSelTable.disabled_rf = ~DM_RxPathSelTable.disabled_rf & 0xf; if (priv->ieee80211->mode == WIRELESS_MODE_B) { DM_RxPathSelTable.cck_method = CCK_RX_VERSION_2; /* pure B mode, fixed cck version2 */ @@ -2575,9 +2575,9 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) rtl8192_setBBreg(dev, rCCK0_AFESetting, 0x0f000000, DM_RxPathSelTable.cck_rx_path); } - if (DM_RxPathSelTable.disabledRF) { + if (DM_RxPathSelTable.disabled_rf) { for (i = 0; i < 4; i++) { - if ((DM_RxPathSelTable.disabledRF>>i) & 0x1) { /* disabled rf */ + if ((DM_RxPathSelTable.disabled_rf >> i) & 0x1) { /* disabled rf */ if (tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i]) { /* enable the BB Rx path */ /*DbgPrint("RF-%d is enabled.\n", 0x1< Date: Fri, 3 Aug 2018 01:02:04 +0100 Subject: [PATCH 830/903] staging:rtl8192u: Remove member reserved - Style The structure dynamic_rx_path_sel contains a u8 member variable called reserved. This member variable is never actually used in the code. The naming suggests that the sizeof the structure is significant but the only use of the structure is a local static in r8192U_dm.c: static struct dynamic_rx_path_sel DM_RxPathSelTable; There is no apparent significance to the sizeof the declared structure DM_RxPathSelTable. As a result the reserved member variable has been removed from the structure. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 74742cb27a2c..66dfcbbf6e43 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -133,7 +133,6 @@ struct dynamic_rx_path_sel { u8 cck_rx_path; u8 disabled_rf; - u8 reserved; u8 rf_rssi[4]; u8 rf_enable_rssi_th[4]; From d3c90eff9c4ed66a9f16db2ef99b75455a850e7b Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:05 +0100 Subject: [PATCH 831/903] staging:rtl8192u: Refactor DCMD_TXCMD_T structure - Style The structure DCMD_TXCMD_T is declared with a typedef, which causes a checkpatch issue with defining new types. As a result the typedef has been removed. The structure's name DCMD_TXCMD_T, as a type, is meant to be lowercase so has been renamed to tx_config_cmd. The structures three members, (Op, Length, and Value) are all violating the coding standard policy on CamelCase naming, so have all been renamed. They have been renamed with longer names, (cmd_op, cmd_length and cmd_value), to make the variable names easier to search for in code. The magic numbers '4' and '12' have both been replaced with sizeof() calls, as they both represent the size of data elements. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 10 +++++----- drivers/staging/rtl8192u/r8192U_dm.h | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 6f17732d038d..4c8f674cf54d 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -510,7 +510,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); bool viviflag = false; - DCMD_TXCMD_T tx_cmd; + struct tx_config_cmd tx_cmd; u8 powerlevelOFDM24G; int i = 0, j = 0, k = 0; u8 RF_Type, tmp_report[5] = {0, 0, 0, 0, 0}; @@ -532,10 +532,10 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G); for (j = 0; j <= 30; j++) { /* fill tx_cmd */ - tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; - tx_cmd.Length = 4; - tx_cmd.Value = Value; - rtStatus = SendTxCommandPacket(dev, &tx_cmd, 12); + tx_cmd.cmd_op = TXCMD_SET_TX_PWR_TRACKING; + tx_cmd.cmd_length = sizeof(tx_cmd.cmd_op); + tx_cmd.cmd_value = Value; + rtStatus = SendTxCommandPacket(dev, &tx_cmd, sizeof(struct tx_config_cmd)); if (rtStatus == RT_STATUS_FAILURE) RT_TRACE(COMP_POWER_TRACKING, "Set configuration with tx cmd queue fail!\n"); usleep_range(1000, 2000); diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 66dfcbbf6e43..9a0105412350 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -139,11 +139,12 @@ struct dynamic_rx_path_sel { long cck_pwdb_sta[4]; }; -typedef struct tag_Tx_Config_Cmd_Format { - u32 Op; /* Command packet type. */ - u32 Length; /* Command packet length. */ - u32 Value; -} DCMD_TXCMD_T, *PDCMD_TXCMD_T; +struct tx_config_cmd { + u32 cmd_op; /* Command packet type. */ + u32 cmd_length; /* Command packet length. */ + u32 cmd_value; +}; + /*------------------------------Define structure----------------------------*/ From a7a014961548ba7f33788fad9d54c65c9d970c24 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:06 +0100 Subject: [PATCH 832/903] staging:rtl8192u: Rename DM_DIG_MIN_Netcore - Style The constant DM_DIG_MIN_Netcore causes a checkpatch issue with CamelCase naming so has been renamed to DM_DIG_MIN_NETCORE. This is a simple coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 2 +- drivers/staging/rtl8192u/r8192U_dm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 4c8f674cf54d..3043b84e9237 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1650,7 +1650,7 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.rssi_val = 50; /* for new dig debug rssi value */ dm_digtable.backoff_val = DM_DIG_BACKOFF; if (priv->CustomerID == RT_CID_819x_Netcore) - dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore; + dm_digtable.rx_gain_range_min = DM_DIG_MIN_NETCORE; else dm_digtable.rx_gain_range_min = DM_DIG_MIN; diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 9a0105412350..655b1afd9294 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -35,7 +35,7 @@ #define DM_DIG_BACKOFF 12 #define DM_DIG_MAX 0x36 #define DM_DIG_MIN 0x1c -#define DM_DIG_MIN_Netcore 0x12 +#define DM_DIG_MIN_NETCORE 0x12 #define RX_PATH_SELECTION_SS_TH_LOW 30 #define RX_PATH_SELECTION_DIFF_TH 18 From 0395a9aad5832a218322cd610afc511b6244decb Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:07 +0100 Subject: [PATCH 833/903] staging:rtl8192u: Rename RateAdaptiveTH_High - Style The constant RateAdaptiveTH_High causes a checkpatch issue with respect to CamelCase naming. As a result the constant has been renamed to RATE_ADAPTIVE_TH_HIGH. This is purely a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 4 ++-- drivers/staging/rtl8192u/r8192U_dm.c | 4 ++-- drivers/staging/rtl8192u/r8192U_dm.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 28592a8d6dd0..d4a063afca55 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3079,9 +3079,9 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev) * or maybe it will continuous silent reset every 2 seconds. */ rx_chk_cnt++; - if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High + 5)) { + if (priv->undecorated_smoothed_pwdb >= (RATE_ADAPTIVE_TH_HIGH + 5)) { rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ - } else if (priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5) && + } else if (priv->undecorated_smoothed_pwdb < (RATE_ADAPTIVE_TH_HIGH + 5) && ((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M) || (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M))) { if (rx_chk_cnt < 2) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 3043b84e9237..b9b751fb96c3 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -243,11 +243,11 @@ void init_rate_adaptive(struct net_device *dev) prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive; pra->ratr_state = DM_RATR_STA_MAX; - pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; + pra->high2low_rssi_thresh_for_ra = RATE_ADAPTIVE_TH_HIGH; pra->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5; pra->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5; - pra->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5; + pra->high_rssi_thresh_for_ra = RATE_ADAPTIVE_TH_HIGH + 5; pra->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M; pra->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M; diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 655b1afd9294..07e80e064f76 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -40,7 +40,7 @@ #define RX_PATH_SELECTION_SS_TH_LOW 30 #define RX_PATH_SELECTION_DIFF_TH 18 -#define RateAdaptiveTH_High 50 +#define RATE_ADAPTIVE_TH_HIGH 50 #define RateAdaptiveTH_Low_20M 30 #define RateAdaptiveTH_Low_40M 10 #define VeryLowRSSI 15 From c972be9a7525db60dbc500658ef4d532c70eb3d7 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:08 +0100 Subject: [PATCH 834/903] staging:rtl8192u: Rename constants RateAdaptiveTH_Low_* - Style The two constants, RateAdaptiveTH_Low_20M and RateAdaptiveTH_Low_40M generate a checkpatch warning about CamelCase naming. The two have been renamed to clear this issue. RATE_ADAPTIVE_TH_LOW_20M and RATE_ADAPTIVE_TH_LOW_40M This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 8 ++++---- drivers/staging/rtl8192u/r8192U_dm.c | 8 ++++---- drivers/staging/rtl8192u/r8192U_dm.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index d4a063afca55..6129ac55656f 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3082,14 +3082,14 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev) if (priv->undecorated_smoothed_pwdb >= (RATE_ADAPTIVE_TH_HIGH + 5)) { rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ } else if (priv->undecorated_smoothed_pwdb < (RATE_ADAPTIVE_TH_HIGH + 5) && - ((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M) || - (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M))) { + ((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RATE_ADAPTIVE_TH_LOW_40M) || + (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RATE_ADAPTIVE_TH_LOW_20M))) { if (rx_chk_cnt < 2) return bStuck; rx_chk_cnt = 0; - } else if (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M) || - (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M)) && + } else if (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RATE_ADAPTIVE_TH_LOW_40M) || + (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RATE_ADAPTIVE_TH_LOW_20M)) && priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { if (rx_chk_cnt < 4) return bStuck; diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index b9b751fb96c3..21107a00776f 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -244,12 +244,12 @@ void init_rate_adaptive(struct net_device *dev) pra->ratr_state = DM_RATR_STA_MAX; pra->high2low_rssi_thresh_for_ra = RATE_ADAPTIVE_TH_HIGH; - pra->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5; - pra->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5; + pra->low2high_rssi_thresh_for_ra20M = RATE_ADAPTIVE_TH_LOW_20M + 5; + pra->low2high_rssi_thresh_for_ra40M = RATE_ADAPTIVE_TH_LOW_40M + 5; pra->high_rssi_thresh_for_ra = RATE_ADAPTIVE_TH_HIGH + 5; - pra->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M; - pra->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M; + pra->low_rssi_thresh_for_ra20M = RATE_ADAPTIVE_TH_LOW_20M; + pra->low_rssi_thresh_for_ra40M = RATE_ADAPTIVE_TH_LOW_40M; if (priv->CustomerID == RT_CID_819x_Netcore) pra->ping_rssi_enable = 1; diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 07e80e064f76..a1378488423b 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -41,8 +41,8 @@ #define RX_PATH_SELECTION_DIFF_TH 18 #define RATE_ADAPTIVE_TH_HIGH 50 -#define RateAdaptiveTH_Low_20M 30 -#define RateAdaptiveTH_Low_40M 10 +#define RATE_ADAPTIVE_TH_LOW_20M 30 +#define RATE_ADAPTIVE_TH_LOW_40M 10 #define VeryLowRSSI 15 #define CTSToSelfTHVal 30 From 070c1ce978916b4434b63cb7bb881aaeaa58f2ef Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:09 +0100 Subject: [PATCH 835/903] staging:rtl8192u: Rename constants - Style The constants 'VeryLowRSSI' and 'CTSToSelfTHVal' generate warnings from checkpatch due to the use of CamelCase naming. The two constants have been renamed to 'VERY_LOW_RSSI' and 'CTS_TO_SELF_TH_VAL' respectively. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 2 +- drivers/staging/rtl8192u/r8192U_dm.c | 2 +- drivers/staging/rtl8192u/r8192U_dm.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 6129ac55656f..e218b5c20642 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3090,7 +3090,7 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev) rx_chk_cnt = 0; } else if (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RATE_ADAPTIVE_TH_LOW_40M) || (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RATE_ADAPTIVE_TH_LOW_20M)) && - priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { + priv->undecorated_smoothed_pwdb >= VERY_LOW_RSSI) { if (rx_chk_cnt < 4) return bStuck; diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 21107a00776f..0e4f55c6493f 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2268,7 +2268,7 @@ static void dm_init_ctstoself(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); priv->ieee80211->bCTSToSelfEnable = true; - priv->ieee80211->CTSToSelfTH = CTSToSelfTHVal; + priv->ieee80211->CTSToSelfTH = CTS_TO_SELF_TH_VAL; } static void dm_ctstoself(struct net_device *dev) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index a1378488423b..30241d91e44a 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -43,8 +43,8 @@ #define RATE_ADAPTIVE_TH_HIGH 50 #define RATE_ADAPTIVE_TH_LOW_20M 30 #define RATE_ADAPTIVE_TH_LOW_40M 10 -#define VeryLowRSSI 15 -#define CTSToSelfTHVal 30 +#define VERY_LOW_RSSI 15 +#define CTS_TO_SELF_TH_VAL 30 /* defined by vivi, for tx power track */ #define E_FOR_TX_POWER_TRACK 300 From 1bb6d9b95025c2f86d237fc3504b0dd837a3b0f8 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:10 +0100 Subject: [PATCH 836/903] staging:rtl8192u: Rename Register Constants - Style The four register constants, 'Current_Tx_Rate_Reg', 'Initial_Tx_Rate_Reg', 'Tx_Retry_Count_Reg' and 'RegC38_TH' all cause checkpatch issue with CamelCase naming. The three have been renamed to 'CURRENT_TX_RATE_REG', 'INITIAL_TX_RATE_REG', 'TX_RETRY_COUNT_REG' and 'REG_C38_TH' respectively. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 16 ++++++++-------- drivers/staging/rtl8192u/r8192U_dm.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 0e4f55c6493f..5fb5f583f703 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2875,13 +2875,13 @@ void dm_check_fsync(struct net_device *dev) if (priv->framesyncMonitor) { if (priv->ieee80211->state == IEEE80211_LINKED) { - if (priv->undecorated_smoothed_pwdb <= RegC38_TH) { + if (priv->undecorated_smoothed_pwdb <= REG_C38_TH) { if (reg_c38_State != RegC38_NonFsync_Other_AP) { write_nic_byte(dev, rOFDM0_RxDetector3, 0x90); reg_c38_State = RegC38_NonFsync_Other_AP; } - } else if (priv->undecorated_smoothed_pwdb >= (RegC38_TH+5)) { + } else if (priv->undecorated_smoothed_pwdb >= (REG_C38_TH + 5)) { if (reg_c38_State) { write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); reg_c38_State = RegC38_Default; @@ -3046,15 +3046,15 @@ static void dm_check_txrateandretrycount(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; /* for 11n tx rate */ - /*priv->stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);*/ - read_nic_byte(dev, Current_Tx_Rate_Reg, &ieee->softmac_stats.CurrentShowTxate); + /*priv->stats.CurrentShowTxate = read_nic_byte(dev, CURRENT_TX_RATE_REG);*/ + read_nic_byte(dev, CURRENT_TX_RATE_REG, &ieee->softmac_stats.CurrentShowTxate); /*printk("=============>tx_rate_reg:%x\n", ieee->softmac_stats.CurrentShowTxate);*/ /* for initial tx rate */ - /*priv->stats.last_packet_rate = read_nic_byte(dev, Initial_Tx_Rate_Reg);*/ - read_nic_byte(dev, Initial_Tx_Rate_Reg, &ieee->softmac_stats.last_packet_rate); + /*priv->stats.last_packet_rate = read_nic_byte(dev, INITIAL_TX_RATE_REG);*/ + read_nic_byte(dev, INITIAL_TX_RATE_REG, &ieee->softmac_stats.last_packet_rate); /* for tx tx retry count */ - /*priv->stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);*/ - read_nic_dword(dev, Tx_Retry_Count_Reg, &ieee->softmac_stats.txretrycount); + /*priv->stats.txretrycount = read_nic_dword(dev, TX_RETRY_COUNT_REG);*/ + read_nic_dword(dev, TX_RETRY_COUNT_REG, &ieee->softmac_stats.txretrycount); } static void dm_send_rssi_tofw(struct net_device *dev) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 30241d91e44a..d93817f2a45b 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -56,10 +56,10 @@ #define TX_POWER_ATHEROAP_THRESH_LOW 72 /* defined by vivi, for showing on UI */ -#define Current_Tx_Rate_Reg 0x1b8 -#define Initial_Tx_Rate_Reg 0x1b9 -#define Tx_Retry_Count_Reg 0x1ac -#define RegC38_TH 20 +#define CURRENT_TX_RATE_REG 0x1b8 +#define INITIAL_TX_RATE_REG 0x1b9 +#define TX_RETRY_COUNT_REG 0x1ac +#define REG_C38_TH 20 /*--------------------------Define Parameters-------------------------------*/ From 0f79619d70bb1c1fa85f1a2b7dc54080b11532cb Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Fri, 3 Aug 2018 01:02:11 +0100 Subject: [PATCH 837/903] staging:rtl8192u: Clean up of spacing - Style Multiple blank line, which cause an issue with checkpath, have been removed and the spacing of definitions have been aligned to look cleaner. These are coding style changes which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.h | 123 +++++++++++++-------------- 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index d93817f2a45b..0de0332906bd 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -21,48 +21,46 @@ #ifndef __R8192UDM_H__ #define __R8192UDM_H__ - /*--------------------------Define Parameters-------------------------------*/ -#define DM_DIG_THRESH_HIGH 40 -#define DM_DIG_THRESH_LOW 35 +#define DM_DIG_THRESH_HIGH 40 +#define DM_DIG_THRESH_LOW 35 -#define DM_DIG_HIGH_PWR_THRESH_HIGH 75 -#define DM_DIG_HIGH_PWR_THRESH_LOW 70 +#define DM_DIG_HIGH_PWR_THRESH_HIGH 75 +#define DM_DIG_HIGH_PWR_THRESH_LOW 70 -#define BW_AUTO_SWITCH_HIGH_LOW 25 -#define BW_AUTO_SWITCH_LOW_HIGH 30 +#define BW_AUTO_SWITCH_HIGH_LOW 25 +#define BW_AUTO_SWITCH_LOW_HIGH 30 -#define DM_DIG_BACKOFF 12 -#define DM_DIG_MAX 0x36 -#define DM_DIG_MIN 0x1c -#define DM_DIG_MIN_NETCORE 0x12 +#define DM_DIG_BACKOFF 12 +#define DM_DIG_MAX 0x36 +#define DM_DIG_MIN 0x1c +#define DM_DIG_MIN_NETCORE 0x12 -#define RX_PATH_SELECTION_SS_TH_LOW 30 -#define RX_PATH_SELECTION_DIFF_TH 18 +#define RX_PATH_SELECTION_SS_TH_LOW 30 +#define RX_PATH_SELECTION_DIFF_TH 18 -#define RATE_ADAPTIVE_TH_HIGH 50 -#define RATE_ADAPTIVE_TH_LOW_20M 30 -#define RATE_ADAPTIVE_TH_LOW_40M 10 -#define VERY_LOW_RSSI 15 -#define CTS_TO_SELF_TH_VAL 30 +#define RATE_ADAPTIVE_TH_HIGH 50 +#define RATE_ADAPTIVE_TH_LOW_20M 30 +#define RATE_ADAPTIVE_TH_LOW_40M 10 +#define VERY_LOW_RSSI 15 +#define CTS_TO_SELF_TH_VAL 30 /* defined by vivi, for tx power track */ -#define E_FOR_TX_POWER_TRACK 300 +#define E_FOR_TX_POWER_TRACK 300 /* Dynamic Tx Power Control Threshold */ -#define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 -#define TX_POWER_NEAR_FIELD_THRESH_LOW 62 +#define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 +#define TX_POWER_NEAR_FIELD_THRESH_LOW 62 /* added by amy for atheros AP */ #define TX_POWER_ATHEROAP_THRESH_HIGH 78 -#define TX_POWER_ATHEROAP_THRESH_LOW 72 +#define TX_POWER_ATHEROAP_THRESH_LOW 72 /* defined by vivi, for showing on UI */ -#define CURRENT_TX_RATE_REG 0x1b8 -#define INITIAL_TX_RATE_REG 0x1b9 -#define TX_RETRY_COUNT_REG 0x1ac -#define REG_C38_TH 20 +#define CURRENT_TX_RATE_REG 0x1b8 +#define INITIAL_TX_RATE_REG 0x1b9 +#define TX_RETRY_COUNT_REG 0x1ac +#define REG_C38_TH 20 /*--------------------------Define Parameters-------------------------------*/ - /*------------------------------Define structure----------------------------*/ enum dig_algorithm { @@ -78,49 +76,49 @@ enum dynamic_init_gain_state { enum dig_connect { DIG_DISCONNECT = 0, - DIG_CONNECT = 1, + DIG_CONNECT = 1, }; enum dig_pkt_detection_threshold { - DIG_PD_AT_LOW_POWER = 0, + DIG_PD_AT_LOW_POWER = 0, DIG_PD_AT_NORMAL_POWER = 1, - DIG_PD_AT_HIGH_POWER = 2, + DIG_PD_AT_HIGH_POWER = 2, }; enum dig_cck_cs_ratio_state { - DIG_CS_RATIO_LOWER = 0, + DIG_CS_RATIO_LOWER = 0, DIG_CS_RATIO_HIGHER = 1, }; /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ struct dig { - u8 dig_enable_flag; - enum dig_algorithm dig_algorithm; - u8 dig_algorithm_switch; + u8 dig_enable_flag; + enum dig_algorithm dig_algorithm; + u8 dig_algorithm_switch; - long rssi_low_thresh; - long rssi_high_thresh; + long rssi_low_thresh; + long rssi_high_thresh; - long rssi_high_power_lowthresh; - long rssi_high_power_highthresh; + long rssi_high_power_lowthresh; + long rssi_high_power_highthresh; - enum dynamic_init_gain_state dig_state; - enum dynamic_init_gain_state dig_highpwr_state; - enum dig_connect cur_connect_state; - enum dig_connect pre_connect_state; + enum dynamic_init_gain_state dig_state; + enum dynamic_init_gain_state dig_highpwr_state; + enum dig_connect cur_connect_state; + enum dig_connect pre_connect_state; - enum dig_pkt_detection_threshold curpd_thstate; - enum dig_pkt_detection_threshold prepd_thstate; - enum dig_cck_cs_ratio_state curcs_ratio_state; - enum dig_cck_cs_ratio_state precs_ratio_state; + enum dig_pkt_detection_threshold curpd_thstate; + enum dig_pkt_detection_threshold prepd_thstate; + enum dig_cck_cs_ratio_state curcs_ratio_state; + enum dig_cck_cs_ratio_state precs_ratio_state; - u32 pre_ig_value; - u32 cur_ig_value; + u32 pre_ig_value; + u32 cur_ig_value; - u8 backoff_val; - u8 rx_gain_range_min; + u8 backoff_val; + u8 rx_gain_range_min; - long rssi_val; + long rssi_val; }; enum cck_rx_path_method { @@ -129,36 +127,33 @@ enum cck_rx_path_method { }; struct dynamic_rx_path_sel { - enum cck_rx_path_method cck_method; - u8 cck_rx_path; + enum cck_rx_path_method cck_method; + u8 cck_rx_path; - u8 disabled_rf; + u8 disabled_rf; - u8 rf_rssi[4]; - u8 rf_enable_rssi_th[4]; - long cck_pwdb_sta[4]; + u8 rf_rssi[4]; + u8 rf_enable_rssi_th[4]; + long cck_pwdb_sta[4]; }; struct tx_config_cmd { - u32 cmd_op; /* Command packet type. */ - u32 cmd_length; /* Command packet length. */ - u32 cmd_value; + u32 cmd_op; /* Command packet type. */ + u32 cmd_length; /* Command packet length. */ + u32 cmd_value; }; /*------------------------------Define structure----------------------------*/ - /*------------------------Export global variable----------------------------*/ extern struct dig dm_digtable; extern u8 dm_shadow[16][256]; /*------------------------Export global variable----------------------------*/ - /*------------------------Export Marco Definition---------------------------*/ /*------------------------Export Marco Definition---------------------------*/ - /*--------------------------Exported Function prototype---------------------*/ void init_hal_dm(struct net_device *dev); void deinit_hal_dm(struct net_device *dev); @@ -178,8 +173,6 @@ void dm_shadow_init(struct net_device *dev); void dm_initialize_txpower_tracking(struct net_device *dev); /*--------------------------Exported Function prototype---------------------*/ - #endif /*__R8192UDM_H__ */ - /* End of r8192U_dm.h */ From f1c3b4880bdf4f64c3bfb6d122e33b54b17231cd Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 4 Aug 2018 10:18:53 +0100 Subject: [PATCH 838/903] staging:rtl8192u: Remove typedef and rename QOS_TCLAS - Style Remove the typedef from the union QOS_TCLAS, which causes a checkpatch issue with defining new types. In addition, as a type, the name should be in lowercase so has been changed. These are coding style changes and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 6 +++--- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 5cf00a2e08ae..823ba363e0ab 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -14,7 +14,7 @@ enum tr_select { RX_DIR = 1, }; -typedef union _QOS_TCLAS { +union qos_tclas { struct _TYPE_GENERAL { u8 Priority; @@ -63,7 +63,7 @@ typedef union _QOS_TCLAS { u8 Mask; u16 TagType; } TYPE2_8021Q; -} QOS_TCLAS, *PQOS_TCLAS; +}; struct ts_common_info { struct list_head list; @@ -71,7 +71,7 @@ struct ts_common_info { struct timer_list inact_timer; u8 addr[6]; struct tspec_body t_spec; - QOS_TCLAS t_class[TCLAS_NUM]; + union qos_tclas t_class[TCLAS_NUM]; u8 t_clas_proc; u8 t_clas_num; }; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index de06cd11ab65..d46d8f468671 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -105,7 +105,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { eth_zero_addr(pTsCommonInfo->addr); memset(&pTsCommonInfo->t_spec, 0, sizeof(struct tspec_body)); - memset(&pTsCommonInfo->t_class, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); + memset(&pTsCommonInfo->t_class, 0, sizeof(union qos_tclas)*TCLAS_NUM); pTsCommonInfo->t_clas_proc = 0; pTsCommonInfo->t_clas_num = 0; } @@ -265,7 +265,7 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee, } static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, - struct tspec_body *pTSPEC, PQOS_TCLAS pTCLAS, u8 TCLAS_Num, + struct tspec_body *pTSPEC, union qos_tclas *pTCLAS, u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -279,7 +279,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, memcpy((u8 *)(&(pTsCommonInfo->t_spec)), (u8 *)pTSPEC, sizeof(struct tspec_body)); for(count = 0; count < TCLAS_Num; count++) - memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS)); + memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(union qos_tclas)); pTsCommonInfo->t_clas_proc = TCLAS_Proc; pTsCommonInfo->t_clas_num = TCLAS_Num; From e8ac237d4854072c34fc069c8e59b586e31e945c Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 4 Aug 2018 10:18:54 +0100 Subject: [PATCH 839/903] staging:rtl8192u: Rename types in QOS_TCLAS union - Style Whilst none of the structures inside the qos_tclas union are used, their names conflict with the coding standard being named in uppercase. The names of all five have been changed to lowercase. This is a style change, and since none of the structures are referenced, these changes should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 823ba363e0ab..c352ba0bcd8f 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -16,22 +16,22 @@ enum tr_select { union qos_tclas { - struct _TYPE_GENERAL { + struct type_general { u8 Priority; u8 ClassifierType; u8 Mask; - } TYPE_GENERAL; + } type_general; - struct _TYPE0_ETH { + struct type0_eth { u8 Priority; u8 ClassifierType; u8 Mask; u8 SrcAddr[6]; u8 DstAddr[6]; u16 Type; - } TYPE0_ETH; + } type0_eth; - struct _TYPE1_IPV4 { + struct type1_ipv4 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -43,9 +43,9 @@ union qos_tclas { u8 DSCP; u8 Protocol; u8 Reserved; - } TYPE1_IPV4; + } type1_ipv4; - struct _TYPE1_IPV6 { + struct type1_ipv6 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -55,14 +55,14 @@ union qos_tclas { u16 SrcPort; u16 DstPort; u8 FlowLabel[3]; - } TYPE1_IPV6; + } type1_ipv6; - struct _TYPE2_8021Q { + struct type2_8021q { u8 Priority; u8 ClassifierType; u8 Mask; u16 TagType; - } TYPE2_8021Q; + } type2_8021q; }; struct ts_common_info { From 51606f72a837d3886dab8a77efe1f6d4b291116c Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 4 Aug 2018 10:18:55 +0100 Subject: [PATCH 840/903] staging:rtl8192u: Rename multiple variables - Style All of the variables used within the structures of the union qos_tclas cause checkpatch issue due to CamelCase naming. As none the member variables are used in code all have been changed on one patch. These changes are coding style in nature and should not impact runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/rtl819x_TS.h | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index c352ba0bcd8f..508ed639cda5 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -17,51 +17,51 @@ enum tr_select { union qos_tclas { struct type_general { - u8 Priority; - u8 ClassifierType; - u8 Mask; + u8 priority; + u8 classifier_type; + u8 mask; } type_general; struct type0_eth { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 SrcAddr[6]; - u8 DstAddr[6]; - u16 Type; + u8 priority; + u8 classifier_type; + u8 mask; + u8 src_addr[6]; + u8 dst_addr[6]; + u16 type; } type0_eth; struct type1_ipv4 { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; - u8 SrcIP[4]; - u8 DstIP[4]; - u16 SrcPort; - u16 DstPort; - u8 DSCP; - u8 Protocol; - u8 Reserved; + u8 priority; + u8 classifier_type; + u8 mask; + u8 version; + u8 src_ip[4]; + u8 dst_ip[4]; + u16 src_port; + u16 dst_port; + u8 dscp; + u8 protocol; + u8 reserved; } type1_ipv4; struct type1_ipv6 { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; - u8 SrcIP[16]; - u8 DstIP[16]; - u16 SrcPort; - u16 DstPort; - u8 FlowLabel[3]; + u8 priority; + u8 classifier_type; + u8 mask; + u8 version; + u8 src_ip[16]; + u8 dst_ip[16]; + u16 src_port; + u16 dst_port; + u8 flow_label[3]; } type1_ipv6; struct type2_8021q { - u8 Priority; - u8 ClassifierType; - u8 Mask; - u16 TagType; + u8 priority; + u8 classifier_type; + u8 mask; + u16 tag_type; } type2_8021q; }; From 4651fb4c4098ce9093db3f6ebcf9373267329436 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 4 Aug 2018 10:18:56 +0100 Subject: [PATCH 841/903] staging:rtl8192u: Remove blank line - Style Removal of a blank like which causes a checkpatch issue. This is a simple coding style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 508ed639cda5..93984e8e87c3 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -15,7 +15,6 @@ enum tr_select { }; union qos_tclas { - struct type_general { u8 priority; u8 classifier_type; From 3750985c8d365618612fa191035b0fb2641b8c68 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 4 Aug 2018 10:18:57 +0100 Subject: [PATCH 842/903] staging:rtl8192u: Remove comments - Style Removal of three comments. The comments in question do not add anything to the understanding of the code, and if they are necessary it would imply that the structure and its member variables are badly named. This is a simple style change and should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index 93984e8e87c3..924d4b373099 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -78,8 +78,8 @@ struct ts_common_info { struct tx_ts_record { struct ts_common_info ts_common_info; u16 tx_cur_seq; - BA_RECORD tx_pending_ba_record; /* For BA Originator */ - BA_RECORD tx_admitted_ba_record; /* For BA Originator */ + BA_RECORD tx_pending_ba_record; + BA_RECORD tx_admitted_ba_record; u8 add_ba_req_in_progress; u8 add_ba_req_delayed; u8 using_ba; @@ -93,7 +93,7 @@ struct rx_ts_record { u16 rx_timeout_indicate_seq; struct list_head rx_pending_pkt_list; struct timer_list rx_pkt_pending_timer; - BA_RECORD rx_admitted_ba_record; /* For BA Recipient */ + BA_RECORD rx_admitted_ba_record; u16 rx_last_seq_num; u8 rx_last_frag_num; u8 num; From 8e0c18d3a114d4ea37140b8245a0543392743ba7 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Sat, 4 Aug 2018 10:18:59 +0100 Subject: [PATCH 843/903] staging:rtl8192u: Replace magic number with defined constant - Style Replace the magic number '8' with defined constant which is normally used 'MAX_DEV_ADDR_SIZE'. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 51cb5e4658b0..212cc9ccbb96 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -217,7 +217,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *)skb->data; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); spin_lock_irqsave(&ieee->lock, flags); From ac588ce4b5163199455b3dd8fa589f5e4eb56152 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 4 Aug 2018 16:35:40 +0200 Subject: [PATCH 844/903] staging: rtl8188eu: rename rtw_IOL_applied Rename rtw_IOL_applied to be all lowercase. rtw_IOL_applied -> rtw_iol_applied Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 +- drivers/staging/rtl8188eu/core/rtw_iol.c | 2 +- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 4 ++-- drivers/staging/rtl8188eu/include/rtw_iol.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index b19aa26d1705..0fd306a808c4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -298,7 +298,7 @@ static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf) { - if (rtw_IOL_applied(Adapter)) { + if (rtw_iol_applied(Adapter)) { rtw_hal_power_on(Adapter); iol_mode_enable(Adapter, 1); iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf); diff --git a/drivers/staging/rtl8188eu/core/rtw_iol.c b/drivers/staging/rtl8188eu/core/rtw_iol.c index 6b97e9f2a77b..f7a86eac738e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_iol.c +++ b/drivers/staging/rtl8188eu/core/rtw_iol.c @@ -7,7 +7,7 @@ #include -bool rtw_IOL_applied(struct adapter *adapter) +bool rtw_iol_applied(struct adapter *adapter) { if (adapter->registrypriv.fw_iol == 1) return true; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 8e7190b98692..607170775fa5 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -75,7 +75,7 @@ s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) s32 result = _SUCCESS; DBG_88E("==> %s\n", __func__); - if (rtw_IOL_applied(padapter)) { + if (rtw_iol_applied(padapter)) { iol_mode_enable(padapter, 1); result = iol_execute(padapter, CMD_READ_EFUSE_MAP); if (result == _SUCCESS) @@ -207,7 +207,7 @@ s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) u32 i; u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;/* 176, 22k */ - if (rtw_IOL_applied(padapter)) { + if (rtw_iol_applied(padapter)) { status = iol_InitLLTTable(padapter, txpktbuf_bndy); } else { for (i = 0; i < (txpktbuf_bndy - 1); i++) { diff --git a/drivers/staging/rtl8188eu/include/rtw_iol.h b/drivers/staging/rtl8188eu/include/rtw_iol.h index 53f5fe210e7b..f20b35e8d0a2 100644 --- a/drivers/staging/rtl8188eu/include/rtw_iol.h +++ b/drivers/staging/rtl8188eu/include/rtw_iol.h @@ -10,6 +10,6 @@ #include #include -bool rtw_IOL_applied(struct adapter *adapter); +bool rtw_iol_applied(struct adapter *adapter); #endif /* __RTW_IOL_H_ */ From 5eb438c9d23622595f6d599e33b11f179d50c3a6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 4 Aug 2018 16:35:41 +0200 Subject: [PATCH 845/903] staging: rtl8188eu: remove unnecessary parentheses Remove unnecessary parentheses from if conditions. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_iol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_iol.c b/drivers/staging/rtl8188eu/core/rtw_iol.c index f7a86eac738e..fc3c66201e59 100644 --- a/drivers/staging/rtl8188eu/core/rtw_iol.c +++ b/drivers/staging/rtl8188eu/core/rtw_iol.c @@ -12,8 +12,8 @@ bool rtw_iol_applied(struct adapter *adapter) if (adapter->registrypriv.fw_iol == 1) return true; - if ((adapter->registrypriv.fw_iol == 2) && - (!adapter_to_dvobj(adapter)->ishighspeed)) + if (adapter->registrypriv.fw_iol == 2 && + !adapter_to_dvobj(adapter)->ishighspeed) return true; return false; } From b5c7af4139f45495779257588ee87aaea6c1a60a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 4 Aug 2018 16:35:42 +0200 Subject: [PATCH 846/903] staging: rtl8188eu: remove redundant include The header osdep_service.h is included from drv_types.h, so remove the redundant include. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_iol.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_iol.h b/drivers/staging/rtl8188eu/include/rtw_iol.h index f20b35e8d0a2..d713782d5cdc 100644 --- a/drivers/staging/rtl8188eu/include/rtw_iol.h +++ b/drivers/staging/rtl8188eu/include/rtw_iol.h @@ -7,7 +7,6 @@ #ifndef __RTW_IOL_H_ #define __RTW_IOL_H_ -#include #include bool rtw_iol_applied(struct adapter *adapter); From 1061bdba2fc395e4738315782655dd9b477b1f9f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 4 Aug 2018 16:35:43 +0200 Subject: [PATCH 847/903] staging: rtl8188eu: remove unnecessary includes In the header rtw_iol.h there is only one function declared. Remove the include of rtw_iol.h from files that do not use this function. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/mac_cfg.c | 1 - drivers/staging/rtl8188eu/hal/phy.c | 1 - drivers/staging/rtl8188eu/hal/usb_halinit.c | 1 - drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 1 - 4 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/mac_cfg.c b/drivers/staging/rtl8188eu/hal/mac_cfg.c index 8e849228f376..370aa5cc55a7 100644 --- a/drivers/staging/rtl8188eu/hal/mac_cfg.c +++ b/drivers/staging/rtl8188eu/hal/mac_cfg.c @@ -7,7 +7,6 @@ #include "odm_precomp.h" #include "phy.h" -#include /* MAC_REG.TXT */ diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 0fe2d53310f0..3c7cf8720df8 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 56fda8005d38..12864b648fa8 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #define HAL_BB_ENABLE 1 diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 19387d87185d..bee3c3a7a7a9 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -19,7 +19,6 @@ #include #include -#include #include #include From 2bc7596438aba6d9eacc4fdfac8dd8b22ae4a267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristaps=20=C4=8Civkulis?= Date: Sun, 5 Aug 2018 18:21:01 +0300 Subject: [PATCH 848/903] staging: erofs: fix if assignment style issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix coding style issue "do not use assignment in if condition" detected by checkpatch.pl. Signed-off-by: Kristaps ÄŒivkulis Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 3 ++- drivers/staging/erofs/xattr.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 1030ca5c2dc3..45b1255f5a22 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -702,7 +702,8 @@ next_part: /* can be used for verification */ map->m_llen = offset + cur - map->m_la; - if ((end = cur) > 0) + end = cur; + if (end > 0) goto repeat; /* FIXME! avoid the last relundant fixup & endio */ diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c index 6b9685fa601c..0e9cfeccdf99 100644 --- a/drivers/staging/erofs/xattr.c +++ b/drivers/staging/erofs/xattr.c @@ -288,8 +288,8 @@ static int inline_getxattr(struct inode *inode, struct getxattr_iter *it) remaining = ret; while (remaining) { - if ((ret = xattr_foreach(&it->it, - &find_xattr_handlers, &remaining)) >= 0) + ret = xattr_foreach(&it->it, &find_xattr_handlers, &remaining); + if (ret >= 0) break; } xattr_iter_end(&it->it, true); @@ -321,8 +321,8 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it) it->it.blkaddr = blkaddr; } - if ((ret = xattr_foreach(&it->it, - &find_xattr_handlers, NULL)) >= 0) + ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL); + if (ret >= 0) break; } if (vi->xattr_shared_count) @@ -512,8 +512,8 @@ static int inline_listxattr(struct listxattr_iter *it) remaining = ret; while (remaining) { - if ((ret = xattr_foreach(&it->it, - &list_xattr_handlers, &remaining)) < 0) + ret = xattr_foreach(&it->it, &list_xattr_handlers, &remaining); + if (ret < 0) break; } xattr_iter_end(&it->it, true); @@ -544,8 +544,8 @@ static int shared_listxattr(struct listxattr_iter *it) it->it.blkaddr = blkaddr; } - if ((ret = xattr_foreach(&it->it, - &list_xattr_handlers, NULL)) < 0) + ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL); + if (ret < 0) break; } if (vi->xattr_shared_count) From a81d678949471d5b7f399cfcf2e48e0382427805 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:35 -0700 Subject: [PATCH 849/903] staging: gasket: sysfs: clean up state if ENOMEM removing mapping If kcalloc() returns NULL in put_mapping(), continue to clean up state, including dropping the reference on the struct device and free attribute memory. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index 56d62aea5111..fc45f0d13e87 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -101,13 +101,12 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) files_to_remove = kcalloc(num_files_to_remove, sizeof(*files_to_remove), GFP_KERNEL); - if (!files_to_remove) { - mutex_unlock(&mapping->mutex); - return; - } - - for (i = 0; i < num_files_to_remove; i++) - files_to_remove[i] = mapping->attributes[i].attr; + if (files_to_remove) + for (i = 0; i < num_files_to_remove; i++) + files_to_remove[i] = + mapping->attributes[i].attr; + else + num_files_to_remove = 0; kfree(mapping->attributes); mapping->attributes = NULL; From b7072b24fa61f42c356ffdfaa0544065d6f1c23b Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:36 -0700 Subject: [PATCH 850/903] staging: gasket: core: move core PCI calls to device drivers Remove gasket wrapping of PCI probe, enable, disable, and remove functions. Replace with calls to add and remove PCI gasket devices, to be called by the gasket device drivers. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 82 ++++++++-------------------- drivers/staging/gasket/gasket_core.h | 6 ++ 2 files changed, 28 insertions(+), 60 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 2d209e36cf37..01cafe1ff660 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -51,9 +51,6 @@ struct gasket_internal_desc { /* Kernel-internal device class. */ struct class *class; - /* PCI subsystem metadata associated with this driver. */ - struct pci_driver pci; - /* Instantiated / present devices of this type. */ struct gasket_dev *devs[GASKET_DEV_MAX]; }; @@ -368,10 +365,10 @@ static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num) } /* - * Setup PCI & set up memory mapping for the specified device. + * Setup PCI memory mapping for the specified device. * - * Enables the PCI device, reads the BAR registers and sets up pointers to the - * device's memory mapped IO space. + * Reads the BAR registers and sets up pointers to the device's memory mapped + * IO space. * * Returns 0 on success and a negative value otherwise. */ @@ -380,14 +377,6 @@ static int gasket_setup_pci(struct pci_dev *pci_dev, { int i, mapped_bars, ret; - ret = pci_enable_device(pci_dev); - if (ret) { - dev_err(gasket_dev->dev, "cannot enable PCI device\n"); - return ret; - } - - pci_set_master(pci_dev); - for (i = 0; i < GASKET_NUM_BARS; i++) { ret = gasket_map_pci_bar(gasket_dev, i); if (ret) { @@ -402,19 +391,16 @@ fail: for (i = 0; i < mapped_bars; i++) gasket_unmap_pci_bar(gasket_dev, i); - pci_disable_device(pci_dev); return -ENOMEM; } -/* Unmaps memory and cleans up PCI for the specified device. */ +/* Unmaps memory for the specified device. */ static void gasket_cleanup_pci(struct gasket_dev *gasket_dev) { int i; for (i = 0; i < GASKET_NUM_BARS; i++) gasket_unmap_pci_bar(gasket_dev, i); - - pci_disable_device(gasket_dev->pci_dev); } /* Determine the health of the Gasket device. */ @@ -1443,15 +1429,14 @@ static int gasket_enable_dev(struct gasket_internal_desc *internal_desc, } /* - * PCI subsystem probe function. + * Add PCI gasket device. * - * Called when a Gasket device is found. Allocates device metadata, maps device - * memory, and calls gasket_enable_dev to prepare the device for active use. - * - * Returns 0 if successful and a negative value otherwise. + * Called by Gasket device probe function. + * Allocates device metadata, maps device memory, and calls gasket_enable_dev + * to prepare the device for active use. */ -static int gasket_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *id) +int gasket_pci_add_device(struct pci_dev *pci_dev, + struct gasket_dev **gasket_devp) { int ret; const char *kobj_name = dev_name(&pci_dev->dev); @@ -1460,13 +1445,14 @@ static int gasket_pci_probe(struct pci_dev *pci_dev, const struct gasket_driver_desc *driver_desc; struct device *parent; - pr_info("Add Gasket device %s\n", kobj_name); + pr_debug("add PCI device %s\n", kobj_name); mutex_lock(&g_mutex); internal_desc = lookup_internal_desc(pci_dev); mutex_unlock(&g_mutex); if (!internal_desc) { - pr_err("PCI probe called for unknown driver type\n"); + dev_err(&pci_dev->dev, + "PCI add device called for unknown driver type\n"); return -ENODEV; } @@ -1530,6 +1516,7 @@ static int gasket_pci_probe(struct pci_dev *pci_dev, goto fail5; } + *gasket_devp = gasket_dev; return 0; fail5: @@ -1545,14 +1532,10 @@ fail1: gasket_free_dev(gasket_dev); return ret; } +EXPORT_SYMBOL(gasket_pci_add_device); -/* - * PCI subsystem remove function. - * - * Called to remove a Gasket device. Finds the device in the device list and - * cleans up metadata. - */ -static void gasket_pci_remove(struct pci_dev *pci_dev) +/* Remove a PCI gasket device. */ +void gasket_pci_remove_device(struct pci_dev *pci_dev) { int i; struct gasket_internal_desc *internal_desc; @@ -1583,8 +1566,8 @@ static void gasket_pci_remove(struct pci_dev *pci_dev) if (!gasket_dev) return; - pr_info("remove %s device %s\n", internal_desc->driver_desc->name, - gasket_dev->kobj_name); + dev_dbg(gasket_dev->dev, "remove %s PCI gasket device\n", + internal_desc->driver_desc->name); gasket_disable_dev(gasket_dev); gasket_cleanup_pci(gasket_dev); @@ -1597,6 +1580,7 @@ static void gasket_pci_remove(struct pci_dev *pci_dev) device_destroy(internal_desc->class, gasket_dev->dev_info.devt); gasket_free_dev(gasket_dev); } +EXPORT_SYMBOL(gasket_pci_remove_device); /** * Lookup a name by number in a num_name table. @@ -1770,11 +1754,6 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) internal = &g_descs[desc_idx]; mutex_init(&internal->mutex); memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX); - memset(&internal->pci, 0, sizeof(internal->pci)); - internal->pci.name = driver_desc->name; - internal->pci.id_table = driver_desc->pci_id_table; - internal->pci.probe = gasket_pci_probe; - internal->pci.remove = gasket_pci_remove; internal->class = class_create(driver_desc->module, driver_desc->name); @@ -1785,33 +1764,18 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc) goto unregister_gasket_driver; } - /* - * Not using pci_register_driver() (without underscores), as it - * depends on KBUILD_MODNAME, and this is a shared file. - */ - ret = __pci_register_driver(&internal->pci, driver_desc->module, - driver_desc->name); - if (ret) { - pr_err("cannot register %s pci driver [ret=%d]\n", - driver_desc->name, ret); - goto fail1; - } - ret = register_chrdev_region(MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, driver_desc->name); if (ret) { pr_err("cannot register %s char driver [ret=%d]\n", driver_desc->name, ret); - goto fail2; + goto destroy_class; } return 0; -fail2: - pci_unregister_driver(&internal->pci); - -fail1: +destroy_class: class_destroy(internal->class); unregister_gasket_driver: @@ -1848,8 +1812,6 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) unregister_chrdev_region(MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX); - pci_unregister_driver(&internal_desc->pci); - class_destroy(internal_desc->class); /* Finally, effectively "remove" the driver. */ diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 67f5960943a8..9f9bc66a0daa 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -607,6 +607,12 @@ int gasket_register_device(const struct gasket_driver_desc *desc); */ void gasket_unregister_device(const struct gasket_driver_desc *desc); +/* Add a PCI gasket device. */ +int gasket_pci_add_device(struct pci_dev *pci_dev, + struct gasket_dev **gasket_devp); +/* Remove a PCI gasket device. */ +void gasket_pci_remove_device(struct pci_dev *pci_dev); + /* * Reset the Gasket device. * @gasket_dev: Gasket device struct. From 1453e90cc40e0b6660b872a573755f8f28c17593 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:37 -0700 Subject: [PATCH 851/903] staging: gasket: apex: move PCI core calls to apex driver Apex driver moves PCI core calls like probe, enable, and remove from gasket to apex. Call new functions in gasket to register apex as a PCI device to the gasket framework. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 49 +++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 42cef68eb4c1..b47661442009 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -621,6 +622,36 @@ static void apex_pci_fixup_class(struct pci_dev *pdev) DECLARE_PCI_FIXUP_CLASS_HEADER(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID, PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class); +static int apex_pci_probe(struct pci_dev *pci_dev, + const struct pci_device_id *id) +{ + int ret; + struct gasket_dev *gasket_dev; + + ret = pci_enable_device(pci_dev); + if (ret) { + dev_err(&pci_dev->dev, "error enabling PCI device\n"); + return ret; + } + + pci_set_master(pci_dev); + + ret = gasket_pci_add_device(pci_dev, &gasket_dev); + if (ret) { + dev_err(&pci_dev->dev, "error adding gasket device\n"); + pci_disable_device(pci_dev); + return ret; + } + + return 0; +} + +static void apex_pci_remove(struct pci_dev *pci_dev) +{ + gasket_pci_remove_device(pci_dev); + pci_disable_device(pci_dev); +} + static struct gasket_driver_desc apex_desc = { .name = "apex", .driver_version = APEX_DRIVER_VERSION, @@ -672,13 +703,29 @@ static struct gasket_driver_desc apex_desc = { .device_reset_cb = apex_reset, }; +static struct pci_driver apex_pci_driver = { + .name = "apex", + .probe = apex_pci_probe, + .remove = apex_pci_remove, + .id_table = apex_pci_ids, +}; + static int __init apex_init(void) { - return gasket_register_device(&apex_desc); + int ret; + + ret = gasket_register_device(&apex_desc); + if (ret) + return ret; + ret = pci_register_driver(&apex_pci_driver); + if (ret) + gasket_unregister_device(&apex_desc); + return ret; } static void apex_exit(void) { + pci_unregister_driver(&apex_pci_driver); gasket_unregister_device(&apex_desc); } MODULE_DESCRIPTION("Google Apex driver"); From c75e2bb32fd04ebcdeaa907144027c0b9c416f05 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:38 -0700 Subject: [PATCH 852/903] staging: gasket: core: convert remaining info logs to debug Remaining info-level logs in gasket core converted to debug-level; the information is not needed during normal system operation. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 01cafe1ff660..2741256eacfe 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1819,7 +1819,7 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) g_descs[desc_idx].driver_desc = NULL; mutex_unlock(&g_mutex); - pr_info("removed %s driver\n", driver_desc->name); + pr_debug("removed %s driver\n", driver_desc->name); } EXPORT_SYMBOL(gasket_unregister_device); @@ -1827,7 +1827,7 @@ static int __init gasket_init(void) { int i; - pr_info("Performing one-time init of the Gasket framework.\n"); + pr_debug("%s\n", __func__); /* Check for duplicates and find a free slot. */ mutex_lock(&g_mutex); for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { @@ -1843,8 +1843,7 @@ static int __init gasket_init(void) static void __exit gasket_exit(void) { - /* No deinit/dealloc needed at present. */ - pr_info("Removing Gasket framework module.\n"); + pr_debug("%s\n", __func__); } MODULE_DESCRIPTION("Google Gasket driver framework"); MODULE_VERSION(GASKET_FRAMEWORK_VERSION); From 1b25e6e81aab048107ed20c218c2b04261fd94ec Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:39 -0700 Subject: [PATCH 853/903] staging: gasket: core: remove device enable and disable callbacks Device enable/disable operations are moving from being initiated through the gasket framework to being initiated by the gasket device driver. The driver can perform any processing needed for these operations before or after the calls into the framework. Neither of these callbacks are implemented for the only gasket driver upstream today, apex. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 9 --------- drivers/staging/gasket/gasket_core.h | 27 ++------------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 2741256eacfe..b070efaf0d41 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -648,8 +648,6 @@ static void gasket_disable_dev(struct gasket_dev *gasket_dev) gasket_page_table_cleanup(gasket_dev->page_table[i]); } } - - check_and_invoke_callback(gasket_dev, driver_desc->disable_dev_cb); } /* @@ -1408,13 +1406,6 @@ static int gasket_enable_dev(struct gasket_internal_desc *internal_desc, } gasket_dev->hardware_revision = ret; - ret = check_and_invoke_callback(gasket_dev, driver_desc->enable_dev_cb); - if (ret) { - dev_err(gasket_dev->dev, "Error in enable device cb: %d\n", - ret); - return ret; - } - /* device_status_cb returns a device status, not an error code. */ gasket_dev->status = gasket_get_hw_status(gasket_dev); if (gasket_dev->status == GASKET_STATUS_DEAD) diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 9f9bc66a0daa..5d40bc7f52e9 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -473,34 +473,11 @@ struct gasket_driver_desc { */ int (*device_close_cb)(struct gasket_dev *dev); - /* - * enable_dev_cb: Callback immediately before enabling the device. - * @dev: Pointer to the gasket_dev struct for this driver instance. - * - * This callback is invoked after the device has been added and all BAR - * spaces mapped, immediately before registering and enabling the - * [character] device via cdev_add. If this call fails (returns - * nonzero), disable_dev_cb will be called. - * - * Note that cdev are initialized but not active - * (cdev_add has not yet been called) when this callback is invoked. - */ - int (*enable_dev_cb)(struct gasket_dev *dev); - - /* - * disable_dev_cb: Callback immediately after disabling the device. - * @dev: Pointer to the gasket_dev struct for this driver instance. - * - * Called during device shutdown, immediately after disabling device - * operations via cdev_del. - */ - int (*disable_dev_cb)(struct gasket_dev *dev); - /* * sysfs_setup_cb: Callback to set up driver-specific sysfs nodes. * @dev: Pointer to the gasket_dev struct for this device. * - * Called just before enable_dev_cb. + * Called during the add gasket device call. * */ int (*sysfs_setup_cb)(struct gasket_dev *dev); @@ -509,7 +486,7 @@ struct gasket_driver_desc { * sysfs_cleanup_cb: Callback to clean up driver-specific sysfs nodes. * @dev: Pointer to the gasket_dev struct for this device. * - * Called just before disable_dev_cb. + * Called during device disable processing. * */ int (*sysfs_cleanup_cb)(struct gasket_dev *dev); From 2f649036fa66b1494da6ecf8bd4d53167e10e36f Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:40 -0700 Subject: [PATCH 854/903] staging: gasket: apex: remove device enable and disable callbacks These are not implemented for apex, and are now being removed from the gasket framework. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index b47661442009..e2bc06b5244f 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -688,9 +688,6 @@ static struct gasket_driver_desc apex_desc = { .add_dev_cb = apex_add_dev_cb, .remove_dev_cb = NULL, - .enable_dev_cb = NULL, - .disable_dev_cb = NULL, - .sysfs_setup_cb = apex_sysfs_setup_cb, .sysfs_cleanup_cb = NULL, From 39091410d0d8eeb07f3b08ff4e44400ccd434762 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:41 -0700 Subject: [PATCH 855/903] staging: gasket: core: let device driver enable/disable gasket device Move gasket device enable/disable functions from internal calls to external calls from the gasket device drivers. The device driver will call these functions at appropriate times in its processing, placing the device driver in control of this sequence and reducing the need for callbacks from framework back to the device drivers during the enable/disable sequences. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 22 ++++++++-------------- drivers/staging/gasket/gasket_core.h | 6 ++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index b070efaf0d41..fad4883e6332 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -628,7 +628,7 @@ static int gasket_add_cdev(struct gasket_cdev_info *dev_info, } /* Disable device operations. */ -static void gasket_disable_dev(struct gasket_dev *gasket_dev) +void gasket_disable_device(struct gasket_dev *gasket_dev) { const struct gasket_driver_desc *driver_desc = gasket_dev->internal_desc->driver_desc; @@ -649,6 +649,7 @@ static void gasket_disable_dev(struct gasket_dev *gasket_dev) } } } +EXPORT_SYMBOL(gasket_disable_device); /* * Registered descriptor lookup. @@ -1350,13 +1351,12 @@ static const struct file_operations gasket_file_ops = { }; /* Perform final init and marks the device as active. */ -static int gasket_enable_dev(struct gasket_internal_desc *internal_desc, - struct gasket_dev *gasket_dev) +int gasket_enable_device(struct gasket_dev *gasket_dev) { int tbl_idx; int ret; const struct gasket_driver_desc *driver_desc = - internal_desc->driver_desc; + gasket_dev->internal_desc->driver_desc; ret = gasket_interrupt_init(gasket_dev, driver_desc->name, driver_desc->interrupt_type, @@ -1418,13 +1418,15 @@ static int gasket_enable_dev(struct gasket_internal_desc *internal_desc, return 0; } +EXPORT_SYMBOL(gasket_enable_device); /* * Add PCI gasket device. * * Called by Gasket device probe function. - * Allocates device metadata, maps device memory, and calls gasket_enable_dev - * to prepare the device for active use. + * Allocates device metadata and maps device memory. The device driver must + * call gasket_enable_device after driver init is complete to place the device + * in active use. */ int gasket_pci_add_device(struct pci_dev *pci_dev, struct gasket_dev **gasket_devp) @@ -1500,13 +1502,6 @@ int gasket_pci_add_device(struct pci_dev *pci_dev, goto fail5; } - ret = gasket_enable_dev(internal_desc, gasket_dev); - if (ret) { - pr_err("cannot setup %s device\n", driver_desc->name); - gasket_disable_dev(gasket_dev); - goto fail5; - } - *gasket_devp = gasket_dev; return 0; @@ -1560,7 +1555,6 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev) dev_dbg(gasket_dev->dev, "remove %s PCI gasket device\n", internal_desc->driver_desc->name); - gasket_disable_dev(gasket_dev); gasket_cleanup_pci(gasket_dev); check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 5d40bc7f52e9..9c143ebeba45 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -590,6 +590,12 @@ int gasket_pci_add_device(struct pci_dev *pci_dev, /* Remove a PCI gasket device. */ void gasket_pci_remove_device(struct pci_dev *pci_dev); +/* Enable a Gasket device. */ +int gasket_enable_device(struct gasket_dev *gasket_dev); + +/* Disable a Gasket device. */ +void gasket_disable_device(struct gasket_dev *gasket_dev); + /* * Reset the Gasket device. * @gasket_dev: Gasket device struct. From 38da89d5cc958d2b0cf03c237cd155ab08973b1a Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:42 -0700 Subject: [PATCH 856/903] staging: gasket: apex: enable/disable gasket device from apex Gasket framework now places device drivers in charge of calling APIs to enable and disable gasket device operations. Make the appropriate calls from the apex driver. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index e2bc06b5244f..1d8a100c5288 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -643,11 +643,23 @@ static int apex_pci_probe(struct pci_dev *pci_dev, return ret; } + pci_set_drvdata(pci_dev, gasket_dev); + ret = gasket_enable_device(gasket_dev); + if (ret) { + dev_err(&pci_dev->dev, "error enabling gasket device\n"); + gasket_pci_remove_device(pci_dev); + pci_disable_device(pci_dev); + return ret; + } + return 0; } static void apex_pci_remove(struct pci_dev *pci_dev) { + struct gasket_dev *gasket_dev = pci_get_drvdata(pci_dev); + + gasket_disable_device(gasket_dev); gasket_pci_remove_device(pci_dev); pci_disable_device(pci_dev); } From 4420ea9366a5df61cbb0bb2ad827ff6391904f56 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:43 -0700 Subject: [PATCH 857/903] staging: gasket: core: delete device add and remove callbacks Gasket device drivers are now in charge of orchestrating the device add and removal sequences, so the callbacks from the framework to the device drivers for these events are no longer needed. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 10 ---------- drivers/staging/gasket/gasket_core.h | 29 ---------------------------- 2 files changed, 39 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index fad4883e6332..0d76e18fcde5 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1468,12 +1468,6 @@ int gasket_pci_add_device(struct pci_dev *pci_dev, if (ret) goto fail2; - ret = check_and_invoke_callback(gasket_dev, driver_desc->add_dev_cb); - if (ret) { - dev_err(gasket_dev->dev, "Error in add device cb: %d\n", ret); - goto fail2; - } - ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device, gasket_dev); if (ret) @@ -1512,7 +1506,6 @@ fail3: gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); fail2: gasket_cleanup_pci(gasket_dev); - check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); device_destroy(internal_desc->class, gasket_dev->dev_info.devt); fail1: gasket_free_dev(gasket_dev); @@ -1559,9 +1552,6 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev) check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); - - check_and_invoke_callback(gasket_dev, driver_desc->remove_dev_cb); - device_destroy(internal_desc->class, gasket_dev->dev_info.devt); gasket_free_dev(gasket_dev); } diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 9c143ebeba45..0ef0a2640f0f 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -302,12 +302,6 @@ struct gasket_dev { /* Hardware revision value for this device. */ int hardware_revision; - /* - * Device-specific data; allocated in gasket_driver_desc.add_dev_cb() - * and freed in gasket_driver_desc.remove_dev_cb(). - */ - void *cb_data; - /* Protects access to per-device data (i.e. this structure). */ struct mutex mutex; @@ -415,29 +409,6 @@ struct gasket_driver_desc { int interrupt_pack_width; /* Driver callback functions - all may be NULL */ - /* - * add_dev_cb: Callback when a device is found. - * @dev: The gasket_dev struct for this driver instance. - * - * This callback should initialize the device-specific cb_data. - * Called when a device is found by the driver, - * before any BAR ranges have been mapped. If this call fails (returns - * nonzero), remove_dev_cb will be called. - * - */ - int (*add_dev_cb)(struct gasket_dev *dev); - - /* - * remove_dev_cb: Callback for when a device is removed from the system. - * @dev: The gasket_dev struct for this driver instance. - * - * This callback should free data allocated in add_dev_cb. - * Called immediately before a device is unregistered by the driver. - * All framework-managed resources will have been cleaned up by the time - * this callback is invoked (PCI BARs, character devices, ...). - */ - int (*remove_dev_cb)(struct gasket_dev *dev); - /* * device_open_cb: Callback for when a device node is opened in write * mode. From c169d876bfbfedd9ed3d3968924c24455bb4cb2f Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:44 -0700 Subject: [PATCH 858/903] staging: gasket: apex: fold device add/remove logic inline Gasket device drivers are now in charge of the device add and remove sequences; the framework callbacks for these are deleted. Move the apex device add callback code to the probe function. Apex did not implement the removal callback. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 69 +++++++++++++--------------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 1d8a100c5288..69ca7fb10edd 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -448,37 +448,6 @@ static int apex_reset(struct gasket_dev *gasket_dev) return ret; } -static int apex_add_dev_cb(struct gasket_dev *gasket_dev) -{ - ulong page_table_ready, msix_table_ready; - int retries = 0; - - apex_reset(gasket_dev); - - while (retries < APEX_RESET_RETRY) { - page_table_ready = - gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT); - msix_table_ready = - gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, - APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT); - if (page_table_ready && msix_table_ready) - break; - schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY)); - retries++; - } - - if (retries == APEX_RESET_RETRY) { - if (!page_table_ready) - dev_err(gasket_dev->dev, "Page table init timed out\n"); - if (!msix_table_ready) - dev_err(gasket_dev->dev, "MSI-X table init timed out\n"); - return -ETIMEDOUT; - } - - return 0; -} - /* * Check permissions for Apex ioctls. * Returns true if the current user may execute this ioctl, and false otherwise. @@ -626,6 +595,8 @@ static int apex_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) { int ret; + ulong page_table_ready, msix_table_ready; + int retries = 0; struct gasket_dev *gasket_dev; ret = pci_enable_device(pci_dev); @@ -644,15 +615,42 @@ static int apex_pci_probe(struct pci_dev *pci_dev, } pci_set_drvdata(pci_dev, gasket_dev); + apex_reset(gasket_dev); + + while (retries < APEX_RESET_RETRY) { + page_table_ready = + gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT); + msix_table_ready = + gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX, + APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT); + if (page_table_ready && msix_table_ready) + break; + schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY)); + retries++; + } + + if (retries == APEX_RESET_RETRY) { + if (!page_table_ready) + dev_err(gasket_dev->dev, "Page table init timed out\n"); + if (!msix_table_ready) + dev_err(gasket_dev->dev, "MSI-X table init timed out\n"); + ret = -ETIMEDOUT; + goto remove_device; + } + ret = gasket_enable_device(gasket_dev); if (ret) { dev_err(&pci_dev->dev, "error enabling gasket device\n"); - gasket_pci_remove_device(pci_dev); - pci_disable_device(pci_dev); - return ret; + goto remove_device; } return 0; + +remove_device: + gasket_pci_remove_device(pci_dev); + pci_disable_device(pci_dev); + return ret; } static void apex_pci_remove(struct pci_dev *pci_dev) @@ -697,9 +695,6 @@ static struct gasket_driver_desc apex_desc = { .interrupts = apex_interrupts, .interrupt_pack_width = 7, - .add_dev_cb = apex_add_dev_cb, - .remove_dev_cb = NULL, - .sysfs_setup_cb = apex_sysfs_setup_cb, .sysfs_cleanup_cb = NULL, From 565eeedaa0c1b2b0d8abd3845e349de29065a5d2 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:45 -0700 Subject: [PATCH 859/903] staging: gasket: core: remove sysfs setup and cleanup callbacks Gasket device drivers now call into the gasket framework to initialize and de-initialize, rather than the other way around. The calling code can perform sysfs setup and cleanup actions without callbacks from the framework. Remove the sysfs setup and cleanup callbacks. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 10 ---------- drivers/staging/gasket/gasket_core.h | 18 ------------------ 2 files changed, 28 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 0d76e18fcde5..ace92f107ed5 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1489,18 +1489,9 @@ int gasket_pci_add_device(struct pci_dev *pci_dev, if (ret) goto fail4; - ret = check_and_invoke_callback(gasket_dev, - driver_desc->sysfs_setup_cb); - if (ret) { - dev_err(gasket_dev->dev, "Error in sysfs setup cb: %d\n", ret); - goto fail5; - } - *gasket_devp = gasket_dev; return 0; -fail5: - check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); fail4: fail3: gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); @@ -1550,7 +1541,6 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev) gasket_cleanup_pci(gasket_dev); - check_and_invoke_callback(gasket_dev, driver_desc->sysfs_cleanup_cb); gasket_sysfs_remove_mapping(gasket_dev->dev_info.device); device_destroy(internal_desc->class, gasket_dev->dev_info.devt); gasket_free_dev(gasket_dev); diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 0ef0a2640f0f..275fd0b345b6 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -444,24 +444,6 @@ struct gasket_driver_desc { */ int (*device_close_cb)(struct gasket_dev *dev); - /* - * sysfs_setup_cb: Callback to set up driver-specific sysfs nodes. - * @dev: Pointer to the gasket_dev struct for this device. - * - * Called during the add gasket device call. - * - */ - int (*sysfs_setup_cb)(struct gasket_dev *dev); - - /* - * sysfs_cleanup_cb: Callback to clean up driver-specific sysfs nodes. - * @dev: Pointer to the gasket_dev struct for this device. - * - * Called during device disable processing. - * - */ - int (*sysfs_cleanup_cb)(struct gasket_dev *dev); - /* * get_mappable_regions_cb: Get descriptors of mappable device memory. * @gasket_dev: Pointer to the struct gasket_dev for this device. From 71934948b0a18c227de088a40c7660b5ed8cce2c Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:46 -0700 Subject: [PATCH 860/903] staging: gasket: apex: move sysfs setup code to probe function The gasket framework no longer provides callbacks to the device driver for sysfs setup and teardown. Move the sysfs setup code to the device probe function. Apex does not implement sysfs cleanup code. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 69ca7fb10edd..55319619b2e6 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -568,12 +568,6 @@ static struct gasket_sysfs_attribute apex_sysfs_attrs[] = { GASKET_END_OF_ATTR_ARRAY }; -static int apex_sysfs_setup_cb(struct gasket_dev *gasket_dev) -{ - return gasket_sysfs_create_entries(gasket_dev->dev_info.device, - apex_sysfs_attrs); -} - /* On device open, perform a core reinit reset. */ static int apex_device_open_cb(struct gasket_dev *gasket_dev) { @@ -639,6 +633,11 @@ static int apex_pci_probe(struct pci_dev *pci_dev, goto remove_device; } + ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device, + apex_sysfs_attrs); + if (ret) + dev_err(&pci_dev->dev, "error creating device sysfs entries\n"); + ret = gasket_enable_device(gasket_dev); if (ret) { dev_err(&pci_dev->dev, "error enabling gasket device\n"); @@ -695,9 +694,6 @@ static struct gasket_driver_desc apex_desc = { .interrupts = apex_interrupts, .interrupt_pack_width = 7, - .sysfs_setup_cb = apex_sysfs_setup_cb, - .sysfs_cleanup_cb = NULL, - .device_open_cb = apex_device_open_cb, .device_close_cb = apex_device_cleanup, From 95a2c279b2c7c2e59977d5b0773a15ba26b7ce4b Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:47 -0700 Subject: [PATCH 861/903] staging: gasket: core: protect against races during unregister Keep mutex held across the unregistration operation, until the driver_desc field of the global table is removed, to prevent a concurrent accessor from looking up the driver_desc while gasket_unregister_device() is in the processing of removing it. Reported-by: Guenter Roeck Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index ace92f107ed5..a6462b6d702f 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1765,9 +1765,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) break; } } - mutex_unlock(&g_mutex); if (!internal_desc) { + mutex_unlock(&g_mutex); pr_err("request to unregister unknown desc: %s, %d:%d\n", driver_desc->name, driver_desc->major, driver_desc->minor); @@ -1780,7 +1780,6 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) class_destroy(internal_desc->class); /* Finally, effectively "remove" the driver. */ - mutex_lock(&g_mutex); g_descs[desc_idx].driver_desc = NULL; mutex_unlock(&g_mutex); From 4801fc6f7f72447efc7c2f6e886c887ff5bf5f4c Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:48 -0700 Subject: [PATCH 862/903] staging: gasket: apex: place in low power reset until opened The apex device is left out of reset mode at the end of device probe/initialize processing. Add a call to enter reset at the end of the sequence, triggering power gating and other low power features. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/apex_driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index 55319619b2e6..c747e9ca4518 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -644,6 +644,10 @@ static int apex_pci_probe(struct pci_dev *pci_dev, goto remove_device; } + /* Place device in low power mode until opened */ + if (allow_power_save) + apex_enter_reset(gasket_dev); + return 0; remove_device: From d37d2dd41f7ad0bc0996e600727480ffaaad6fd3 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Sun, 5 Aug 2018 13:07:49 -0700 Subject: [PATCH 863/903] staging: gasket: core: remove incorrect extraneous comment A copy-and-pasted comment from another code sequence is removed from gasket core init sequence. Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index a6462b6d702f..d12ab560411f 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1792,7 +1792,6 @@ static int __init gasket_init(void) int i; pr_debug("%s\n", __func__); - /* Check for duplicates and find a free slot. */ mutex_lock(&g_mutex); for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) { g_descs[i].driver_desc = NULL; From 8d84a9c1d29dbad517228e7e64d07b4d86dc7f59 Mon Sep 17 00:00:00 2001 From: Sumit Pundir Date: Tue, 7 Aug 2018 16:14:28 +0530 Subject: [PATCH 864/903] staging: gasket: fix code indent for conditional statement Fixed a coding style issue related to indentation. Reported by checkpatch.pl Signed-off-by: Sumit Pundir Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index ed6ab3c5f038..d4c5f8aa7dd3 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1311,7 +1311,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, gasket_dev->coherent_buffer.virt_base = mem; *dma_address = driver_desc->coherent_buffer_description.base; - for (j = 0; j < num_pages; j++) { + for (j = 0; j < num_pages; j++) { gasket_dev->page_table[index]->coherent_pages[j].paddr = handle + j * PAGE_SIZE; gasket_dev->page_table[index]->coherent_pages[j].kernel_virt = From ec6e6925fc2adb98ef351d7c25a7e41caa4d5b77 Mon Sep 17 00:00:00 2001 From: zhong jiang Date: Mon, 6 Aug 2018 11:10:19 +0800 Subject: [PATCH 865/903] staging: gasket: remove some extra semicolon That semicolons are unneeded, Just remove them. Signed-off-by: zhong jiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 09c3d0747af6..1cfbc120f228 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -386,7 +386,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup interrupts will cause the device to report @@ -445,7 +445,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) "Cannot handle unsupported interrupt type %d\n", gasket_dev->interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup MSIx will cause the device @@ -493,7 +493,7 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) dev_dbg(gasket_dev->dev, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); - }; + } kfree(interrupt_data->interrupt_counts); kfree(interrupt_data->eventfd_ctxs); From 3978c8e3237c9d09364501bcefdb8c40368421d9 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 6 Aug 2018 11:27:53 +0800 Subject: [PATCH 866/903] staging: erofs: remove an extra semicolon in z_erofs_vle_unzip_all There is an extra semicolon in z_erofs_vle_unzip_all, remove it. Reported-by: Julia Lawall Signed-off-by: zhong jiang Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 45b1255f5a22..8721f0a41d15 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1017,7 +1017,7 @@ static void z_erofs_vle_unzip_all(struct super_block *sb, owned = READ_ONCE(grp->next); z_erofs_vle_unzip(sb, grp, page_pool); - }; + } } static void z_erofs_vle_unzip_wq(struct work_struct *work) From c5fe50aaa20c87cd863fdc56ec7c8e504986f31d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 22:43:06 +0200 Subject: [PATCH 867/903] Revert "staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames" On a Raven Ridge system with a r8188eu usb wifi device commit 515ce733e86e ("staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames") is causing two bugs and a warning in dmesg: [ 22.618465] BUG: scheduling while atomic: NetworkManager/489/0x00000202 [ 22.618466] Modules linked in: amdkfd amd_iommu_v2 amdgpu nls_iso8859_1 nls_cp437 vfat fat r8188eu(C) edac_mce_amd chash kvm_amd gpu_sched i2c_algo_bit ccp ttm rng_core lib80211 kvm snd_hda_codec_realtek snd_hda_codec_generic cfg80211 snd_hda_codec_hdmi snd_hda_intel input_leds drm_kms_helper irqbypass snd_hda_codec crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc rfkill led_class mousedev joydev wmi_bmof snd_hda_core drm aesni_intel snd_hwdep aes_x86_64 crypto_simd cryptd glue_helper snd_pcm pcspkr sp5100_tco snd_timer r8169 k10temp agpgart i2c_piix4 snd mii syscopyarea sysfillrect sysimgblt fb_sys_fops soundcore rtc_cmos evdev gpio_amdpt pinctrl_amd mac_hid wmi pcc_cpufreq acpi_cpufreq crypto_user ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 fscrypto hid_generic usbhid hid sd_mod [ 22.618549] ahci xhci_pci libahci xhci_hcd crc32c_intel libata usbcore scsi_mod usb_common [ 22.618554] Preemption disabled at: [ 22.618558] [] __dev_queue_xmit+0x74/0x910 [ 22.618561] CPU: 3 PID: 489 Comm: NetworkManager Tainted: G C 4.18.0-rc7-staging+ #14 [ 22.618562] Hardware name: Gigabyte Technology Co., Ltd. A320M-S2H/A320M-S2H-CF, BIOS F23d 04/17/2018 [ 22.618563] Call Trace: [ 22.618569] dump_stack+0x5c/0x80 [ 22.618571] ? __dev_queue_xmit+0x74/0x910 [ 22.618574] __schedule_bug.cold.14+0x82/0x9b [ 22.618576] __schedule+0x6fd/0x8b0 [ 22.618578] ? enqueue_task_fair+0xc3/0x730 [ 22.618580] schedule+0x32/0x90 [ 22.618581] schedule_timeout+0x311/0x4a0 [ 22.618583] ? _raw_spin_unlock_irqrestore+0x20/0x40 [ 22.618585] ? try_to_wake_up+0x231/0x480 [ 22.618586] wait_for_common+0x15f/0x190 [ 22.618588] ? wake_up_q+0x70/0x70 [ 22.618597] ? rtw_aes_encrypt+0x26f/0x290 [r8188eu] [ 22.618598] wait_for_completion_killable+0x19/0x30 [ 22.618601] call_usermodehelper_exec+0x115/0x160 [ 22.618603] __request_module+0x1ac/0x3e2 [ 22.618606] ? netlink_broadcast_filtered+0x142/0x400 [ 22.618607] ? netlink_broadcast+0xf/0x20 [ 22.618615] rtw_aes_encrypt+0x26f/0x290 [r8188eu] [ 22.618622] ? rtw_get_stainfo+0xe6/0x130 [r8188eu] [ 22.618629] rtw_xmitframe_coalesce+0x950/0xb00 [r8188eu] [ 22.618631] ? _raw_spin_lock_irqsave+0x25/0x50 [ 22.618638] rtw_hal_xmit+0x83/0x130 [r8188eu] [ 22.618645] rtw_xmit+0x258/0x5d0 [r8188eu] [ 22.618652] rtw_xmit_entry+0xe8/0x2e7 [r8188eu] [ 22.618654] dev_hard_start_xmit+0xa5/0x240 [ 22.618657] sch_direct_xmit+0x150/0x340 [ 22.618658] __dev_queue_xmit+0x2f6/0x910 [ 22.618661] packet_sendmsg+0x948/0x15a7 [ 22.618663] ? attach_to_pi_owner+0x38/0x180 [ 22.618666] sock_sendmsg+0x33/0x40 [ 22.618668] __sys_sendto+0xee/0x160 [ 22.618670] ? memzero_explicit+0xa/0x10 [ 22.618672] ? urandom_read+0x120/0x270 [ 22.618675] __x64_sys_sendto+0x24/0x30 [ 22.618677] do_syscall_64+0x5b/0x170 [ 22.618678] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 22.618680] RIP: 0033:0x7f0942790c12 [ 22.618680] Code: 48 83 ec 18 44 89 4c 24 08 e8 9a f5 ff ff 44 8b 4c 24 08 4d 89 f8 45 89 f2 89 c5 4c 89 ea 4c 89 e6 89 df b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 3a 89 ef 48 89 44 24 08 e8 ca f5 ff ff 48 8b [ 22.618700] RSP: 002b:00007ffe2051be30 EFLAGS: 00000293 ORIG_RAX: 000000000000002c [ 22.618701] RAX: ffffffffffffffda RBX: 0000000000000011 RCX: 00007f0942790c12 [ 22.618702] RDX: 0000000000000148 RSI: 0000559278761700 RDI: 0000000000000011 [ 22.618703] RBP: 0000000000000000 R08: 00005592787aa860 R09: 0000000000000014 [ 22.618703] R10: 0000000000000000 R11: 0000000000000293 R12: 0000559278761700 [ 22.618704] R13: 0000000000000148 R14: 0000000000000000 R15: 00005592787aa860 [ 22.620488] lib80211_crypt: registered algorithm 'CCMP' [ 22.620735] ------------[ cut here ]------------ [ 22.620738] DEBUG_LOCKS_WARN_ON(val > preempt_count()) [ 22.620744] WARNING: CPU: 3 PID: 489 at kernel/sched/core.c:3246 preempt_count_sub+0x5a/0x90 [ 22.620749] Modules linked in: lib80211_crypt_ccmp amdkfd amd_iommu_v2 amdgpu nls_iso8859_1 nls_cp437 vfat fat r8188eu(C) edac_mce_amd chash kvm_amd gpu_sched i2c_algo_bit ccp ttm rng_core lib80211 kvm snd_hda_codec_realtek snd_hda_codec_generic cfg80211 snd_hda_codec_hdmi snd_hda_intel input_leds drm_kms_helper irqbypass snd_hda_codec crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc rfkill led_class mousedev joydev wmi_bmof snd_hda_core drm aesni_intel snd_hwdep aes_x86_64 crypto_simd cryptd glue_helper snd_pcm pcspkr sp5100_tco snd_timer r8169 k10temp agpgart i2c_piix4 snd mii syscopyarea sysfillrect sysimgblt fb_sys_fops soundcore rtc_cmos evdev gpio_amdpt pinctrl_amd mac_hid wmi pcc_cpufreq acpi_cpufreq crypto_user ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 fscrypto hid_generic [ 22.620792] usbhid hid sd_mod ahci xhci_pci libahci xhci_hcd crc32c_intel libata usbcore scsi_mod usb_common [ 22.620803] CPU: 3 PID: 489 Comm: NetworkManager Tainted: G WC 4.18.0-rc7-staging+ #14 [ 22.620804] Hardware name: Gigabyte Technology Co., Ltd. A320M-S2H/A320M-S2H-CF, BIOS F23d 04/17/2018 [ 22.620808] RIP: 0010:preempt_count_sub+0x5a/0x90 [ 22.620809] Code: 14 f7 6b c3 e8 57 89 2d 00 85 c0 74 f6 8b 15 55 6a 5a 01 85 d2 75 ec 48 c7 c6 2e 01 e7 94 48 c7 c7 db b2 e5 94 e8 90 77 fd ff <0f> 0b c3 84 d2 75 c9 e8 2a 89 2d 00 85 c0 74 c9 8b 05 28 6a 5a 01 [ 22.620842] RSP: 0018:ffffa1904133bc48 EFLAGS: 00010286 [ 22.620844] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000001 [ 22.620846] RDX: 0000000080000001 RSI: ffffffff94e82606 RDI: 00000000ffffffff [ 22.620847] RBP: ffff8eb4449eac00 R08: 0000001af4246984 R09: 00000000000003f1 [ 22.620849] R10: ffffffff955f7700 R11: 0000000000000000 R12: ffff8eb4449eacac [ 22.620850] R13: ffff8eb4565da800 R14: ffff8eb453ca2000 R15: 0000000000000003 [ 22.620852] FS: 00007f0944d69000(0000) GS:ffff8eb45ecc0000(0000) knlGS:0000000000000000 [ 22.620853] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 22.620854] CR2: 00007ffe20518fa8 CR3: 0000000207844000 CR4: 00000000003406e0 [ 22.620855] Call Trace: [ 22.620859] _raw_spin_unlock+0x16/0x30 [ 22.620862] sch_direct_xmit+0x178/0x340 [ 22.620866] __dev_queue_xmit+0x2f6/0x910 [ 22.620870] packet_sendmsg+0x948/0x15a7 [ 22.620873] ? attach_to_pi_owner+0x38/0x180 [ 22.620877] sock_sendmsg+0x33/0x40 [ 22.620880] __sys_sendto+0xee/0x160 [ 22.620885] ? memzero_explicit+0xa/0x10 [ 22.620887] ? urandom_read+0x120/0x270 [ 22.620891] __x64_sys_sendto+0x24/0x30 [ 22.620893] do_syscall_64+0x5b/0x170 [ 22.620896] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 22.620898] RIP: 0033:0x7f0942790c12 [ 22.620899] Code: 48 83 ec 18 44 89 4c 24 08 e8 9a f5 ff ff 44 8b 4c 24 08 4d 89 f8 45 89 f2 89 c5 4c 89 ea 4c 89 e6 89 df b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 3a 89 ef 48 89 44 24 08 e8 ca f5 ff ff 48 8b [ 22.620925] RSP: 002b:00007ffe2051be30 EFLAGS: 00000293 ORIG_RAX: 000000000000002c [ 22.620928] RAX: ffffffffffffffda RBX: 0000000000000011 RCX: 00007f0942790c12 [ 22.620929] RDX: 0000000000000148 RSI: 0000559278761700 RDI: 0000000000000011 [ 22.620930] RBP: 0000000000000000 R08: 00005592787aa860 R09: 0000000000000014 [ 22.620931] R10: 0000000000000000 R11: 0000000000000293 R12: 0000559278761700 [ 22.620933] R13: 0000000000000148 R14: 0000000000000000 R15: 00005592787aa860 [ 22.620936] ---[ end trace ecf9299fa6cc3176 ]--- [ 22.620940] BUG: using __this_cpu_read() in preemptible [00000000] code: NetworkManager/489 [ 22.620942] caller is __local_bh_enable_ip+0x50/0x80 [ 22.620945] CPU: 3 PID: 489 Comm: NetworkManager Tainted: G WC 4.18.0-rc7-staging+ #14 [ 22.620946] Hardware name: Gigabyte Technology Co., Ltd. A320M-S2H/A320M-S2H-CF, BIOS F23d 04/17/2018 [ 22.620947] Call Trace: [ 22.620950] dump_stack+0x5c/0x80 [ 22.620955] check_preemption_disabled.cold.0+0x46/0x51 [ 22.620958] __local_bh_enable_ip+0x50/0x80 [ 22.620961] __dev_queue_xmit+0x450/0x910 [ 22.620964] packet_sendmsg+0x948/0x15a7 [ 22.620967] ? attach_to_pi_owner+0x38/0x180 [ 22.620971] sock_sendmsg+0x33/0x40 [ 22.620973] __sys_sendto+0xee/0x160 [ 22.620976] ? memzero_explicit+0xa/0x10 [ 22.620978] ? urandom_read+0x120/0x270 [ 22.620982] __x64_sys_sendto+0x24/0x30 [ 22.620984] do_syscall_64+0x5b/0x170 [ 22.620986] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 22.620990] RIP: 0033:0x7f0942790c12 [ 22.620991] Code: 48 83 ec 18 44 89 4c 24 08 e8 9a f5 ff ff 44 8b 4c 24 08 4d 89 f8 45 89 f2 89 c5 4c 89 ea 4c 89 e6 89 df b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 3a 89 ef 48 89 44 24 08 e8 ca f5 ff ff 48 8b [ 22.621017] RSP: 002b:00007ffe2051be30 EFLAGS: 00000293 ORIG_RAX: 000000000000002c [ 22.621020] RAX: ffffffffffffffda RBX: 0000000000000011 RCX: 00007f0942790c12 [ 22.621021] RDX: 0000000000000148 RSI: 0000559278761700 RDI: 0000000000000011 [ 22.621024] RBP: 0000000000000000 R08: 00005592787aa860 R09: 0000000000000014 [ 22.621025] R10: 0000000000000000 R11: 0000000000000293 R12: 0000559278761700 [ 22.621026] R13: 0000000000000148 R14: 0000000000000000 R15: 00005592787aa860 Revert the commit fixes the issues and dmesg looks good again. Fixes: 515ce733e86e ("staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames") Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 786 ++++++++++++++++-- 1 file changed, 710 insertions(+), 76 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index da5f308f9e30..2a48b09ea9ae 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -727,22 +727,510 @@ exit: return res; } -u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) +/* 3 ===== AES related ===== */ + + +#define MAX_MSG_SIZE 2048 +/*****************************/ +/******** SBOX Table *********/ +/*****************************/ + +static u8 sbox_table[256] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, + 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, + 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, + 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, + 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, + 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, + 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, + 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, + 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, + 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, + 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, + 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, + 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, + 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, + 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, + 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, + 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 +}; + +/*****************************/ +/**** Function Prototypes ****/ +/*****************************/ + +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out); +static void construct_mic_iv(u8 *mic_header1, int qc_exists, int a4_exists, u8 *mpdu, uint payload_length, u8 *pn_vector); +static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu); +static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists); +static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c); +static void xor_128(u8 *a, u8 *b, u8 *out); +static void xor_32(u8 *a, u8 *b, u8 *out); +static u8 sbox(u8 a); +static void next_key(u8 *key, int round); +static void byte_sub(u8 *in, u8 *out); +static void shift_row(u8 *in, u8 *out); +static void mix_column(u8 *in, u8 *out); +static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext); + +/****************************************/ +/* aes128k128d() */ +/* Performs a 128 bit AES encrypt with */ +/* 128 bit data. */ +/****************************************/ +static void xor_128(u8 *a, u8 *b, u8 *out) { + int i; + + for (i = 0; i < 16; i++) + out[i] = a[i] ^ b[i]; +} + +static void xor_32(u8 *a, u8 *b, u8 *out) +{ + int i; + + for (i = 0; i < 4; i++) + out[i] = a[i] ^ b[i]; +} + +static u8 sbox(u8 a) +{ + return sbox_table[(int)a]; +} + +static void next_key(u8 *key, int round) +{ + u8 rcon; + u8 sbox_key[4]; + u8 rcon_table[12] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x1b, 0x36, 0x36, 0x36 + }; + + sbox_key[0] = sbox(key[13]); + sbox_key[1] = sbox(key[14]); + sbox_key[2] = sbox(key[15]); + sbox_key[3] = sbox(key[12]); + + rcon = rcon_table[round]; + + xor_32(&key[0], sbox_key, &key[0]); + key[0] = key[0] ^ rcon; + + xor_32(&key[4], &key[0], &key[4]); + xor_32(&key[8], &key[4], &key[8]); + xor_32(&key[12], &key[8], &key[12]); +} + +static void byte_sub(u8 *in, u8 *out) +{ + int i; + for (i = 0; i < 16; i++) + out[i] = sbox(in[i]); +} + +static void shift_row(u8 *in, u8 *out) +{ + out[0] = in[0]; + out[1] = in[5]; + out[2] = in[10]; + out[3] = in[15]; + out[4] = in[4]; + out[5] = in[9]; + out[6] = in[14]; + out[7] = in[3]; + out[8] = in[8]; + out[9] = in[13]; + out[10] = in[2]; + out[11] = in[7]; + out[12] = in[12]; + out[13] = in[1]; + out[14] = in[6]; + out[15] = in[11]; +} + +static void mix_column(u8 *in, u8 *out) +{ + int i; + u8 add1b[4]; + u8 add1bf7[4]; + u8 rotl[4]; + u8 swap_halves[4]; + u8 andf7[4]; + u8 rotr[4]; + u8 temp[4]; + u8 tempb[4]; + + for (i = 0 ; i < 4; i++) { + if ((in[i] & 0x80) == 0x80) + add1b[i] = 0x1b; + else + add1b[i] = 0x00; + } + + swap_halves[0] = in[2]; /* Swap halves */ + swap_halves[1] = in[3]; + swap_halves[2] = in[0]; + swap_halves[3] = in[1]; + + rotl[0] = in[3]; /* Rotate left 8 bits */ + rotl[1] = in[0]; + rotl[2] = in[1]; + rotl[3] = in[2]; + + andf7[0] = in[0] & 0x7f; + andf7[1] = in[1] & 0x7f; + andf7[2] = in[2] & 0x7f; + andf7[3] = in[3] & 0x7f; + + for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ + andf7[i] = andf7[i] << 1; + if ((andf7[i-1] & 0x80) == 0x80) + andf7[i] = (andf7[i] | 0x01); + } + andf7[0] = andf7[0] << 1; + andf7[0] = andf7[0] & 0xfe; + + xor_32(add1b, andf7, add1bf7); + + xor_32(in, add1bf7, rotr); + + temp[0] = rotr[0]; /* Rotate right 8 bits */ + rotr[0] = rotr[1]; + rotr[1] = rotr[2]; + rotr[2] = rotr[3]; + rotr[3] = temp[0]; + + xor_32(add1bf7, rotr, temp); + xor_32(swap_halves, rotl, tempb); + xor_32(temp, tempb, out); +} + +static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) +{ + int round; + int i; + u8 intermediatea[16]; + u8 intermediateb[16]; + u8 round_key[16]; + + for (i = 0; i < 16; i++) + round_key[i] = key[i]; + for (round = 0; round < 11; round++) { + if (round == 0) { + xor_128(round_key, data, ciphertext); + next_key(round_key, round); + } else if (round == 10) { + byte_sub(ciphertext, intermediatea); + shift_row(intermediatea, intermediateb); + xor_128(intermediateb, round_key, ciphertext); + } else { /* 1 - 9 */ + byte_sub(ciphertext, intermediatea); + shift_row(intermediatea, intermediateb); + mix_column(&intermediateb[0], &intermediatea[0]); + mix_column(&intermediateb[4], &intermediatea[4]); + mix_column(&intermediateb[8], &intermediatea[8]); + mix_column(&intermediateb[12], &intermediatea[12]); + xor_128(intermediatea, round_key, ciphertext); + next_key(round_key, round); + } + } +} + +/************************************************/ +/* construct_mic_iv() */ +/* Builds the MIC IV from header fields and PN */ +/************************************************/ +static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, + uint payload_length, u8 *pn_vector) +{ + int i; + + mic_iv[0] = 0x59; + if (qc_exists && a4_exists) + mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ + if (qc_exists && !a4_exists) + mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */ + if (!qc_exists) + mic_iv[1] = 0x00; + for (i = 2; i < 8; i++) + mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ + for (i = 8; i < 14; i++) + mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ + mic_iv[14] = (unsigned char)(payload_length / 256); + mic_iv[15] = (unsigned char)(payload_length % 256); +} + +/************************************************/ +/* construct_mic_header1() */ +/* Builds the first MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu) +{ + mic_header1[0] = (u8)((header_length - 2) / 256); + mic_header1[1] = (u8)((header_length - 2) % 256); + mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ + mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */ + mic_header1[4] = mpdu[4]; /* A1 */ + mic_header1[5] = mpdu[5]; + mic_header1[6] = mpdu[6]; + mic_header1[7] = mpdu[7]; + mic_header1[8] = mpdu[8]; + mic_header1[9] = mpdu[9]; + mic_header1[10] = mpdu[10]; /* A2 */ + mic_header1[11] = mpdu[11]; + mic_header1[12] = mpdu[12]; + mic_header1[13] = mpdu[13]; + mic_header1[14] = mpdu[14]; + mic_header1[15] = mpdu[15]; +} + +/************************************************/ +/* construct_mic_header2() */ +/* Builds the last MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists) +{ + int i; + + for (i = 0; i < 16; i++) + mic_header2[i] = 0x00; + + mic_header2[0] = mpdu[16]; /* A3 */ + mic_header2[1] = mpdu[17]; + mic_header2[2] = mpdu[18]; + mic_header2[3] = mpdu[19]; + mic_header2[4] = mpdu[20]; + mic_header2[5] = mpdu[21]; + + mic_header2[6] = 0x00; + mic_header2[7] = 0x00; /* mpdu[23]; */ + + if (!qc_exists && a4_exists) { + for (i = 0; i < 6; i++) + mic_header2[8+i] = mpdu[24+i]; /* A4 */ + } + + if (qc_exists && !a4_exists) { + mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */ + mic_header2[9] = mpdu[25] & 0x00; + } + + if (qc_exists && a4_exists) { + for (i = 0; i < 6; i++) + mic_header2[8+i] = mpdu[24+i]; /* A4 */ + + mic_header2[14] = mpdu[30] & 0x0f; + mic_header2[15] = mpdu[31] & 0x00; + } +} + +/************************************************/ +/* construct_mic_header2() */ +/* Builds the last MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c) +{ + int i; + + for (i = 0; i < 16; i++) + ctr_preload[i] = 0x00; + i = 0; + + ctr_preload[0] = 0x01; /* flag */ + if (qc_exists && a4_exists) + ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */ + if (qc_exists && !a4_exists) + ctr_preload[1] = mpdu[24] & 0x0f; + + for (i = 2; i < 8; i++) + ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ + for (i = 8; i < 14; i++) + ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ + ctr_preload[14] = (unsigned char)(c / 256); /* Ctr */ + ctr_preload[15] = (unsigned char)(c % 256); +} + +/************************************/ +/* bitwise_xor() */ +/* A 128 bit, bitwise exclusive or */ +/************************************/ +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) +{ + int i; + + for (i = 0; i < 16; i++) + out[i] = ina[i] ^ inb[i]; +} + +static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) +{ + uint qc_exists, a4_exists, i, j, payload_remainder, + num_blocks, payload_index; + + u8 pn_vector[6]; + u8 mic_iv[16]; + u8 mic_header1[16]; + u8 mic_header2[16]; + u8 ctr_preload[16]; + + /* Intermediate Buffers */ + u8 chain_buffer[16]; + u8 aes_out[16]; + u8 padded_buffer[16]; + u8 mic[8]; + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); + + frsubtype >>= 4; + + memset(mic_iv, 0, 16); + memset(mic_header1, 0, 16); + memset(mic_header2, 0, 16); + memset(ctr_preload, 0, 16); + memset(chain_buffer, 0, 16); + memset(aes_out, 0, 16); + memset(padded_buffer, 0, 16); + + if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) + a4_exists = 0; + else + a4_exists = 1; + + if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) || (frtype == WIFI_DATA_CFACKPOLL)) { + qc_exists = 1; + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + } else if ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) || (frsubtype == 0x0b)) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + qc_exists = 1; + } else { + qc_exists = 0; + } + + pn_vector[0] = pframe[hdrlen]; + pn_vector[1] = pframe[hdrlen+1]; + pn_vector[2] = pframe[hdrlen+4]; + pn_vector[3] = pframe[hdrlen+5]; + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + + construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector); + + construct_mic_header1(mic_header1, hdrlen, pframe); + construct_mic_header2(mic_header2, pframe, a4_exists, qc_exists); + + payload_remainder = plen % 16; + num_blocks = plen / 16; + + /* Find start of payload */ + payload_index = hdrlen + 8; + + /* Calculate MIC */ + aes128k128d(key, mic_iv, aes_out); + bitwise_xor(aes_out, mic_header1, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + bitwise_xor(aes_out, mic_header2, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + + for (i = 0; i < num_blocks; i++) { + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ + + payload_index += 16; + aes128k128d(key, chain_buffer, aes_out); + } + + /* Add on the final payload block if it needs padding */ + if (payload_remainder > 0) { + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */ + bitwise_xor(aes_out, padded_buffer, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + } + + for (j = 0; j < 8; j++) + mic[j] = aes_out[j]; + + /* Insert MIC into payload */ + for (j = 0; j < 8; j++) + pframe[payload_index+j] = mic[j]; + + payload_index = hdrlen + 8; + for (i = 0; i < num_blocks; i++) { + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); + for (j = 0; j < 16; j++) + pframe[payload_index++] = chain_buffer[j]; + } + + if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ + /* encrypt it and copy the unpadded part back */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index+j]; + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < payload_remainder; j++) + pframe[payload_index++] = chain_buffer[j]; + } + /* Encrypt the MIC */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, 0); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < 8; j++) + padded_buffer[j] = pframe[j+hdrlen+8+plen]; + + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < 8; j++) + pframe[payload_index++] = chain_buffer[j]; + return _SUCCESS; +} + +u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) +{ /* exclude ICV */ + + /*static*/ +/* unsigned char message[MAX_MSG_SIZE]; */ + + /* Intermediate Buffers */ int curfragnum, length; - u8 *pframe; /* *payload,*iv */ + u8 *pframe, *prwskey; /* *payload,*iv */ u8 hw_hdr_offset = 0; struct sta_info *stainfo; struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + +/* uint offset = 0; */ u32 res = _SUCCESS; - void *crypto_private; - struct sk_buff *skb; - struct lib80211_crypto_ops *crypto_ops; - const int key_idx = IS_MCAST(pattrib->ra) ? psecuritypriv->dot118021XGrpKeyid : 0; - const int key_length = 16; - u8 *key; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -753,81 +1241,40 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt != _AES_) - return res; - - if (pattrib->psta) - stainfo = pattrib->psta; - else - stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - - if (!stainfo) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); - return _FAIL; - } - - crypto_ops = try_then_request_module(lib80211_get_crypto_ops("CCMP"), "lib80211_crypt_ccmp"); - - if (IS_MCAST(pattrib->ra)) - key = psecuritypriv->dot118021XGrpKey[key_idx].skey; - else - key = stainfo->dot118021x_UncstKey.skey; - - if (!crypto_ops) { - res = _FAIL; - goto exit; - } - - crypto_private = crypto_ops->init(key_idx); - if (!crypto_private) { - res = _FAIL; - goto exit; - } - - if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) { - res = _FAIL; - goto exit_crypto_ops_deinit; - } - - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); - - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if ((curfragnum+1) == pattrib->nr_frags) - length = pattrib->last_txcmdsz; + if (pattrib->encrypt == _AES_) { + if (pattrib->psta) + stainfo = pattrib->psta; else - length = pxmitpriv->frag_len; + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - skb = dev_alloc_skb(length); - if (!skb) { + if (stainfo) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); + + if (IS_MCAST(pattrib->ra)) + prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); + } else{ + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); + pframe += pxmitpriv->frag_len; + pframe = (u8 *)round_up((size_t)(pframe), 8); + } + } + } else{ + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); res = _FAIL; - goto exit_crypto_ops_deinit; } - - skb_put_data(skb, pframe, length); - - memmove(skb->data + pattrib->iv_len, skb->data, pattrib->hdrlen); - skb_pull(skb, pattrib->iv_len); - skb_trim(skb, skb->len - pattrib->icv_len); - - if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, crypto_private)) { - kfree_skb(skb); - res = _FAIL; - goto exit_crypto_ops_deinit; - } - - memcpy(pframe, skb->data, skb->len); - - pframe += skb->len; - pframe = (u8 *)round_up((size_t)(pframe), 8); - - kfree_skb(skb); } -exit_crypto_ops_deinit: - crypto_ops->deinit(crypto_private); -exit: - return res; + return res; } u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) @@ -903,3 +1350,190 @@ exit_lib80211_ccmp: exit: return res; } + +/* AES tables*/ +const u32 Te0[256] = { + 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, + 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, + 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, + 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, + 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, + 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, + 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, + 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, + 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, + 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, + 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, + 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, + 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, + 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, + 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, + 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, + 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, + 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, + 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, + 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, + 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, + 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, + 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, + 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, + 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, + 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, + 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, + 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, + 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, + 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, + 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, + 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, + 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, + 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, + 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, + 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, + 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, + 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, + 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, + 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, + 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, + 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, + 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, + 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, + 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, + 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, + 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, + 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, + 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, + 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, + 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, + 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, + 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, + 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, + 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, + 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, + 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, + 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, + 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, + 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, + 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, + 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, + 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, + 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, +}; + +const u32 Td0[256] = { + 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, + 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, + 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, + 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, + 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, + 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, + 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, + 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, + 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, + 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, + 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, + 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, + 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, + 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, + 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, + 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, + 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, + 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, + 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, + 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, + 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, + 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, + 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, + 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, + 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, + 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, + 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, + 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, + 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, + 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, + 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, + 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, + 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, + 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, + 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, + 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, + 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, + 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, + 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, + 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, + 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, + 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, + 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, + 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, + 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, + 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, + 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, + 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, + 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, + 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, + 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, + 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, + 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, + 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, + 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, + 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, + 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, + 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, + 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, + 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, + 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, + 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, + 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, + 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, +}; + +const u8 Td4s[256] = { + 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, + 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, + 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U, + 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU, + 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU, + 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU, + 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U, + 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U, + 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U, + 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U, + 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU, + 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U, + 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU, + 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U, + 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U, + 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU, + 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU, + 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U, + 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U, + 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU, + 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U, + 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU, + 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U, + 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U, + 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U, + 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU, + 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU, + 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU, + 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U, + 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U, + 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, + 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, +}; +const u8 rcons[] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 + /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ +}; + +/** + * Expand the cipher key into the encryption key schedule. + * + * @return the number of rounds for the given cipher key size. + */ +#define ROUND(i, d, s) \ +do { \ + d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \ + d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \ + d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \ + d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \ +} while (0) From 8571c62d45cb7e9fdff87fe5132002d17fbce7a3 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:26:54 +0200 Subject: [PATCH 868/903] staging: mt7621-pci: use generic kernel pci subsystem read and write map_bus callback is called before every .read/.write operation. Implement it and change custom read write operations for the pci subsystem generics. Make the probe function to don't use legacy stuff and request bus resources directly. Get pci register base and ranges from device tree. The driver is not using PCI_LEGACY code anymore and shall use the PCI_DRIVERS_GENERIC option to correct compile it. Add also new Kconfig file for this controller setting there its correct dependencies. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/mt7621-pci/Kconfig | 7 + drivers/staging/mt7621-pci/pci-mt7621.c | 226 ++++++++++++++++++++++-- 3 files changed, 218 insertions(+), 17 deletions(-) create mode 100644 drivers/staging/mt7621-pci/Kconfig diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 2bce6473318d..732b63182d27 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -110,6 +110,8 @@ source "drivers/staging/vboxvideo/Kconfig" source "drivers/staging/pi433/Kconfig" +source "drivers/staging/mt7621-pci/Kconfig" + source "drivers/staging/mt7621-pinctrl/Kconfig" source "drivers/staging/mt7621-spi/Kconfig" diff --git a/drivers/staging/mt7621-pci/Kconfig b/drivers/staging/mt7621-pci/Kconfig new file mode 100644 index 000000000000..d33533872a16 --- /dev/null +++ b/drivers/staging/mt7621-pci/Kconfig @@ -0,0 +1,7 @@ +config PCI_MT7621 + tristate "MediaTek MT7621 PCI Controller" + depends on RALINK + select PCI_DRIVERS_GENERIC + help + This selects a driver for the MediaTek MT7621 PCI Controller. + diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 650e49b995e3..12702917bbaa 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -53,11 +53,16 @@ #include #include #include +#include +#include +#include #include #include #include +#include "../../pci/pci.h" + /* * These functions and structures provide the BIOS scan and mapping of the PCI * devices. @@ -178,6 +183,43 @@ static int pcie_link_status = 0; #define PCI_ACCESS_WRITE_2 4 #define PCI_ACCESS_WRITE_4 5 +/** + * struct mt7621_pcie_port - PCIe port information + * @base: IO mapped register base + * @list: port list + * @pcie: pointer to PCIe host info + * @reset: pointer to port reset control + */ +struct mt7621_pcie_port { + void __iomem *base; + struct list_head list; + struct mt7621_pcie *pcie; + struct reset_control *reset; +}; + +/** + * struct mt7621_pcie - PCIe host information + * @base: IO Mapped Register Base + * @io: IO resource + * @mem: non-prefetchable memory resource + * @busn: bus range + * @offset: IO / Memory offset + * @dev: Pointer to PCIe device + * @ports: pointer to PCIe port information + */ +struct mt7621_pcie { + void __iomem *base; + struct device *dev; + struct resource io; + struct resource mem; + struct resource busn; + struct { + resource_size_t mem; + resource_size_t io; + } offset; + struct list_head ports; +}; + static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot, unsigned int func, unsigned int where) { @@ -297,17 +339,22 @@ pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u } } -struct pci_ops mt7621_pci_ops = { - .read = pci_config_read, - .write = pci_config_write, -}; +static void __iomem *mt7621_pcie_map_bus(struct pci_bus *bus, + unsigned int devfn, int where) +{ + struct mt7621_pcie *pcie = bus->sysdata; + u32 address = mt7621_pci_get_cfgaddr(bus->number, PCI_SLOT(devfn), + PCI_FUNC(devfn), where); -static struct resource mt7621_res_pci_mem1; -static struct resource mt7621_res_pci_io1; -static struct pci_controller mt7621_controller = { - .pci_ops = &mt7621_pci_ops, - .mem_resource = &mt7621_res_pci_mem1, - .io_resource = &mt7621_res_pci_io1, + writel(address, pcie->base + RALINK_PCI_CONFIG_ADDR); + + return pcie->base + RALINK_PCI_CONFIG_DATA_VIRTUAL_REG + (where & 3); +} + +struct pci_ops mt7621_pci_ops = { + .map_bus = mt7621_pcie_map_bus, + .read = pci_generic_config_read, + .write = pci_generic_config_write, }; static void @@ -463,9 +510,10 @@ set_phy_for_ssc(void) set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control } -void setup_cm_memory_region(struct resource *mem_resource) +static void setup_cm_memory_region(struct resource *mem_resource) { resource_size_t mask; + if (mips_cps_numiocu(0)) { /* FIXME: hardware doesn't accept mask values with 1s after * 0s (e.g. 0xffef), so it would be great to warn if that's @@ -480,14 +528,142 @@ void setup_cm_memory_region(struct resource *mem_resource) } } +static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) +{ + struct device *dev = pcie->dev; + struct device_node *node = dev->of_node; + struct of_pci_range_parser parser; + struct of_pci_range range; + int err; + + if (of_pci_range_parser_init(&parser, node)) { + dev_err(dev, "missing \"ranges\" property\n"); + return -EINVAL; + } + + for_each_of_pci_range(&parser, &range) { + struct resource *res = NULL; + + switch (range.flags & IORESOURCE_TYPE_BITS) { + case IORESOURCE_IO: + ioremap(range.cpu_addr, range.size); + res = &pcie->io; + pcie->offset.io = 0x00000000UL; + break; + case IORESOURCE_MEM: + res = &pcie->mem; + pcie->offset.mem = 0x00000000UL; + break; + } + + if (res != NULL) + of_pci_range_to_resource(&range, node, res); + } + + err = of_pci_parse_bus_range(node, &pcie->busn); + if (err < 0) { + dev_err(dev, "failed to parse bus ranges property: %d\n", err); + pcie->busn.name = node->name; + pcie->busn.start = 0; + pcie->busn.end = 0xff; + pcie->busn.flags = IORESOURCE_BUS; + } + + return 0; +} + +static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) +{ + struct device *dev = pcie->dev; + struct device_node *node = dev->of_node; + struct resource regs; + const char *type; + int err; + + type = of_get_property(node, "device_type", NULL); + if (!type || strcmp(type, "pci") != 0) { + dev_err(dev, "invalid \"device_type\" %s\n", type); + return -EINVAL; + } + + err = of_address_to_resource(node, 0, ®s); + if (err) { + dev_err(dev, "missing \"reg\" property\n"); + return err; + } + + pcie->base = devm_ioremap_resource(dev, ®s); + if (IS_ERR(pcie->base)) + return PTR_ERR(pcie->base); + + return 0; +} + +static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, + struct list_head *res) +{ + struct device *dev = pcie->dev; + int err; + + pci_add_resource_offset(res, &pcie->io, pcie->offset.io); + pci_add_resource_offset(res, &pcie->mem, pcie->offset.mem); + pci_add_resource(res, &pcie->busn); + + err = devm_request_pci_bus_resources(dev, res); + if (err < 0) + return err; + + return 0; +} + +static int mt7621_pcie_register_host(struct pci_host_bridge *host, + struct list_head *res) +{ + struct mt7621_pcie *pcie = pci_host_bridge_priv(host); + + list_splice_init(res, &host->windows); + host->busnr = pcie->busn.start; + host->dev.parent = pcie->dev; + host->ops = &mt7621_pci_ops; + host->map_irq = pcibios_map_irq; + host->swizzle_irq = pci_common_swizzle; + host->sysdata = pcie; + + return pci_host_probe(host); +} + static int mt7621_pci_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; + struct mt7621_pcie *pcie; + struct pci_host_bridge *bridge; + int err; unsigned long val = 0; + LIST_HEAD(res); + if (!dev->of_node) + return -ENODEV; + + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); + if (!bridge) + return -ENODEV; + + pcie = pci_host_bridge_priv(bridge); + pcie->dev = dev; + platform_set_drvdata(pdev, pcie); + INIT_LIST_HEAD(&pcie->ports); + + err = mt7621_pcie_parse_dt(pcie); + if (err) { + dev_err(dev, "Parsing DT failed\n"); + return err; + } + + /* set resources limits */ iomem_resource.start = 0; - iomem_resource.end = ~0; + iomem_resource.end = ~0UL; /* no limit */ ioport_resource.start = 0; - ioport_resource.end = ~0; + ioport_resource.end = ~0UL; /* no limit */ val = RALINK_PCIE0_RST; val |= RALINK_PCIE1_RST; @@ -665,11 +841,27 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num write_config(0, 0, 0, 0x70c, val); } - pci_load_of_ranges(&mt7621_controller, pdev->dev.of_node); - setup_cm_memory_region(mt7621_controller.mem_resource); - register_pci_controller(&mt7621_controller); - return 0; + err = mt7621_pci_parse_request_of_pci_ranges(pcie); + if (err) { + dev_err(dev, "Error requesting pci resources from ranges"); + return err; + } + setup_cm_memory_region(&pcie->mem); + + err = mt7621_pcie_request_resources(pcie, &res); + if (err) { + dev_err(dev, "Error requesting resources\n"); + return err; + } + + err = mt7621_pcie_register_host(bridge, &res); + if (err) { + dev_err(dev, "Error registering host\n"); + return err; + } + + return 0; } int pcibios_plat_dev_init(struct pci_dev *dev) From e9d03d17dd94399bbc658394501d41a10ea1ef70 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:26:55 +0200 Subject: [PATCH 869/903] staging: mt7621-pci: remove dead code derived to not use custom reads and writes Driver is using now pci subsystem generics reads and writes and requesting bus resources without using legacy code functions. Because of this there is a lot of dead code that can be removed. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 128 ------------------------ 1 file changed, 128 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 12702917bbaa..68f47147cbdb 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -123,15 +123,6 @@ *(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data) #define MV_READ(ofs, data) \ *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs))) -#define MV_WRITE_16(ofs, data) \ - *(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data) -#define MV_READ_16(ofs, data) \ - *(data) = le16_to_cpu(*(volatile u16 *)(RALINK_PCI_BASE+(ofs))) - -#define MV_WRITE_8(ofs, data) \ - *(volatile u8 *)(RALINK_PCI_BASE+(ofs)) = data -#define MV_READ_8(ofs, data) \ - *(data) = *(volatile u8 *)(RALINK_PCI_BASE+(ofs)) #define RALINK_PCI_MM_MAP_BASE 0x60000000 #define RALINK_PCI_IO_MAP_BASE 0x1e160000 @@ -176,13 +167,6 @@ #define MEMORY_BASE 0x0 static int pcie_link_status = 0; -#define PCI_ACCESS_READ_1 0 -#define PCI_ACCESS_READ_2 1 -#define PCI_ACCESS_READ_4 2 -#define PCI_ACCESS_WRITE_1 3 -#define PCI_ACCESS_WRITE_2 4 -#define PCI_ACCESS_WRITE_4 5 - /** * struct mt7621_pcie_port - PCIe port information * @base: IO mapped register base @@ -227,118 +211,6 @@ static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot, (func << 8) | (where & 0xfc) | 0x80000000; } -static int config_access(unsigned char access_type, struct pci_bus *bus, - unsigned int devfn, unsigned int where, u32 *data) -{ - unsigned int slot = PCI_SLOT(devfn); - u8 func = PCI_FUNC(devfn); - u32 address_reg, data_reg; - unsigned int address; - - address_reg = RALINK_PCI_CONFIG_ADDR; - data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG; - - address = mt7621_pci_get_cfgaddr(bus->number, slot, func, where); - - MV_WRITE(address_reg, address); - - switch (access_type) { - case PCI_ACCESS_WRITE_1: - MV_WRITE_8(data_reg+(where&0x3), *data); - break; - case PCI_ACCESS_WRITE_2: - MV_WRITE_16(data_reg+(where&0x3), *data); - break; - case PCI_ACCESS_WRITE_4: - MV_WRITE(data_reg, *data); - break; - case PCI_ACCESS_READ_1: - MV_READ_8(data_reg+(where&0x3), data); - break; - case PCI_ACCESS_READ_2: - MV_READ_16(data_reg+(where&0x3), data); - break; - case PCI_ACCESS_READ_4: - MV_READ(data_reg, data); - break; - default: - printk("no specify access type\n"); - break; - } - return 0; -} - -static int -read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 *val) -{ - return config_access(PCI_ACCESS_READ_1, bus, devfn, (unsigned int)where, (u32 *)val); -} - -static int -read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 *val) -{ - return config_access(PCI_ACCESS_READ_2, bus, devfn, (unsigned int)where, (u32 *)val); -} - -static int -read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val) -{ - return config_access(PCI_ACCESS_READ_4, bus, devfn, (unsigned int)where, (u32 *)val); -} - -static int -write_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 val) -{ - if (config_access(PCI_ACCESS_WRITE_1, bus, devfn, (unsigned int)where, (u32 *)&val)) - return -1; - - return PCIBIOS_SUCCESSFUL; -} - -static int -write_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 val) -{ - if (config_access(PCI_ACCESS_WRITE_2, bus, devfn, where, (u32 *)&val)) - return -1; - - return PCIBIOS_SUCCESSFUL; -} - -static int -write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val) -{ - if (config_access(PCI_ACCESS_WRITE_4, bus, devfn, where, &val)) - return -1; - - return PCIBIOS_SUCCESSFUL; -} - -static int -pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) -{ - switch (size) { - case 1: - return read_config_byte(bus, devfn, where, (u8 *) val); - case 2: - return read_config_word(bus, devfn, where, (u16 *) val); - default: - return read_config_dword(bus, devfn, where, val); - } -} - -static int -pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) -{ - switch (size) { - case 1: - return write_config_byte(bus, devfn, where, (u8) val); - case 2: - return write_config_word(bus, devfn, where, (u16) val); - default: - return write_config_dword(bus, devfn, where, val); - } -} - static void __iomem *mt7621_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, int where) { From 52ed727ca031ca7a6fcfde55a2902ac4845d736c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:26:56 +0200 Subject: [PATCH 870/903] staging: mt7621-pci: add pcie_write and pcie_read helpers Introdice this functions to make easier to write/read to/from an offset relative to base address Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 68f47147cbdb..fe9c68fbe364 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -204,6 +204,16 @@ struct mt7621_pcie { struct list_head ports; }; +static inline u32 pcie_read(struct mt7621_pcie *pcie, u32 reg) +{ + return readl(pcie->base + reg); +} + +static inline void pcie_write(struct mt7621_pcie *pcie, u32 val, u32 reg) +{ + writel(val, pcie->base + reg); +} + static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot, unsigned int func, unsigned int where) { From 9f999b41502714e7a33f3723f4a3aba85bd0324c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:26:57 +0200 Subject: [PATCH 871/903] staging: mt7621-pci: use pcie_[read|write] in [write|read]_config Instead of custom macros use pcie_read and pcie_write functions. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 63 ++++++++++++------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index fe9c68fbe364..f1abf6c6939d 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -240,41 +240,38 @@ struct pci_ops mt7621_pci_ops = { }; static void -read_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned long reg, unsigned long *val) +read_config(struct mt7621_pcie *pcie, + unsigned long bus, unsigned long dev, + unsigned long func, unsigned long reg, unsigned long *val) { - u32 address_reg, data_reg, address; + u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); - address_reg = RALINK_PCI_CONFIG_ADDR; - data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG; - address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); - MV_WRITE(address_reg, address); - MV_READ(data_reg, val); - return; + pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); + *val = pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG); } static void -write_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned long reg, unsigned long val) +write_config(struct mt7621_pcie *pcie, + unsigned long bus, unsigned long dev, + unsigned long func, unsigned long reg, unsigned long val) { - u32 address_reg, data_reg, address; + u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); - address_reg = RALINK_PCI_CONFIG_ADDR; - data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG; - address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); - MV_WRITE(address_reg, address); - MV_WRITE(data_reg, val); - return; + pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); + pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG); } int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { + struct mt7621_pcie *pcie = dev->bus->sysdata; u16 cmd; u32 val; int irq; if (dev->bus->number == 0) { - write_config(0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); - read_config(0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val); + write_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); + read_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val); printk("BAR0 at slot %d = %x\n", slot, val); } @@ -572,13 +569,13 @@ static int mt7621_pci_probe(struct platform_device *pdev) bypass_pipe_rst(); set_phy_for_ssc(); - read_config(0, 0, 0, 0x70c, &val); + read_config(pcie, 0, 0, 0, 0x70c, &val); printk("Port 0 N_FTS = %x\n", (unsigned int)val); - read_config(0, 1, 0, 0x70c, &val); + read_config(pcie, 0, 1, 0, 0x70c, &val); printk("Port 1 N_FTS = %x\n", (unsigned int)val); - read_config(0, 2, 0, 0x70c, &val); + read_config(pcie, 0, 2, 0, 0x70c, &val); printk("Port 2 N_FTS = %x\n", (unsigned int)val); rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); @@ -699,28 +696,28 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num switch (pcie_link_status) { case 7: - read_config(0, 2, 0, 0x4, &val); - write_config(0, 2, 0, 0x4, val|0x4); - read_config(0, 2, 0, 0x70c, &val); + read_config(pcie, 0, 2, 0, 0x4, &val); + write_config(pcie, 0, 2, 0, 0x4, val|0x4); + read_config(pcie, 0, 2, 0, 0x70c, &val); val &= ~(0xff)<<8; val |= 0x50<<8; - write_config(0, 2, 0, 0x70c, val); + write_config(pcie, 0, 2, 0, 0x70c, val); case 3: case 5: case 6: - read_config(0, 1, 0, 0x4, &val); - write_config(0, 1, 0, 0x4, val|0x4); - read_config(0, 1, 0, 0x70c, &val); + read_config(pcie, 0, 1, 0, 0x4, &val); + write_config(pcie, 0, 1, 0, 0x4, val|0x4); + read_config(pcie, 0, 1, 0, 0x70c, &val); val &= ~(0xff)<<8; val |= 0x50<<8; - write_config(0, 1, 0, 0x70c, val); + write_config(pcie, 0, 1, 0, 0x70c, val); default: - read_config(0, 0, 0, 0x4, &val); - write_config(0, 0, 0, 0x4, val|0x4); //bus master enable - read_config(0, 0, 0, 0x70c, &val); + read_config(pcie, 0, 0, 0, 0x4, &val); + write_config(pcie, 0, 0, 0, 0x4, val|0x4); //bus master enable + read_config(pcie, 0, 0, 0, 0x70c, &val); val &= ~(0xff)<<8; val |= 0x50<<8; - write_config(0, 0, 0, 0x70c, val); + write_config(pcie, 0, 0, 0, 0x70c, val); } err = mt7621_pci_parse_request_of_pci_ranges(pcie); From c0431f4f4aef9a52875d19af3c220e6c8f60d427 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:26:58 +0200 Subject: [PATCH 872/903] staging: mt7621-pci: simplify read_config function read_config function is always called with bus and func being 0. Avoid those params and just use 0 inside the function. Return readed value instead pass a reference parameter. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 32 ++++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index f1abf6c6939d..ad480f2f0b79 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -239,15 +239,13 @@ struct pci_ops mt7621_pci_ops = { .write = pci_generic_config_write, }; -static void -read_config(struct mt7621_pcie *pcie, - unsigned long bus, unsigned long dev, - unsigned long func, unsigned long reg, unsigned long *val) +static u32 +read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg) { - u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); + u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); - *val = pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG); + return pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG); } static void @@ -271,7 +269,7 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) if (dev->bus->number == 0) { write_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); - read_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val); + val = read_config(pcie, slot, PCI_BASE_ADDRESS_0); printk("BAR0 at slot %d = %x\n", slot, val); } @@ -517,7 +515,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) struct mt7621_pcie *pcie; struct pci_host_bridge *bridge; int err; - unsigned long val = 0; + u32 val = 0; LIST_HEAD(res); if (!dev->of_node) @@ -569,13 +567,13 @@ static int mt7621_pci_probe(struct platform_device *pdev) bypass_pipe_rst(); set_phy_for_ssc(); - read_config(pcie, 0, 0, 0, 0x70c, &val); + val = read_config(pcie, 0, 0x70c); printk("Port 0 N_FTS = %x\n", (unsigned int)val); - read_config(pcie, 0, 1, 0, 0x70c, &val); + val = read_config(pcie, 1, 0x70c); printk("Port 1 N_FTS = %x\n", (unsigned int)val); - read_config(pcie, 0, 2, 0, 0x70c, &val); + val = read_config(pcie, 2, 0x70c); printk("Port 2 N_FTS = %x\n", (unsigned int)val); rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); @@ -696,25 +694,25 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num switch (pcie_link_status) { case 7: - read_config(pcie, 0, 2, 0, 0x4, &val); + val = read_config(pcie, 2, 0x4); write_config(pcie, 0, 2, 0, 0x4, val|0x4); - read_config(pcie, 0, 2, 0, 0x70c, &val); + val = read_config(pcie, 2, 0x70c); val &= ~(0xff)<<8; val |= 0x50<<8; write_config(pcie, 0, 2, 0, 0x70c, val); case 3: case 5: case 6: - read_config(pcie, 0, 1, 0, 0x4, &val); + val = read_config(pcie, 1, 0x4); write_config(pcie, 0, 1, 0, 0x4, val|0x4); - read_config(pcie, 0, 1, 0, 0x70c, &val); + val = read_config(pcie, 1, 0x70c); val &= ~(0xff)<<8; val |= 0x50<<8; write_config(pcie, 0, 1, 0, 0x70c, val); default: - read_config(pcie, 0, 0, 0, 0x4, &val); + val = read_config(pcie, 0, 0x4); write_config(pcie, 0, 0, 0, 0x4, val|0x4); //bus master enable - read_config(pcie, 0, 0, 0, 0x70c, &val); + val = read_config(pcie, 0, 0x70c); val &= ~(0xff)<<8; val |= 0x50<<8; write_config(pcie, 0, 0, 0, 0x70c, val); From f8427fae570988deb5a78514ae6d70be1af0d358 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:26:59 +0200 Subject: [PATCH 873/903] staging: mt7621-pci: simplify write_config function write_config function is always called with bus and func being 0. Avoid those params and just use 0 inside the function. Review parameter types changing for more proper ones. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index ad480f2f0b79..3b45c592d10f 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -249,11 +249,9 @@ read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg) } static void -write_config(struct mt7621_pcie *pcie, - unsigned long bus, unsigned long dev, - unsigned long func, unsigned long reg, unsigned long val) +write_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg, u32 val) { - u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg); + u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG); @@ -268,7 +266,7 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) int irq; if (dev->bus->number == 0) { - write_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); + write_config(pcie, slot, PCI_BASE_ADDRESS_0, MEMORY_BASE); val = read_config(pcie, slot, PCI_BASE_ADDRESS_0); printk("BAR0 at slot %d = %x\n", slot, val); } @@ -695,27 +693,27 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num switch (pcie_link_status) { case 7: val = read_config(pcie, 2, 0x4); - write_config(pcie, 0, 2, 0, 0x4, val|0x4); + write_config(pcie, 2, 0x4, val|0x4); val = read_config(pcie, 2, 0x70c); val &= ~(0xff)<<8; val |= 0x50<<8; - write_config(pcie, 0, 2, 0, 0x70c, val); + write_config(pcie, 2, 0x70c, val); case 3: case 5: case 6: val = read_config(pcie, 1, 0x4); - write_config(pcie, 0, 1, 0, 0x4, val|0x4); + write_config(pcie, 1, 0x4, val|0x4); val = read_config(pcie, 1, 0x70c); val &= ~(0xff)<<8; val |= 0x50<<8; - write_config(pcie, 0, 1, 0, 0x70c, val); + write_config(pcie, 1, 0x70c, val); default: val = read_config(pcie, 0, 0x4); - write_config(pcie, 0, 0, 0, 0x4, val|0x4); //bus master enable + write_config(pcie, 0, 0x4, val|0x4); //bus master enable val = read_config(pcie, 0, 0x70c); val &= ~(0xff)<<8; val |= 0x50<<8; - write_config(pcie, 0, 0, 0, 0x70c, val); + write_config(pcie, 0, 0x70c, val); } err = mt7621_pci_parse_request_of_pci_ranges(pcie); From edec14020e3fcfb0a86bfa9f1d512b922697890f Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:00 +0200 Subject: [PATCH 874/903] staging: mt7621-pci: remove unused macros There some macros that are not being used. Remove them. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 3b45c592d10f..4200c68eb65e 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -84,7 +84,6 @@ #define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x000C) #define RALINK_PCI_BASE 0xBE140000 -#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000) #define RT6855_PCIE0_OFFSET 0x2000 #define RT6855_PCIE1_OFFSET 0x3000 #define RT6855_PCIE2_OFFSET 0x4000 @@ -95,8 +94,6 @@ #define RALINK_PCI0_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0034) #define RALINK_PCI0_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0038) #define RALINK_PCI0_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0050) -#define RALINK_PCI0_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0060) -#define RALINK_PCI0_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0064) #define RALINK_PCI1_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0010) #define RALINK_PCI1_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0018) @@ -104,8 +101,6 @@ #define RALINK_PCI1_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0034) #define RALINK_PCI1_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0038) #define RALINK_PCI1_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0050) -#define RALINK_PCI1_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0060) -#define RALINK_PCI1_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0064) #define RALINK_PCI2_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0010) #define RALINK_PCI2_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0018) @@ -113,17 +108,10 @@ #define RALINK_PCI2_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0034) #define RALINK_PCI2_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0038) #define RALINK_PCI2_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0050) -#define RALINK_PCI2_DERR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0060) -#define RALINK_PCI2_ECRC *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0064) #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000) #define RALINK_PCIEPHY_P2_CTL_OFFSET (RALINK_PCI_BASE + 0xA000) -#define MV_WRITE(ofs, data) \ - *(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data) -#define MV_READ(ofs, data) \ - *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs))) - #define RALINK_PCI_MM_MAP_BASE 0x60000000 #define RALINK_PCI_IO_MAP_BASE 0x1e160000 @@ -141,28 +129,18 @@ else \ rt_sysc_m32(0, val, RALINK_RSTCTRL); \ } while (0) + #define RALINK_CLKCFG1 0x30 #define RALINK_RSTCTRL 0x34 #define RALINK_GPIOMODE 0x60 #define RALINK_PCIE_CLK_GEN 0x7c #define RALINK_PCIE_CLK_GEN1 0x80 -#define PPLL_CFG1 0x9c -#define PPLL_DRV 0xa0 -/* SYSC_REG_SYSTEM_CONFIG1 bits */ -#define RALINK_PCI_HOST_MODE_EN (1<<7) -#define RALINK_PCIE_RC_MODE_EN (1<<8) //RALINK_RSTCTRL bit #define RALINK_PCIE_RST (1<<23) #define RALINK_PCI_RST (1<<24) //RALINK_CLKCFG1 bit #define RALINK_PCI_CLK_EN (1<<19) #define RALINK_PCIE_CLK_EN (1<<21) -//RALINK_GPIOMODE bit -#define PCI_SLOTx2 (1<<11) -#define PCI_SLOTx1 (2<<11) -//MTK PCIE PLL bit -#define PDRV_SW_SET (1<<31) -#define LC_CKDRVPD_ (1<<19) #define MEMORY_BASE 0x0 static int pcie_link_status = 0; From e38bb1754003d9a0fba5b59f23c850615664cbe6 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:01 +0200 Subject: [PATCH 875/903] staging: mt7621-pci: avoid register duplication per controller using pcie_[read|write] Use pcie_[read|write] fucntions to read and write controller registers. Define those only by offset and pass controller offset + register offset relative to base address to functions. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 70 ++++++++++++------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 4200c68eb65e..e1245a4297dc 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -74,8 +74,8 @@ #define RALINK_PCI_CONFIG_ADDR 0x20 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24 -#define RALINK_PCI_MEMBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x0028) -#define RALINK_PCI_IOBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x002C) +#define RALINK_PCI_MEMBASE 0x28 +#define RALINK_PCI_IOBASE 0x2C #define RALINK_PCIE0_RST (1<<24) #define RALINK_PCIE1_RST (1<<25) #define RALINK_PCIE2_RST (1<<26) @@ -88,26 +88,12 @@ #define RT6855_PCIE1_OFFSET 0x3000 #define RT6855_PCIE2_OFFSET 0x4000 -#define RALINK_PCI0_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0010) -#define RALINK_PCI0_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0018) -#define RALINK_PCI0_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0030) -#define RALINK_PCI0_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0034) -#define RALINK_PCI0_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0038) -#define RALINK_PCI0_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE0_OFFSET + 0x0050) - -#define RALINK_PCI1_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0010) -#define RALINK_PCI1_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0018) -#define RALINK_PCI1_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0030) -#define RALINK_PCI1_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0034) -#define RALINK_PCI1_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0038) -#define RALINK_PCI1_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE1_OFFSET + 0x0050) - -#define RALINK_PCI2_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0010) -#define RALINK_PCI2_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0018) -#define RALINK_PCI2_ID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0030) -#define RALINK_PCI2_CLASS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0034) -#define RALINK_PCI2_SUBID *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0038) -#define RALINK_PCI2_STATUS *(volatile u32 *)(RALINK_PCI_BASE + RT6855_PCIE2_OFFSET + 0x0050) +#define RALINK_PCI_BAR0SETUP_ADDR 0x0010 +#define RALINK_PCI_IMBASEBAR0_ADDR 0x0018 +#define RALINK_PCI_ID 0x0030 +#define RALINK_PCI_CLASS 0x0034 +#define RALINK_PCI_SUBID 0x0038 +#define RALINK_PCI_STATUS 0x0050 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000) #define RALINK_PCIEPHY_P2_CTL_OFFSET (RALINK_PCI_BASE + 0xA000) @@ -566,7 +552,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) *(unsigned int *)(0xbe000620) |= 0x1<<19 | 0x1<<8 | 0x1<<7; // set DATA mdelay(1000); - if ((RALINK_PCI0_STATUS & 0x1) == 0) { + if ((pcie_read(pcie, RT6855_PCIE0_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { printk("PCIE0 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST); rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1); @@ -576,7 +562,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt } - if ((RALINK_PCI1_STATUS & 0x1) == 0) { + if ((pcie_read(pcie, RT6855_PCIE1_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { printk("PCIE1 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE1_RST); rt_sysc_m32(RALINK_PCIE1_CLK_EN, 0, RALINK_CLKCFG1); @@ -586,7 +572,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) RALINK_PCI_PCIMSK_ADDR |= (1<<21); // enable pcie1 interrupt } - if ((RALINK_PCI2_STATUS & 0x1) == 0) { + if ((pcie_read(pcie, RT6855_PCIE2_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { printk("PCIE2 no card, disable it(RST&CLK)\n"); ASSERT_SYSRST_PCIE(RALINK_PCIE2_RST); rt_sysc_m32(RALINK_PCIE2_CLK_EN, 0, RALINK_CLKCFG1); @@ -641,30 +627,42 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num ioport_resource.end = mt7621_res_pci_io1.end; */ - RALINK_PCI_MEMBASE = 0xffffffff; //RALINK_PCI_MM_MAP_BASE; - RALINK_PCI_IOBASE = RALINK_PCI_IO_MAP_BASE; + pcie_write(pcie, 0xffffffff, RALINK_PCI_MEMBASE); + pcie_write(pcie, RALINK_PCI_IO_MAP_BASE, RALINK_PCI_IOBASE); //PCIe0 if ((pcie_link_status & 0x1) != 0) { - RALINK_PCI0_BAR0SETUP_ADDR = 0x7FFF0001; //open 7FFF:2G; ENABLE - RALINK_PCI0_IMBASEBAR0_ADDR = MEMORY_BASE; - RALINK_PCI0_CLASS = 0x06040001; + /* open 7FFF:2G; ENABLE */ + pcie_write(pcie, 0x7FFF0001, + RT6855_PCIE0_OFFSET + RALINK_PCI_BAR0SETUP_ADDR); + pcie_write(pcie, MEMORY_BASE, + RT6855_PCIE0_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); + pcie_write(pcie, 0x06040001, + RT6855_PCIE0_OFFSET + RALINK_PCI_CLASS); printk("PCIE0 enabled\n"); } //PCIe1 if ((pcie_link_status & 0x2) != 0) { - RALINK_PCI1_BAR0SETUP_ADDR = 0x7FFF0001; //open 7FFF:2G; ENABLE - RALINK_PCI1_IMBASEBAR0_ADDR = MEMORY_BASE; - RALINK_PCI1_CLASS = 0x06040001; + /* open 7FFF:2G; ENABLE */ + pcie_write(pcie, 0x7FFF0001, + RT6855_PCIE1_OFFSET + RALINK_PCI_BAR0SETUP_ADDR); + pcie_write(pcie, MEMORY_BASE, + RT6855_PCIE1_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); + pcie_write(pcie, 0x06040001, + RT6855_PCIE1_OFFSET + RALINK_PCI_CLASS); printk("PCIE1 enabled\n"); } //PCIe2 if ((pcie_link_status & 0x4) != 0) { - RALINK_PCI2_BAR0SETUP_ADDR = 0x7FFF0001; //open 7FFF:2G; ENABLE - RALINK_PCI2_IMBASEBAR0_ADDR = MEMORY_BASE; - RALINK_PCI2_CLASS = 0x06040001; + /* open 7FFF:2G; ENABLE */ + pcie_write(pcie, 0x7FFF0001, + RT6855_PCIE2_OFFSET + RALINK_PCI_BAR0SETUP_ADDR); + pcie_write(pcie, MEMORY_BASE, + RT6855_PCIE2_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); + pcie_write(pcie, 0x06040001, + RT6855_PCIE2_OFFSET + RALINK_PCI_CLASS); printk("PCIE2 enabled\n"); } From cd7d07db8b83cfc88d4ee3a1d5f751cf6af58f13 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:02 +0200 Subject: [PATCH 876/903] staging: mt7621-pci: review includes putting them in alphabethic order There are some includes that are being used that are not really needed to correct driver compilation. Remove them and reorder the rest alphabetically. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index e1245a4297dc..4a20138fb91a 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -40,26 +40,20 @@ ************************************************************************** */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include +#include #include -#include -#include #include #include +#include +#include +#include #include - -#include +#include #include +#include #include "../../pci/pci.h" From 152f3893f4bdcbf2202c08d376b837b62f54a7e4 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:03 +0200 Subject: [PATCH 877/903] staging: mt7621-pci: use pcie_[read|write] in RALINK_PCI_PCICFG_ADDR and RALINK_PCI_PCIMSK_ADDR RALINK_PCI_PCICFG_ADDR and RALINK_PCI_PCIMSK_ADDR are defined to be directly referenced for read and write. Use pcie_read and pcie_write instead changing its definition to a simple relative offset to pcie base address. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 54 ++++++++++++++++--------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 4a20138fb91a..1a301e834455 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -74,8 +74,8 @@ #define RALINK_PCIE1_RST (1<<25) #define RALINK_PCIE2_RST (1<<26) -#define RALINK_PCI_PCICFG_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x0000) -#define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 0x000C) +#define RALINK_PCI_PCICFG_ADDR 0x0000 +#define RALINK_PCI_PCIMSK_ADDR 0x000C #define RALINK_PCI_BASE 0xBE140000 #define RT6855_PCIE0_OFFSET 0x2000 @@ -553,7 +553,9 @@ static int mt7621_pci_probe(struct platform_device *pdev) pcie_link_status &= ~(1<<0); } else { pcie_link_status |= 1<<0; - RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt + val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); + val |= (1<<20); // enable pcie1 interrupt + pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); } if ((pcie_read(pcie, RT6855_PCIE1_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { @@ -563,7 +565,9 @@ static int mt7621_pci_probe(struct platform_device *pdev) pcie_link_status &= ~(1<<1); } else { pcie_link_status |= 1<<1; - RALINK_PCI_PCIMSK_ADDR |= (1<<21); // enable pcie1 interrupt + val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); + val |= (1<<21); // enable pcie1 interrupt + pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); } if ((pcie_read(pcie, RT6855_PCIE2_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { @@ -573,7 +577,9 @@ static int mt7621_pci_probe(struct platform_device *pdev) pcie_link_status &= ~(1<<2); } else { pcie_link_status |= 1<<2; - RALINK_PCI_PCIMSK_ADDR |= (1<<22); // enable pcie2 interrupt + val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); + val |= (1<<22); // enable pcie2 interrupt + pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); } if (pcie_link_status == 0) @@ -592,27 +598,35 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num */ switch (pcie_link_status) { case 2: - RALINK_PCI_PCICFG_ADDR &= ~0x00ff0000; - RALINK_PCI_PCICFG_ADDR |= 0x1 << 16; //port0 - RALINK_PCI_PCICFG_ADDR |= 0x0 << 20; //port1 + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~0x00ff0000; + val |= 0x1 << 16; // port 0 + val |= 0x0 << 20; // port 1 + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); break; case 4: - RALINK_PCI_PCICFG_ADDR &= ~0x0fff0000; - RALINK_PCI_PCICFG_ADDR |= 0x1 << 16; //port0 - RALINK_PCI_PCICFG_ADDR |= 0x2 << 20; //port1 - RALINK_PCI_PCICFG_ADDR |= 0x0 << 24; //port2 + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~0x0fff0000; + val |= 0x1 << 16; //port0 + val |= 0x2 << 20; //port1 + val |= 0x0 << 24; //port2 + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); break; case 5: - RALINK_PCI_PCICFG_ADDR &= ~0x0fff0000; - RALINK_PCI_PCICFG_ADDR |= 0x0 << 16; //port0 - RALINK_PCI_PCICFG_ADDR |= 0x2 << 20; //port1 - RALINK_PCI_PCICFG_ADDR |= 0x1 << 24; //port2 + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~0x0fff0000; + val |= 0x0 << 16; //port0 + val |= 0x2 << 20; //port1 + val |= 0x1 << 24; //port2 + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); break; case 6: - RALINK_PCI_PCICFG_ADDR &= ~0x0fff0000; - RALINK_PCI_PCICFG_ADDR |= 0x2 << 16; //port0 - RALINK_PCI_PCICFG_ADDR |= 0x0 << 20; //port1 - RALINK_PCI_PCICFG_ADDR |= 0x1 << 24; //port2 + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~0x0fff0000; + val |= 0x2 << 16; //port0 + val |= 0x0 << 20; //port1 + val |= 0x1 << 24; //port2 + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); break; } From c00f0352bed0ff03d193a56387eb421e04d9415b Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:04 +0200 Subject: [PATCH 878/903] staging: mt7621-pci: remove RALINK_PCI_BASE from remaining definitions RALINK_PCI_BASE has no sense and this driver has base address readed and mapped from device tree. Remove remaining uses of it and change code to use pcie_read and pcie_write functions in places where this was being used. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 131 ++++++++++++------------ 1 file changed, 67 insertions(+), 64 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 1a301e834455..972a8024a1ae 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -76,7 +76,6 @@ #define RALINK_PCI_PCICFG_ADDR 0x0000 #define RALINK_PCI_PCIMSK_ADDR 0x000C -#define RALINK_PCI_BASE 0xBE140000 #define RT6855_PCIE0_OFFSET 0x2000 #define RT6855_PCIE1_OFFSET 0x3000 @@ -89,8 +88,8 @@ #define RALINK_PCI_SUBID 0x0038 #define RALINK_PCI_STATUS 0x0050 -#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000) -#define RALINK_PCIEPHY_P2_CTL_OFFSET (RALINK_PCI_BASE + 0xA000) +#define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000 +#define RALINK_PCIEPHY_P2_CTL_OFFSET 0xA000 #define RALINK_PCI_MM_MAP_BASE 0x60000000 #define RALINK_PCI_IO_MAP_BASE 0x1e160000 @@ -242,105 +241,109 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) } void -set_pcie_phy(u32 *addr, int start_b, int bits, int val) +set_pcie_phy(struct mt7621_pcie *pcie, u32 offset, + int start_b, int bits, int val) { - *(unsigned int *)(addr) &= ~(((1<> 6) & 0x7; /* Set PCIe Port0 & Port1 PHY to disable SSC */ /* Debug Xtal Type */ - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 1 enable control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x00); // rg_pe1_phy_en //Port 1 disable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 1 enable control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x00); // rg_pe1_phy_en //Port 1 disable if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) printk("***** Xtal 40MHz *****\n"); } else { // 25MHz | 20MHz Xtal - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) if (reg >= 6) { printk("***** Xtal 25MHz *****\n"); - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial } else { printk("***** Xtal 20MHz *****\n"); } } - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv } /* Enable PHY and disable force mode */ - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x01); // rg_pe1_phy_en //Port 1 enable - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 1 disable control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x01); // rg_pe1_phy_en //Port 1 enable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 1 disable control /* Set PCIe Port2 PHY to disable SSC */ /* Debug Xtal Type */ - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) } else { // 25MHz | 20MHz Xtal - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) if (reg >= 6) { // 25MHz Xtal - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial } } - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv } /* Enable PHY and disable force mode */ - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable - set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable + set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control } static void setup_cm_memory_region(struct resource *mem_resource) @@ -520,8 +523,8 @@ static int mt7621_pci_probe(struct platform_device *pdev) DEASSERT_SYSRST_PCIE(val); if ((*(unsigned int *)(0xbe00000c)&0xFFFF) == 0x0101) // MT7621 E2 - bypass_pipe_rst(); - set_phy_for_ssc(); + bypass_pipe_rst(pcie); + set_phy_for_ssc(pcie); val = read_config(pcie, 0, 0x70c); printk("Port 0 N_FTS = %x\n", (unsigned int)val); From 88e8fa0c26ba400ac15fad9cf6461f746ddb3aca Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:05 +0200 Subject: [PATCH 879/903] staging: mt7621-pci: use BIT macro in preprocessor definitions Some preprocessor definitions are using a custom implementation of BIT macro. Just use linux kernel BIT macro instead. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 972a8024a1ae..c288b26db16d 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -62,17 +62,17 @@ * devices. */ -#define RALINK_PCIE0_CLK_EN (1<<24) -#define RALINK_PCIE1_CLK_EN (1<<25) -#define RALINK_PCIE2_CLK_EN (1<<26) +#define RALINK_PCIE0_CLK_EN BIT(24) +#define RALINK_PCIE1_CLK_EN BIT(25) +#define RALINK_PCIE2_CLK_EN BIT(26) #define RALINK_PCI_CONFIG_ADDR 0x20 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24 #define RALINK_PCI_MEMBASE 0x28 #define RALINK_PCI_IOBASE 0x2C -#define RALINK_PCIE0_RST (1<<24) -#define RALINK_PCIE1_RST (1<<25) -#define RALINK_PCIE2_RST (1<<26) +#define RALINK_PCIE0_RST BIT(24) +#define RALINK_PCIE1_RST BIT(25) +#define RALINK_PCIE2_RST BIT(26) #define RALINK_PCI_PCICFG_ADDR 0x0000 #define RALINK_PCI_PCIMSK_ADDR 0x000C @@ -115,11 +115,11 @@ #define RALINK_PCIE_CLK_GEN 0x7c #define RALINK_PCIE_CLK_GEN1 0x80 //RALINK_RSTCTRL bit -#define RALINK_PCIE_RST (1<<23) -#define RALINK_PCI_RST (1<<24) +#define RALINK_PCIE_RST BIT(23) +#define RALINK_PCI_RST BIT(24) //RALINK_CLKCFG1 bit -#define RALINK_PCI_CLK_EN (1<<19) -#define RALINK_PCIE_CLK_EN (1<<21) +#define RALINK_PCI_CLK_EN BIT(19) +#define RALINK_PCIE_CLK_EN BIT(21) #define MEMORY_BASE 0x0 static int pcie_link_status = 0; From 8594351af0f9e065885a6bbcb5248736e8a5612a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:06 +0200 Subject: [PATCH 880/903] staging: mt7621-pci: rename RALINK_PCI_CONFIG_DATA_VIRTUAL_REG definition RALINK_PCI_CONFIG_DATA_VIRTUAL_REG is a very long name. Make it a bit shorter renaming it to RALINK_PCI_CONFIG_DATA. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index c288b26db16d..dd1a72890caf 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -67,7 +67,7 @@ #define RALINK_PCIE2_CLK_EN BIT(26) #define RALINK_PCI_CONFIG_ADDR 0x20 -#define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24 +#define RALINK_PCI_CONFIG_DATA 0x24 #define RALINK_PCI_MEMBASE 0x28 #define RALINK_PCI_IOBASE 0x2C #define RALINK_PCIE0_RST BIT(24) @@ -187,7 +187,7 @@ static void __iomem *mt7621_pcie_map_bus(struct pci_bus *bus, writel(address, pcie->base + RALINK_PCI_CONFIG_ADDR); - return pcie->base + RALINK_PCI_CONFIG_DATA_VIRTUAL_REG + (where & 3); + return pcie->base + RALINK_PCI_CONFIG_DATA + (where & 3); } struct pci_ops mt7621_pci_ops = { @@ -202,7 +202,7 @@ read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg) u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); - return pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG); + return pcie_read(pcie, RALINK_PCI_CONFIG_DATA); } static void @@ -211,7 +211,7 @@ write_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg, u32 val) u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); - pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG); + pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA); } int From 4cafd03a916e2f7c15520fed0b7894cf25f4ecc5 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:07 +0200 Subject: [PATCH 881/903] staging: mt7621-pci: remove remaining pci_legacy dependant code pcibios_* remaining code is not neccessary at all. We can use map_irq set to of_irq_parse_and_map_pci driver 'probe' function. Remove this code. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 33 +------------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index dd1a72890caf..a49e2795af6b 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -214,32 +214,6 @@ write_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg, u32 val) pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA); } -int -pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) -{ - struct mt7621_pcie *pcie = dev->bus->sysdata; - u16 cmd; - u32 val; - int irq; - - if (dev->bus->number == 0) { - write_config(pcie, slot, PCI_BASE_ADDRESS_0, MEMORY_BASE); - val = read_config(pcie, slot, PCI_BASE_ADDRESS_0); - printk("BAR0 at slot %d = %x\n", slot, val); - } - - pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x14); //configure cache line size 0x14 - pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xFF); //configure latency timer 0x10 - pci_read_config_word(dev, PCI_COMMAND, &cmd); - cmd = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; - pci_write_config_word(dev, PCI_COMMAND, cmd); - - irq = of_irq_parse_and_map_pci(dev, slot, pin); - - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); - return irq; -} - void set_pcie_phy(struct mt7621_pcie *pcie, u32 offset, int start_b, int bits, int val) @@ -461,7 +435,7 @@ static int mt7621_pcie_register_host(struct pci_host_bridge *host, host->busnr = pcie->busn.start; host->dev.parent = pcie->dev; host->ops = &mt7621_pci_ops; - host->map_irq = pcibios_map_irq; + host->map_irq = of_irq_parse_and_map_pci; host->swizzle_irq = pci_common_swizzle; host->sysdata = pcie; @@ -726,11 +700,6 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num return 0; } -int pcibios_plat_dev_init(struct pci_dev *dev) -{ - return 0; -} - static const struct of_device_id mt7621_pci_ids[] = { { .compatible = "mediatek,mt7621-pci" }, {}, From 532f14d973949948bf1a3f33e17a8548a30b33d5 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 3 Aug 2018 10:27:08 +0200 Subject: [PATCH 882/903] staging: mt7621-dts: add pcie controller port registers The pcie node of the device tree only contains registers for the host-bridge and pcie port 0. Add the pcie port 1 and pcie port 2 also. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 4610403b470d..2e837e60663a 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -394,8 +394,10 @@ pcie: pcie@1e140000 { compatible = "mediatek,mt7621-pci"; - reg = <0x1e140000 0x100 - 0x1e142000 0x100>; + reg = <0x1e140000 0x100 /* host-pci bridge registers */ + 0x1e142000 0x100 /* pcie port 0 RC control registers */ + 0x1e143000 0x100 /* pcie port 1 RC control registers */ + 0x1e144000 0x100>; /* pcie port 2 RC control registers */ #address-cells = <3>; #size-cells = <2>; From e083926b3e269d4064825dcf2ad50c636fddf8cf Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 6 Aug 2018 11:05:13 +0100 Subject: [PATCH 883/903] staging: comedi: ni_mio_common: fix subdevice flags for PFI subdevice The PFI subdevice flags indicate that the subdevice is readable and writeable, but that is only true for the supported "M-series" boards, not the older "E-series" boards. Only set the SDF_READABLE and SDF_WRITABLE subdevice flags for the M-series boards. These two flags are mainly for informational purposes. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index b0b05a96c2f0..4dee2fc37aed 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -5446,11 +5446,11 @@ static int ni_E_init(struct comedi_device *dev, /* Digital I/O (PFI) subdevice */ s = &dev->subdevices[NI_PFI_DIO_SUBDEV]; s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->maxdata = 1; if (devpriv->is_m_series) { s->n_chan = 16; s->insn_bits = ni_pfi_insn_bits; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; ni_writew(dev, s->state, NI_M_PFI_DO_REG); for (i = 0; i < NUM_PFI_OUTPUT_SELECT_REGS; ++i) { @@ -5459,6 +5459,7 @@ static int ni_E_init(struct comedi_device *dev, } } else { s->n_chan = 10; + s->subdev_flags = SDF_INTERNAL; } s->insn_config = ni_pfi_insn_config; From f7992a043f5cf9a3249c9168e828166c2ce2674d Mon Sep 17 00:00:00 2001 From: Luke Triantafyllidis Date: Fri, 3 Aug 2018 14:37:13 +1000 Subject: [PATCH 884/903] staging: rtlwifi: refactor rtl_get_tcb_desc Refactored rtl_get_tcb_desc slightly to stay within the 80 character line limit. Signed-off-by: Luke Triantafyllidis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/base.c | 104 ++++++++++++++++----------------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c index a4e2041a5ead..d363c39aa788 100644 --- a/drivers/staging/rtlwifi/base.c +++ b/drivers/staging/rtlwifi/base.c @@ -1236,67 +1236,61 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw, if (rtl_is_tx_report_skb(hw, skb)) tcb_desc->use_spe_rpt = 1; - if (ieee80211_is_data(fc)) { - /* - *we set data rate INX 0 - *in rtl_rc.c if skb is special data or - *mgt which need low data rate. - */ - - /* - *So tcb_desc->hw_rate is just used for - *special data and mgt frames - */ - if (info->control.rates[0].idx == 0 || - ieee80211_is_nullfunc(fc)) { - tcb_desc->use_driver_rate = true; - tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_MC); - - tcb_desc->disable_ratefallback = 1; - } else { - /* because hw will never use hw_rate - * when tcb_desc->use_driver_rate = false - * so we never set highest N rate here, - * and N rate will all be controlled by FW - * when tcb_desc->use_driver_rate = false - */ - if (sta && sta->vht_cap.vht_supported) { - tcb_desc->hw_rate = - _rtl_get_vht_highest_n_rate(hw, sta); - } else { - if (sta && sta->ht_cap.ht_supported) { - tcb_desc->hw_rate = - _rtl_get_highest_n_rate(hw, sta); - } else { - if (rtlmac->mode == WIRELESS_MODE_B) { - tcb_desc->hw_rate = - rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M]; - } else { - tcb_desc->hw_rate = - rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M]; - } - } - } - } - - if (is_multicast_ether_addr(hdr->addr1)) - tcb_desc->multicast = 1; - else if (is_broadcast_ether_addr(hdr->addr1)) - tcb_desc->broadcast = 1; - - _rtl_txrate_selectmode(hw, sta, tcb_desc); - _rtl_query_bandwidth_mode(hw, sta, tcb_desc); - _rtl_qurey_shortpreamble_mode(hw, tcb_desc, info); - _rtl_query_shortgi(hw, sta, tcb_desc, info); - _rtl_query_protection_mode(hw, tcb_desc, info); - } else { + if (!ieee80211_is_data(fc)) { tcb_desc->use_driver_rate = true; tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); tcb_desc->disable_ratefallback = 1; tcb_desc->mac_id = 0; tcb_desc->packet_bw = false; + + return; } + + /* + * We set data rate INX 0 + * in rtl_rc.c if skb is special data or + * mgt which need low data rate. + */ + + /* + * So tcb_desc->hw_rate is just used for + * special data and mgt frames + */ + if (info->control.rates[0].idx == 0 || ieee80211_is_nullfunc(fc)) { + tcb_desc->use_driver_rate = true; + tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); + + tcb_desc->disable_ratefallback = 1; + } else if (sta && sta->vht_cap.vht_supported) { + /* + * Because hw will never use hw_rate + * when tcb_desc->use_driver_rate = false + * so we never set highest N rate here, + * and N rate will all be controlled by FW + * when tcb_desc->use_driver_rate = false + */ + tcb_desc->hw_rate = _rtl_get_vht_highest_n_rate(hw, sta); + } else if (sta && sta->ht_cap.ht_supported) { + tcb_desc->hw_rate = _rtl_get_highest_n_rate(hw, sta); + } else { + enum rtl_var_map var = RTL_RC_OFDM_RATE54M; + + if (rtlmac->mode == WIRELESS_MODE_B) + var = RTL_RC_CCK_RATE11M; + + tcb_desc->hw_rate = rtlpriv->cfg->maps[var]; + } + + if (is_multicast_ether_addr(hdr->addr1)) + tcb_desc->multicast = 1; + else if (is_broadcast_ether_addr(hdr->addr1)) + tcb_desc->broadcast = 1; + + _rtl_txrate_selectmode(hw, sta, tcb_desc); + _rtl_query_bandwidth_mode(hw, sta, tcb_desc); + _rtl_qurey_shortpreamble_mode(hw, tcb_desc, info); + _rtl_query_shortgi(hw, sta, tcb_desc, info); + _rtl_query_protection_mode(hw, tcb_desc, info); #undef SET_RATE_ID } From 247e415fbc3e4728a3d2ea3334f19e1d3556f4c1 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 21:05:11 +0200 Subject: [PATCH 885/903] staging: rtl8188eu: use is_multicast_ether_addr in recv_linux.c Use is_multicast_ether_addr instead of custom IS_MCAST in os_dep/recv_linux.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index deadf26ea2aa..6f74f49bf3ab 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -84,11 +84,11 @@ int rtw_recv_indicatepkt(struct adapter *padapter, struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - int bmcast = IS_MCAST(pattrib->dst); + bool mcast = is_multicast_ether_addr(pattrib->dst); if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) { - if (bmcast) { + if (mcast) { psta = rtw_get_bcmc_stainfo(padapter); pskb2 = skb_clone(skb, GFP_ATOMIC); } else { @@ -104,7 +104,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, rtw_xmit_entry(skb, pnetdev); - if (bmcast) + if (mcast) skb = pskb2; else goto _recv_indicatepkt_end; From d39e86cbd8ae75e6761b14ce34e689a13605629e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 21:05:12 +0200 Subject: [PATCH 886/903] staging: rtl8188eu: use is_multicast_ether_addr in rtl8188eu_xmit.c Use is_multicast_ether_addr instead of custom IS_MCAST in hal/rtl8188eu_xmit.c. There is only one use, so remove the extra variable for the result of IS_MCAST. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 14622eee56ca..82fc5075e0a6 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -167,7 +167,6 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag struct tx_desc *ptxdesc = (struct tx_desc *)pmem; struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - int bmcst = IS_MCAST(pattrib->ra); if (adapt->registrypriv.mp_mode == 0) { if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { @@ -186,7 +185,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw0 |= cpu_to_le32(((offset) << OFFSET_SHT) & 0x00ff0000);/* 32 bytes for TX Desc */ - if (bmcst) + if (is_multicast_ether_addr(pattrib->ra)) ptxdesc->txdw0 |= cpu_to_le32(BMC); if (adapt->registrypriv.mp_mode == 0) { From 353c6774bd8ebaab76f01efd3ed5551073b1be4c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 21:05:13 +0200 Subject: [PATCH 887/903] staging: rtl8188eu: cleanup block comment - style Cleanup a block comment to conform with kernel coding style. Also cleans 'line over 80 characters' checkpatch warnings. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 82fc5075e0a6..6925ec48dff1 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -43,9 +43,11 @@ static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff & checksum); } -/* Description: In normal chip, we should send some packet to Hw which will be used by Fw */ -/* in FW LPS mode. The function is to fill the Tx descriptor of this packets, then */ -/* Fw can tell Hw to send these packet derectly. */ +/* + * In normal chip, we should send some packet to Hw which will be used by Fw + * in FW LPS mode. The function is to fill the Tx descriptor of this packets, + * then Fw can tell Hw to send these packet derectly. + */ void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u8 ispspoll, u8 is_btqosnull) { struct tx_desc *ptxdesc; From e18676cc6e208e4b6cb7bd07faeac4a3e6aed9fa Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 21:05:14 +0200 Subject: [PATCH 888/903] staging: rtl8188eu: remove whitespace - style Replace tabs with spaces and/or remove spaces where appropriate. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/rtl8188eu_xmit.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 6925ec48dff1..a11bee16d070 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -15,7 +15,7 @@ s32 rtw_hal_init_xmit_priv(struct adapter *adapt) { - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; tasklet_init(&pxmitpriv->xmit_tasklet, (void(*)(unsigned long))rtl8188eu_xmit_tasklet, @@ -30,8 +30,8 @@ static u8 urb_zero_packet_chk(struct adapter *adapt, int sz) static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) { - u16 *usptr = (u16 *)ptxdesc; - u32 count = 16; /* (32 bytes / 2 bytes per XOR) => 16 times */ + u16 *usptr = (u16 *)ptxdesc; + u32 count = 16; /* (32 bytes / 2 bytes per XOR) => 16 times */ u32 index; u16 checksum = 0; @@ -160,15 +160,15 @@ static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bagg_pkt) { - int pull = 0; - uint qsel; + int pull = 0; + uint qsel; u8 data_rate, pwr_status, offset; - struct adapter *adapt = pxmitframe->padapter; - struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct adapter *adapt = pxmitframe->padapter; + struct pkt_attrib *pattrib = &pxmitframe->attrib; struct odm_dm_struct *odmpriv = &adapt->HalData->odmpriv; - struct tx_desc *ptxdesc = (struct tx_desc *)pmem; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct tx_desc *ptxdesc = (struct tx_desc *)pmem; + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); if (adapt->registrypriv.mp_mode == 0) { if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { @@ -328,7 +328,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag return pull; } -/* for non-agg data frame or management frame */ +/* for non-agg data frame or management frame */ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) { s32 ret = _SUCCESS; From 5c3bd8481c38a94b5442de556a88edfe5848e9a8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 21:05:15 +0200 Subject: [PATCH 889/903] staging: rtl8188eu: use is_multicast_ether_addr in rtw_sta_mgt.c Use is_multicast_ether_addr instead of custom IS_MCAST in core/rtw_sta_mgt.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 53e518148ae5..34c3e2af63c1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -414,7 +414,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) if (!hwaddr) return NULL; - if (IS_MCAST(hwaddr)) + if (is_multicast_ether_addr(hwaddr)) addr = bc_addr; else addr = hwaddr; From 705030a151cd2700415ba0eed98bd20459bac8b0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 Aug 2018 21:05:16 +0200 Subject: [PATCH 890/903] staging: rtl8188eu: remove whitespace, add missing blank line Replace tabs with spaces and/or remove spaces where appropriate. Add a missing blank line after declarations. Also clears checkpatch warnings. WARNING: Statements should start on a tabstop WARNING: suspect code indent for conditional statements (8, 17) Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 37 ++++++++++---------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 34c3e2af63c1..f12a12b19d3f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -18,7 +18,7 @@ static void _rtw_init_stainfo(struct sta_info *psta) { memset((u8 *)psta, 0, sizeof(struct sta_info)); - spin_lock_init(&psta->lock); + spin_lock_init(&psta->lock); INIT_LIST_HEAD(&psta->list); INIT_LIST_HEAD(&psta->hash_list); _rtw_init_queue(&psta->sleep_q); @@ -55,7 +55,7 @@ static void _rtw_init_stainfo(struct sta_info *psta) #endif /* CONFIG_88EU_AP_MODE */ } -u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) +u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) { struct sta_info *psta; s32 i; @@ -127,15 +127,15 @@ inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); } -u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) +u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) { struct list_head *phead, *plist; struct sta_info *psta = NULL; struct recv_reorder_ctrl *preorder_ctrl; - int index; + int index; if (pstapriv) { - /* delete all reordering_ctrl_timer */ + /* delete all reordering_ctrl_timer */ spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { phead = &pstapriv->sta_hash[index]; @@ -171,7 +171,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) struct __queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; int i = 0; - u16 wRxSeqInitialValue = 0xffff; + u16 wRxSeqInitialValue = 0xffff; pfree_sta_queue = &pstapriv->free_sta_queue; @@ -243,14 +243,14 @@ exit: } /* using pstapriv->sta_hash_lock to protect */ -u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) +u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) { int i; struct __queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; - struct sta_xmit_priv *pstaxmitpriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_xmit_priv *pstaxmitpriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct sta_priv *pstapriv = &padapter->stapriv; if (!psta) goto exit; @@ -376,9 +376,9 @@ exit: void rtw_free_all_stainfo(struct adapter *padapter) { struct list_head *plist, *phead; - s32 index; + s32 index; struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); if (pstapriv->asoc_sta_count == 1) @@ -407,7 +407,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { struct list_head *plist, *phead; struct sta_info *psta = NULL; - u32 index; + u32 index; u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -443,10 +443,10 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) u32 rtw_init_bcmc_stainfo(struct adapter *padapter) { - struct sta_info *psta; + struct sta_info *psta; u32 res = _SUCCESS; unsigned char bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; psta = rtw_alloc_stainfo(pstapriv, bcast_addr); @@ -465,9 +465,10 @@ exit: struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) { - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - return rtw_get_stainfo(pstapriv, bc_addr); + + return rtw_get_stainfo(pstapriv, bc_addr); } u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) @@ -502,7 +503,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) else if (pacl_list->mode == 2)/* deny unless in accept list */ res = (match) ? true : false; else - res = true; + res = true; #endif From 243638bc1c76a34d709432a59453f31123408742 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 6 Aug 2018 14:31:02 +0100 Subject: [PATCH 891/903] staging: rtl8188eu: remove unused array dB_Invert_Table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Array dB_Invert_Table is declared but not used, hence it is redundant and can be removed. Cleans up clang warning: warning: ‘dB_Invert_Table’ defined but not used [-Wunused-const-variable=] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 1f21728f5084..9d567838a43a 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -11,16 +11,6 @@ #include "phy.h" u32 GlobalDebugLevel; -static const u16 dB_Invert_Table[8][12] = { - {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4}, - {4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16}, - {18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63}, - {71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251}, - {282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000}, - {1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981}, - {4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125, 15849}, - {17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119, 56234, 65535} -}; /* avoid to warn in FreeBSD ==> To DO modify */ static u32 EDCAParam[HT_IOT_PEER_MAX][3] = { From 0b1533c6c6f63bca9807fd6f295d769b6f4b5a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:28:16 -0300 Subject: [PATCH 892/903] staging: fbtft: Puts macro arguments in parenthesis to avoid precedence issues - Style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Puts macro arguments in parenthesis to avoid precedence issues. Some large lines were broken to fit the 80-char limit. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_hx8347d.c | 2 +- drivers/staging/fbtft/fb_ili9163.c | 2 +- drivers/staging/fbtft/fb_ili9320.c | 2 +- drivers/staging/fbtft/fb_ili9325.c | 2 +- drivers/staging/fbtft/fb_ili9341.c | 2 +- drivers/staging/fbtft/fb_s6d1121.c | 2 +- drivers/staging/fbtft/fb_ssd1289.c | 2 +- drivers/staging/fbtft/fb_st7735r.c | 2 +- drivers/staging/fbtft/fb_watterott.c | 12 +++++++++--- drivers/staging/fbtft/fbtft.h | 9 +++++---- 10 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/staging/fbtft/fb_hx8347d.c b/drivers/staging/fbtft/fb_hx8347d.c index 0b605303813e..3427a858d17c 100644 --- a/drivers/staging/fbtft/fb_hx8347d.c +++ b/drivers/staging/fbtft/fb_hx8347d.c @@ -92,7 +92,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) * VRP0 VRP1 VRP2 VRP3 VRP4 VRP5 PRP0 PRP1 PKP0 PKP1 PKP2 PKP3 PKP4 CGM * VRN0 VRN1 VRN2 VRN3 VRN4 VRN5 PRN0 PRN1 PKN0 PKN1 PKN2 PKN3 PKN4 CGM */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9163.c b/drivers/staging/fbtft/fb_ili9163.c index fd3dd671509f..86e140244aab 100644 --- a/drivers/staging/fbtft/fb_ili9163.c +++ b/drivers/staging/fbtft/fb_ili9163.c @@ -192,7 +192,7 @@ static int set_var(struct fbtft_par *par) } #ifdef GAMMA_ADJ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int gamma_adj(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9320.c b/drivers/staging/fbtft/fb_ili9320.c index 501eee7dce4c..740c0acbecd8 100644 --- a/drivers/staging/fbtft/fb_ili9320.c +++ b/drivers/staging/fbtft/fb_ili9320.c @@ -211,7 +211,7 @@ static int set_var(struct fbtft_par *par) * VRP0 VRP1 RP0 RP1 KP0 KP1 KP2 KP3 KP4 KP5 * VRN0 VRN1 RN0 RN1 KN0 KN1 KN2 KN3 KN4 KN5 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9325.c b/drivers/staging/fbtft/fb_ili9325.c index d6b1d4be9ff4..2cf75f2e03e2 100644 --- a/drivers/staging/fbtft/fb_ili9325.c +++ b/drivers/staging/fbtft/fb_ili9325.c @@ -205,7 +205,7 @@ static int set_var(struct fbtft_par *par) * VRP0 VRP1 RP0 RP1 KP0 KP1 KP2 KP3 KP4 KP5 * VRN0 VRN1 RN0 RN1 KN0 KN1 KN2 KN3 KN4 KN5 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9341.c b/drivers/staging/fbtft/fb_ili9341.c index a10e8c9de438..9ccd0823c3ab 100644 --- a/drivers/staging/fbtft/fb_ili9341.c +++ b/drivers/staging/fbtft/fb_ili9341.c @@ -111,7 +111,7 @@ static int set_var(struct fbtft_par *par) * Positive: Par1 Par2 [...] Par15 * Negative: Par1 Par2 [...] Par15 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { int i; diff --git a/drivers/staging/fbtft/fb_s6d1121.c b/drivers/staging/fbtft/fb_s6d1121.c index b90244259d43..c3e434d647b8 100644 --- a/drivers/staging/fbtft/fb_s6d1121.c +++ b/drivers/staging/fbtft/fb_s6d1121.c @@ -120,7 +120,7 @@ static int set_var(struct fbtft_par *par) * PKP0 PKP1 PKP2 PKP3 PKP4 PKP5 PKP6 PKP7 PKP8 PKP9 PKP10 PKP11 VRP0 VRP1 * PKN0 PKN1 PKN2 PKN3 PKN4 PKN5 PKN6 PKN7 PRN8 PRN9 PRN10 PRN11 VRN0 VRN1 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ssd1289.c b/drivers/staging/fbtft/fb_ssd1289.c index cbf22e1f4b61..46116d06522c 100644 --- a/drivers/staging/fbtft/fb_ssd1289.c +++ b/drivers/staging/fbtft/fb_ssd1289.c @@ -126,7 +126,7 @@ static int set_var(struct fbtft_par *par) * VRP0 VRP1 PRP0 PRP1 PKP0 PKP1 PKP2 PKP3 PKP4 PKP5 * VRN0 VRN1 PRN0 PRN1 PKN0 PKN1 PKN2 PKN3 PKN4 PKN5 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_st7735r.c b/drivers/staging/fbtft/fb_st7735r.c index 631208bd3a17..e24af0a7f2de 100644 --- a/drivers/staging/fbtft/fb_st7735r.c +++ b/drivers/staging/fbtft/fb_st7735r.c @@ -133,7 +133,7 @@ static int set_var(struct fbtft_par *par) * VRF0P VOS0P PK0P PK1P PK2P PK3P PK4P PK5P PK6P PK7P PK8P PK9P SELV0P SELV1P SELV62P SELV63P * VRF0N VOS0N PK0N PK1N PK2N PK3N PK4N PK5N PK6N PK7N PK8N PK9N SELV0N SELV1N SELV62N SELV63N */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { int i, j; diff --git a/drivers/staging/fbtft/fb_watterott.c b/drivers/staging/fbtft/fb_watterott.c index bfd1527f20f7..33dd720aa675 100644 --- a/drivers/staging/fbtft/fb_watterott.c +++ b/drivers/staging/fbtft/fb_watterott.c @@ -89,9 +89,15 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) return 0; } -#define RGB565toRGB323(c) (((c&0xE000)>>8) | ((c&0600)>>6) | ((c&0x001C)>>2)) -#define RGB565toRGB332(c) (((c&0xE000)>>8) | ((c&0700)>>6) | ((c&0x0018)>>3)) -#define RGB565toRGB233(c) (((c&0xC000)>>8) | ((c&0700)>>5) | ((c&0x001C)>>2)) +#define RGB565toRGB323(c) ((((c) & 0xE000) >> 8) |\ + (((c) & 000600) >> 6) |\ + (((c) & 0x001C) >> 2)) +#define RGB565toRGB332(c) ((((c) & 0xE000) >> 8) |\ + (((c) & 000700) >> 6) |\ + (((c) & 0x0018) >> 3)) +#define RGB565toRGB233(c) ((((c) & 0xC000) >> 8) |\ + (((c) & 000700) >> 5) |\ + (((c) & 0x001C) >> 2)) static int write_vmem_8bit(struct fbtft_par *par, size_t offset, size_t len) { diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h index c7cb4a7896f4..0c710d374fab 100644 --- a/drivers/staging/fbtft/fbtft.h +++ b/drivers/staging/fbtft/fbtft.h @@ -234,8 +234,8 @@ struct fbtft_par { #define NUMARGS(...) (sizeof((int[]){__VA_ARGS__})/sizeof(int)) -#define write_reg(par, ...) \ - par->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__) +#define write_reg(par, ...) \ + ((par)->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__)) /* fbtft-core.c */ int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc); @@ -404,8 +404,9 @@ do { \ #define fbtft_par_dbg_hex(level, par, dev, type, buf, num, format, arg...) \ do { \ - if (unlikely(par->debug & level)) \ - fbtft_dbg_hex(dev, sizeof(type), buf, num * sizeof(type), format, ##arg); \ + if (unlikely((par)->debug & (level))) \ + fbtft_dbg_hex(dev, sizeof(type), buf,\ + (num) * sizeof(type), format, ##arg); \ } while (0) #endif /* __LINUX_FBTFT_H */ From 333c7b940526be12b8a831b08f948a07e0955271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:28:29 -0300 Subject: [PATCH 893/903] staging: fbtft: Fixes some alignment issues - Style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes (most) alignment issues pointed by checkpatch.pl. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_ssd1289.c | 6 ++--- drivers/staging/fbtft/fb_ssd1351.c | 31 ++++++++++++++-------- drivers/staging/fbtft/fb_st7735r.c | 13 +++++++--- drivers/staging/fbtft/fb_st7789v.c | 13 +++++----- drivers/staging/fbtft/fb_watterott.c | 14 +++++----- drivers/staging/fbtft/fbtft-bus.c | 17 ++++++------ drivers/staging/fbtft/fbtft-core.c | 39 +++++++++++++++------------- drivers/staging/fbtft/fbtft-io.c | 17 ++++++------ drivers/staging/fbtft/fbtft-sysfs.c | 3 ++- drivers/staging/fbtft/fbtft.h | 6 ++--- drivers/staging/fbtft/fbtft_device.c | 25 +++++++++--------- drivers/staging/fbtft/flexfb.c | 4 ++- 12 files changed, 106 insertions(+), 82 deletions(-) diff --git a/drivers/staging/fbtft/fb_ssd1289.c b/drivers/staging/fbtft/fb_ssd1289.c index 46116d06522c..67b3f8548241 100644 --- a/drivers/staging/fbtft/fb_ssd1289.c +++ b/drivers/staging/fbtft/fb_ssd1289.c @@ -38,7 +38,7 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0x0E, 0x2B00); write_reg(par, 0x1E, 0x00B7); write_reg(par, 0x01, - BIT(13) | (par->bgr << 11) | BIT(9) | (HEIGHT - 1)); + BIT(13) | (par->bgr << 11) | BIT(9) | (HEIGHT - 1)); write_reg(par, 0x02, 0x0600); write_reg(par, 0x10, 0x0000); write_reg(par, 0x05, 0x0000); @@ -98,8 +98,8 @@ static int set_var(struct fbtft_par *par) if (par->fbtftops.init_display != init_display) { /* don't risk messing up register 11h */ fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "%s: skipping since custom init_display() is used\n", - __func__); + "%s: skipping since custom init_display() is used\n", + __func__); return 0; } diff --git a/drivers/staging/fbtft/fb_ssd1351.c b/drivers/staging/fbtft/fb_ssd1351.c index 1b92691ac7cc..e077b3d58aef 100644 --- a/drivers/staging/fbtft/fb_ssd1351.c +++ b/drivers/staging/fbtft/fb_ssd1351.c @@ -139,14 +139,22 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) } write_reg(par, 0xB8, - tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], - tmp[8], tmp[9], tmp[10], tmp[11], tmp[12], tmp[13], tmp[14], tmp[15], - tmp[16], tmp[17], tmp[18], tmp[19], tmp[20], tmp[21], tmp[22], tmp[23], - tmp[24], tmp[25], tmp[26], tmp[27], tmp[28], tmp[29], tmp[30], tmp[31], - tmp[32], tmp[33], tmp[34], tmp[35], tmp[36], tmp[37], tmp[38], tmp[39], - tmp[40], tmp[41], tmp[42], tmp[43], tmp[44], tmp[45], tmp[46], tmp[47], - tmp[48], tmp[49], tmp[50], tmp[51], tmp[52], tmp[53], tmp[54], tmp[55], - tmp[56], tmp[57], tmp[58], tmp[59], tmp[60], tmp[61], tmp[62]); + tmp[0], tmp[1], tmp[2], tmp[3], + tmp[4], tmp[5], tmp[6], tmp[7], + tmp[8], tmp[9], tmp[10], tmp[11], + tmp[12], tmp[13], tmp[14], tmp[15], + tmp[16], tmp[17], tmp[18], tmp[19], + tmp[20], tmp[21], tmp[22], tmp[23], + tmp[24], tmp[25], tmp[26], tmp[27], + tmp[28], tmp[29], tmp[30], tmp[31], + tmp[32], tmp[33], tmp[34], tmp[35], + tmp[36], tmp[37], tmp[38], tmp[39], + tmp[40], tmp[41], tmp[42], tmp[43], + tmp[44], tmp[45], tmp[46], tmp[47], + tmp[48], tmp[49], tmp[50], tmp[51], + tmp[52], tmp[53], tmp[54], tmp[55], + tmp[56], tmp[57], tmp[58], tmp[59], + tmp[60], tmp[61], tmp[62]); return 0; } @@ -185,8 +193,8 @@ static int update_onboard_backlight(struct backlight_device *bd) bool on; fbtft_par_dbg(DEBUG_BACKLIGHT, par, - "%s: power=%d, fb_blank=%d\n", - __func__, bd->props.power, bd->props.fb_blank); + "%s: power=%d, fb_blank=%d\n", + __func__, bd->props.power, bd->props.fb_blank); on = (bd->props.power == FB_BLANK_UNBLANK) && (bd->props.fb_blank == FB_BLANK_UNBLANK); @@ -209,7 +217,8 @@ static void register_onboard_backlight(struct fbtft_par *par) bl_props.power = FB_BLANK_POWERDOWN; bd = backlight_device_register(dev_driver_string(par->info->device), - par->info->device, par, &bl_ops, &bl_props); + par->info->device, par, &bl_ops, + &bl_props); if (IS_ERR(bd)) { dev_err(par->info->device, "cannot register backlight device (%ld)\n", diff --git a/drivers/staging/fbtft/fb_st7735r.c b/drivers/staging/fbtft/fb_st7735r.c index e24af0a7f2de..9670a8989b91 100644 --- a/drivers/staging/fbtft/fb_st7735r.c +++ b/drivers/staging/fbtft/fb_st7735r.c @@ -145,13 +145,18 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) for (i = 0; i < par->gamma.num_curves; i++) write_reg(par, 0xE0 + i, - CURVE(i, 0), CURVE(i, 1), CURVE(i, 2), CURVE(i, 3), - CURVE(i, 4), CURVE(i, 5), CURVE(i, 6), CURVE(i, 7), - CURVE(i, 8), CURVE(i, 9), CURVE(i, 10), CURVE(i, 11), - CURVE(i, 12), CURVE(i, 13), CURVE(i, 14), CURVE(i, 15)); + CURVE(i, 0), CURVE(i, 1), + CURVE(i, 2), CURVE(i, 3), + CURVE(i, 4), CURVE(i, 5), + CURVE(i, 6), CURVE(i, 7), + CURVE(i, 8), CURVE(i, 9), + CURVE(i, 10), CURVE(i, 11), + CURVE(i, 12), CURVE(i, 13), + CURVE(i, 14), CURVE(i, 15)); return 0; } + #undef CURVE static struct fbtft_display display = { diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c index 7d7573a7b615..3c3f387936e8 100644 --- a/drivers/staging/fbtft/fb_st7789v.c +++ b/drivers/staging/fbtft/fb_st7789v.c @@ -201,13 +201,12 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) c = i * par->gamma.num_values; for (j = 0; j < par->gamma.num_values; j++) curves[c + j] &= gamma_par_mask[j]; - write_reg( - par, PVGAMCTRL + i, - curves[c + 0], curves[c + 1], curves[c + 2], - curves[c + 3], curves[c + 4], curves[c + 5], - curves[c + 6], curves[c + 7], curves[c + 8], - curves[c + 9], curves[c + 10], curves[c + 11], - curves[c + 12], curves[c + 13]); + write_reg(par, PVGAMCTRL + i, + curves[c + 0], curves[c + 1], curves[c + 2], + curves[c + 3], curves[c + 4], curves[c + 5], + curves[c + 6], curves[c + 7], curves[c + 8], + curves[c + 9], curves[c + 10], curves[c + 11], + curves[c + 12], curves[c + 13]); } return 0; } diff --git a/drivers/staging/fbtft/fb_watterott.c b/drivers/staging/fbtft/fb_watterott.c index 33dd720aa675..e77178157f1b 100644 --- a/drivers/staging/fbtft/fb_watterott.c +++ b/drivers/staging/fbtft/fb_watterott.c @@ -46,7 +46,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) va_end(args); fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, - par->info->device, u8, par->buf, len, "%s: ", __func__); + par->info->device, u8, par->buf, + len, "%s: ", __func__); ret = par->fbtftops.write(par, par->buf, len); if (ret < 0) { @@ -175,7 +176,7 @@ static int init_display(struct fbtft_par *par) version = firmware_version(par); fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "Firmware version: %x.%02x\n", - version >> 8, version & 0xFF); + version >> 8, version & 0xFF); if (mode == 332) par->fbtftops.write_vmem = write_vmem_8bit; @@ -226,9 +227,9 @@ static int backlight_chip_update_status(struct backlight_device *bd) int brightness = bd->props.brightness; fbtft_par_dbg(DEBUG_BACKLIGHT, par, - "%s: brightness=%d, power=%d, fb_blank=%d\n", - __func__, bd->props.brightness, bd->props.power, - bd->props.fb_blank); + "%s: brightness=%d, power=%d, fb_blank=%d\n", __func__, + bd->props.brightness, bd->props.power, + bd->props.fb_blank); if (bd->props.power != FB_BLANK_UNBLANK) brightness = 0; @@ -256,7 +257,8 @@ static void register_chip_backlight(struct fbtft_par *par) bl_props.brightness = DEFAULT_BRIGHTNESS; bd = backlight_device_register(dev_driver_string(par->info->device), - par->info->device, par, &bl_ops, &bl_props); + par->info->device, par, &bl_ops, + &bl_props); if (IS_ERR(bd)) { dev_err(par->info->device, "cannot register backlight device (%ld)\n", diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c index 871b307d83cb..8ce1ff9b6c2a 100644 --- a/drivers/staging/fbtft/fbtft-bus.c +++ b/drivers/staging/fbtft/fbtft-bus.c @@ -79,7 +79,8 @@ void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...) *(((u8 *)buf) + i) = (u8)va_arg(args, unsigned int); va_end(args); fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, - par->info->device, u8, buf, len, "%s: ", __func__); + par->info->device, u8, buf, len, "%s: ", + __func__); } if (len <= 0) return; @@ -129,7 +130,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) size_t startbyte_size = 0; fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n", - __func__, offset, len); + __func__, offset, len); remain = len / 2; vmem16 = (u16 *)(par->info->screen_buffer + offset); @@ -153,8 +154,8 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) while (remain) { to_copy = min(tx_array_size, remain); - dev_dbg(par->info->device, " to_copy=%zu, remain=%zu\n", - to_copy, remain - to_copy); + dev_dbg(par->info->device, "to_copy=%zu, remain=%zu\n", + to_copy, remain - to_copy); for (i = 0; i < to_copy; i++) txbuf16[i] = cpu_to_be16(vmem16[i]); @@ -183,7 +184,7 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len) int ret = 0; fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n", - __func__, offset, len); + __func__, offset, len); if (!par->txbuf.buf) { dev_err(par->info->device, "%s: txbuf.buf is NULL\n", __func__); @@ -197,8 +198,8 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len) while (remain) { to_copy = min(tx_array_size, remain); - dev_dbg(par->info->device, " to_copy=%zu, remain=%zu\n", - to_copy, remain - to_copy); + dev_dbg(par->info->device, "to_copy=%zu, remain=%zu\n", + to_copy, remain - to_copy); #ifdef __LITTLE_ENDIAN for (i = 0; i < to_copy; i += 2) { @@ -233,7 +234,7 @@ int fbtft_write_vmem16_bus16(struct fbtft_par *par, size_t offset, size_t len) u16 *vmem16; fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n", - __func__, offset, len); + __func__, offset, len); vmem16 = (u16 *)(par->info->screen_buffer + offset); diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 731e47149af8..a03d8adf3f9a 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -137,8 +137,8 @@ static int fbtft_request_gpios(struct fbtft_par *par) flags = fbtft_request_gpios_match(par, gpio); if (flags != FBTFT_GPIO_NO_MATCH) { ret = devm_gpio_request_one(par->info->device, - gpio->gpio, flags, - par->info->device->driver->name); + gpio->gpio, flags, + par->info->device->driver->name); if (ret < 0) { dev_err(par->info->device, "%s: gpio_request_one('%s'=%d) failed with %d\n", @@ -249,8 +249,8 @@ static int fbtft_backlight_update_status(struct backlight_device *bd) bool polarity = par->polarity; fbtft_par_dbg(DEBUG_BACKLIGHT, par, - "%s: polarity=%d, power=%d, fb_blank=%d\n", - __func__, polarity, bd->props.power, bd->props.fb_blank); + "%s: polarity=%d, power=%d, fb_blank=%d\n", + __func__, polarity, bd->props.power, bd->props.fb_blank); if ((bd->props.power == FB_BLANK_UNBLANK) && (bd->props.fb_blank == FB_BLANK_UNBLANK)) @@ -372,7 +372,7 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned int start_line, if (start_line > par->info->var.yres - 1 || end_line > par->info->var.yres - 1) { dev_warn(par->info->device, - "%s: start_line=%u or end_line=%u is larger than max=%d. Shouldn't happen, will do full display update\n", + "%s: start_line=%u or end_line=%u is larger than max=%d. Shouldn't happen, will do full display update\n", __func__, start_line, end_line, par->info->var.yres - 1); start_line = 0; @@ -817,8 +817,8 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, info->pseudo_palette = par->pseudo_palette; if (par->gamma.curves && gamma) { - if (fbtft_gamma_parse_str(par, - par->gamma.curves, gamma, strlen(gamma))) + if (fbtft_gamma_parse_str(par, par->gamma.curves, gamma, + strlen(gamma))) goto alloc_fail; } @@ -1045,8 +1045,8 @@ static int fbtft_init_display_dt(struct fbtft_par *par) while (p && !(val & 0xFFFF0000)) { if (i > 63) { dev_err(par->info->device, - "%s: Maximum register values exceeded\n", - __func__); + "%s: Maximum register values exceeded\n", + __func__); return -EINVAL; } buf[i++] = val; @@ -1166,8 +1166,8 @@ int fbtft_init_display(struct fbtft_par *par) while (par->init_sequence[i] >= 0) { if (j > 63) { dev_err(par->info->device, - "%s: Maximum register values exceeded\n", - __func__); + "%s: Maximum register values exceeded\n", + __func__); return -EINVAL; } buf[j++] = par->init_sequence[i++]; @@ -1193,7 +1193,8 @@ int fbtft_init_display(struct fbtft_par *par) case -2: i++; fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "init: mdelay(%d)\n", par->init_sequence[i]); + "init: mdelay(%d)\n", + par->init_sequence[i]); mdelay(par->init_sequence[i++]); break; default: @@ -1225,8 +1226,8 @@ static int fbtft_verify_gpios(struct fbtft_par *par) fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__); - if (pdata->display.buswidth != 9 && par->startbyte == 0 && - par->gpio.dc < 0) { + if (pdata->display.buswidth != 9 && par->startbyte == 0 && + par->gpio.dc < 0) { dev_err(par->info->device, "Missing info about 'dc' gpio. Aborting.\n"); return -EINVAL; @@ -1321,7 +1322,8 @@ static struct fbtft_platform_data *fbtft_probe_dt(struct device *dev) * Return: 0 if successful, negative if error */ int fbtft_probe_common(struct fbtft_display *display, - struct spi_device *sdev, struct platform_device *pdev) + struct spi_device *sdev, + struct platform_device *pdev) { struct device *dev; struct fb_info *info; @@ -1393,11 +1395,12 @@ int fbtft_probe_common(struct fbtft_display *display, par->spi->bits_per_word = 9; } else { dev_warn(&par->spi->dev, - "9-bit SPI not available, emulating using 8-bit.\n"); + "9-bit SPI not available, emulating using 8-bit.\n"); /* allocate buffer with room for dc bits */ par->extra = devm_kzalloc(par->info->device, - par->txbuf.len + (par->txbuf.len / 8) + 8, - GFP_KERNEL); + par->txbuf.len + + (par->txbuf.len / 8) + 8, + GFP_KERNEL); if (!par->extra) { ret = -ENOMEM; goto out_release; diff --git a/drivers/staging/fbtft/fbtft-io.c b/drivers/staging/fbtft/fbtft-io.c index f4a591919f62..b5051d3d46a6 100644 --- a/drivers/staging/fbtft/fbtft-io.c +++ b/drivers/staging/fbtft/fbtft-io.c @@ -14,7 +14,7 @@ int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len) struct spi_message m; fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); if (!par->spi) { dev_err(par->info->device, @@ -47,7 +47,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len) u64 val, dc, tmp; fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); if (!par->extra) { dev_err(par->info->device, "%s: error: par->extra is NULL\n", @@ -109,14 +109,15 @@ int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t len) txbuf[0] = par->startbyte | 0x3; t.tx_buf = txbuf; fbtft_par_dbg_hex(DEBUG_READ, par, par->info->device, u8, - txbuf, len, "%s(len=%d) txbuf => ", __func__, len); + txbuf, len, "%s(len=%d) txbuf => ", + __func__, len); } spi_message_init(&m); spi_message_add_tail(&t, &m); ret = spi_sync(par->spi, &m); fbtft_par_dbg_hex(DEBUG_READ, par, par->info->device, u8, buf, len, - "%s(len=%d) buf <= ", __func__, len); + "%s(len=%d) buf <= ", __func__, len); return ret; } @@ -135,7 +136,7 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len) #endif fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); while (len--) { data = *(u8 *)buf; @@ -151,7 +152,7 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len) for (i = 0; i < 8; i++) { if ((data & 1) != (prev_data & 1)) gpio_set_value(par->gpio.db[i], - data & 1); + data & 1); data >>= 1; prev_data >>= 1; } @@ -185,7 +186,7 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len) #endif fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); while (len) { data = *(u16 *)buf; @@ -201,7 +202,7 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len) for (i = 0; i < 16; i++) { if ((data & 1) != (prev_data & 1)) gpio_set_value(par->gpio.db[i], - data & 1); + data & 1); data >>= 1; prev_data >>= 1; } diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c index 712096659aa0..2a5c630dab87 100644 --- a/drivers/staging/fbtft/fbtft-sysfs.c +++ b/drivers/staging/fbtft/fbtft-sysfs.c @@ -126,7 +126,8 @@ static ssize_t store_gamma_curve(struct device *device, mutex_lock(&par->gamma.lock); memcpy(par->gamma.curves, tmp_curves, - par->gamma.num_curves * par->gamma.num_values * sizeof(tmp_curves[0])); + par->gamma.num_curves * par->gamma.num_values * + sizeof(tmp_curves[0])); mutex_unlock(&par->gamma.lock); return count; diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h index 0c710d374fab..798a8fe98e95 100644 --- a/drivers/staging/fbtft/fbtft.h +++ b/drivers/staging/fbtft/fbtft.h @@ -64,16 +64,16 @@ struct fbtft_ops { void (*write_register)(struct fbtft_par *par, int len, ...); void (*set_addr_win)(struct fbtft_par *par, - int xs, int ys, int xe, int ye); + int xs, int ys, int xe, int ye); void (*reset)(struct fbtft_par *par); void (*mkdirty)(struct fb_info *info, int from, int to); void (*update_display)(struct fbtft_par *par, - unsigned int start_line, unsigned int end_line); + unsigned int start_line, unsigned int end_line); int (*init_display)(struct fbtft_par *par); int (*blank)(struct fbtft_par *par, bool on); unsigned long (*request_gpios_match)(struct fbtft_par *par, - const struct fbtft_gpio *gpio); + const struct fbtft_gpio *gpio); int (*request_gpios)(struct fbtft_par *par); int (*verify_gpios)(struct fbtft_par *par); diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index 22ba81dbf093..85018e4a4284 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -21,12 +21,13 @@ static struct platform_device *p_device; static char *name; module_param(name, charp, 0000); -MODULE_PARM_DESC(name, "Devicename (required). name=list => list all supported devices."); +MODULE_PARM_DESC(name, + "Devicename (required). name=list => list all supported devices."); static unsigned int rotate; module_param(rotate, uint, 0000); MODULE_PARM_DESC(rotate, -"Angle to rotate display counter clockwise: 0, 90, 180, 270"); + "Angle to rotate display counter clockwise: 0, 90, 180, 270"); static unsigned int busnum; module_param(busnum, uint, 0000); @@ -47,7 +48,7 @@ MODULE_PARM_DESC(mode, "SPI mode (override device default)"); static char *gpios; module_param(gpios, charp, 0000); MODULE_PARM_DESC(gpios, -"List of gpios. Comma separated with the form: reset:23,dc:24 (when overriding the default, all gpios must be specified)"); + "List of gpios. Comma separated with the form: reset:23,dc:24 (when overriding the default, all gpios must be specified)"); static unsigned int fps; module_param(fps, uint, 0000); @@ -56,7 +57,7 @@ MODULE_PARM_DESC(fps, "Frames per second (override driver default)"); static char *gamma; module_param(gamma, charp, 0000); MODULE_PARM_DESC(gamma, -"String representation of Gamma Curve(s). Driver specific."); + "String representation of Gamma Curve(s). Driver specific."); static int txbuflen; module_param(txbuflen, int, 0000); @@ -65,7 +66,7 @@ MODULE_PARM_DESC(txbuflen, "txbuflen (override driver default)"); static int bgr = -1; module_param(bgr, int, 0000); MODULE_PARM_DESC(bgr, -"BGR bit (supported by some drivers)."); + "BGR bit (supported by some drivers)."); static unsigned int startbyte; module_param(startbyte, uint, 0000); @@ -95,12 +96,12 @@ MODULE_PARM_DESC(init, "Init sequence, used with the custom argument"); static unsigned long debug; module_param(debug, ulong, 0000); MODULE_PARM_DESC(debug, -"level: 0-7 (the remaining 29 bits is for advanced usage)"); + "level: 0-7 (the remaining 29 bits is for advanced usage)"); static unsigned int verbose = 3; module_param(verbose, uint, 0000); MODULE_PARM_DESC(verbose, -"0 silent, >0 show gpios, >1 show devices, >2 show devices before (default=3)"); + "0 silent, >0 show gpios, >1 show devices, >2 show devices before (default=3)"); struct fbtft_device_display { char *name; @@ -112,7 +113,7 @@ static void fbtft_device_pdev_release(struct device *dev); static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len); static void adafruit18_green_tab_set_addr_win(struct fbtft_par *par, - int xs, int ys, int xe, int ye); + int xs, int ys, int xe, int ye); #define ADAFRUIT18_GAMMA \ "02 1c 07 12 37 32 29 2d 29 25 2B 39 00 01 03 10\n" \ @@ -1243,7 +1244,7 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len) #endif fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); while (len) { data = *(u16 *)buf; @@ -1259,7 +1260,7 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len) for (i = 0; i < 16; i++) { if ((data & 1) != (prev_data & 1)) gpio_set_value(par->gpio.db[i], - data & 1); + data & 1); data >>= 1; prev_data >>= 1; } @@ -1285,7 +1286,7 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len) } static void adafruit18_green_tab_set_addr_win(struct fbtft_par *par, - int xs, int ys, int xe, int ye) + int xs, int ys, int xe, int ye) { write_reg(par, 0x2A, 0, xs + 2, 0, xe + 2); write_reg(par, 0x2B, 0, ys + 1, 0, ye + 1); @@ -1476,7 +1477,7 @@ static int __init fbtft_device_init(void) size_t len; len = strlcpy(displays[i].spi->modalias, name, - SPI_NAME_SIZE); + SPI_NAME_SIZE); if (len >= SPI_NAME_SIZE) pr_warn("modalias (name) truncated to: %s\n", displays[i].spi->modalias); diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index f676c9b853f1..a2b4164ce5e4 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -694,7 +694,9 @@ static int flexfb_probe_common(struct spi_device *sdev, } break; default: - dev_err(dev, "argument 'buswidth': %d is not supported with SPI.\n", buswidth); + dev_err(dev, + "argument 'buswidth': %d is not supported with SPI.\n", + buswidth); return -EINVAL; } } else { From e66f30ee1369af24366ce947a29d1362b8cd882c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:28:50 -0300 Subject: [PATCH 894/903] staging: fbtft: A bit more information on dev_err. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a bit more information on debug. The line break was to avoid obfuscating the parameters on the end of a large line. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_ssd1351.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fb_ssd1351.c b/drivers/staging/fbtft/fb_ssd1351.c index e077b3d58aef..ba78a7758fb7 100644 --- a/drivers/staging/fbtft/fb_ssd1351.c +++ b/drivers/staging/fbtft/fb_ssd1351.c @@ -126,14 +126,16 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) for (i = 0; i < 63; i++) { if (i > 0 && curves[i] < 2) { dev_err(par->info->device, - "Illegal value in Grayscale Lookup Table at index %d. Must be greater than 1\n", i); + "Illegal value in Grayscale Lookup Table at index %d : %d. Must be greater than 1\n", + i, curves[i]); return -EINVAL; } acc += curves[i]; tmp[i] = acc; if (acc > 180) { dev_err(par->info->device, - "Illegal value(s) in Grayscale Lookup Table. At index=%d, the accumulated value has exceeded 180\n", i); + "Illegal value(s) in Grayscale Lookup Table. At index=%d : %d, the accumulated value has exceeded 180\n", + i, acc); return -EINVAL; } } From d9932c8be094b2891c50348513bfeae578cd5e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:28:57 -0300 Subject: [PATCH 895/903] staging: fbtft: Changes gamma table to define. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of other "Gamma Tables" were already boxed on a define, just did the same to PIOLED. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft_device.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index 85018e4a4284..4110bba52e64 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -262,6 +262,10 @@ static const s16 waveshare32b_init_sequence[] = { -3 }; +#define PIOLED_GAMMA "0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 " \ + "2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " \ + "3 3 3 4 4 4 4 4 4 4 4 4 4 4 4" + /* Supported displays in alphabetical order */ static struct fbtft_device_display displays[] = { { @@ -890,14 +894,7 @@ static struct fbtft_device_display displays[] = { { "dc", 25 }, {}, }, - .gamma = "0 2 2 2 2 2 2 2 " - "2 2 2 2 2 2 2 2 " - "2 2 2 2 2 2 2 2 " - "2 2 2 2 2 2 2 3 " - "3 3 3 3 3 3 3 3 " - "3 3 3 3 3 3 3 3 " - "3 3 3 4 4 4 4 4 " - "4 4 4 4 4 4 4" + .gamma = PIOLED_GAMMA } } }, { From 5bfac06f3e21669a1109fe05bb457adac711312a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:29:04 -0300 Subject: [PATCH 896/903] staging: fbtft: Removes one nesting level to help readability - Style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This nesting level was removed to improve readability. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/flexfb.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index a2b4164ce5e4..2af474469e7d 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -679,19 +679,22 @@ static int flexfb_probe_common(struct spi_device *sdev, if (par->spi->master->bits_per_word_mask & SPI_BPW_MASK(9)) { par->spi->bits_per_word = 9; - } else { - dev_warn(dev, - "9-bit SPI not available, emulating using 8-bit.\n"); - /* allocate buffer with room for dc bits */ - par->extra = devm_kzalloc(par->info->device, - par->txbuf.len + (par->txbuf.len / 8) + 8, - GFP_KERNEL); - if (!par->extra) { - ret = -ENOMEM; - goto out_release; - } - par->fbtftops.write = fbtft_write_spi_emulate_9; + break; } + + dev_warn(dev, + "9-bit SPI not available, emulating using 8-bit.\n"); + /* allocate buffer with room for dc bits */ + par->extra = devm_kzalloc(par->info->device, + par->txbuf.len + + (par->txbuf.len / 8) + 8, + GFP_KERNEL); + if (!par->extra) { + ret = -ENOMEM; + goto out_release; + } + par->fbtftops.write = fbtft_write_spi_emulate_9; + break; default: dev_err(dev, From c21cbb5ee3b2c21907915fd365ad1ad85579d603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:29:10 -0300 Subject: [PATCH 897/903] staging: fbtft: Adjust some empty-line problems - Style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Erases some blank lines. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_s6d02a1.c | 1 - drivers/staging/fbtft/fb_s6d1121.c | 1 + drivers/staging/fbtft/fb_ssd1289.c | 1 + drivers/staging/fbtft/fbtft_device.c | 2 -- 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fbtft/fb_s6d02a1.c b/drivers/staging/fbtft/fb_s6d02a1.c index 55513a395567..d3d6871d8c47 100644 --- a/drivers/staging/fbtft/fb_s6d02a1.c +++ b/drivers/staging/fbtft/fb_s6d02a1.c @@ -16,7 +16,6 @@ #define DRVNAME "fb_s6d02a1" static const s16 default_init_sequence[] = { - -1, 0xf0, 0x5a, 0x5a, -1, 0xfc, 0x5a, 0x5a, diff --git a/drivers/staging/fbtft/fb_s6d1121.c b/drivers/staging/fbtft/fb_s6d1121.c index c3e434d647b8..aa716f33420a 100644 --- a/drivers/staging/fbtft/fb_s6d1121.c +++ b/drivers/staging/fbtft/fb_s6d1121.c @@ -154,6 +154,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) return 0; } + #undef CURVE static struct fbtft_display display = { diff --git a/drivers/staging/fbtft/fb_ssd1289.c b/drivers/staging/fbtft/fb_ssd1289.c index 67b3f8548241..c9b18b3ba4ab 100644 --- a/drivers/staging/fbtft/fb_ssd1289.c +++ b/drivers/staging/fbtft/fb_ssd1289.c @@ -153,6 +153,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) return 0; } + #undef CURVE static struct fbtft_display display = { diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index 4110bba52e64..50e97da993e7 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -837,7 +837,6 @@ static struct fbtft_device_display displays[] = { } } }, { - .name = "piscreen", .spi = &(struct spi_board_info) { .modalias = "fb_ili9486", @@ -1580,7 +1579,6 @@ static void __exit fbtft_device_exit(void) if (p_device) platform_device_unregister(p_device); - } arch_initcall(fbtft_device_init); From 1315e8bad80c02a630e4f20e1518b21c3adef4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:29:18 -0300 Subject: [PATCH 898/903] staging: fbtft: Erases some repetitive usage of function name - Style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes this functions to avoid using "blank" on debug twice. Improves log readability. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_sh1106.c | 2 +- drivers/staging/fbtft/fb_ssd1306.c | 2 +- drivers/staging/fbtft/fb_ssd1325.c | 2 +- drivers/staging/fbtft/fb_ssd1331.c | 2 +- drivers/staging/fbtft/fb_ssd1351.c | 2 +- drivers/staging/fbtft/fb_uc1611.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/fbtft/fb_sh1106.c b/drivers/staging/fbtft/fb_sh1106.c index 3fc18c0a6f11..00096f8d249a 100644 --- a/drivers/staging/fbtft/fb_sh1106.c +++ b/drivers/staging/fbtft/fb_sh1106.c @@ -89,7 +89,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); write_reg(par, on ? 0xAE : 0xAF); diff --git a/drivers/staging/fbtft/fb_ssd1306.c b/drivers/staging/fbtft/fb_ssd1306.c index 9276be499303..50172ddd94ae 100644 --- a/drivers/staging/fbtft/fb_ssd1306.c +++ b/drivers/staging/fbtft/fb_ssd1306.c @@ -148,7 +148,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) diff --git a/drivers/staging/fbtft/fb_ssd1325.c b/drivers/staging/fbtft/fb_ssd1325.c index 1a469b3c92d4..f974f7fc4d79 100644 --- a/drivers/staging/fbtft/fb_ssd1325.c +++ b/drivers/staging/fbtft/fb_ssd1325.c @@ -88,7 +88,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) diff --git a/drivers/staging/fbtft/fb_ssd1331.c b/drivers/staging/fbtft/fb_ssd1331.c index 383e197cf56a..0b614c84822e 100644 --- a/drivers/staging/fbtft/fb_ssd1331.c +++ b/drivers/staging/fbtft/fb_ssd1331.c @@ -168,7 +168,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) write_reg(par, 0xAE); diff --git a/drivers/staging/fbtft/fb_ssd1351.c b/drivers/staging/fbtft/fb_ssd1351.c index ba78a7758fb7..3da091b4d297 100644 --- a/drivers/staging/fbtft/fb_ssd1351.c +++ b/drivers/staging/fbtft/fb_ssd1351.c @@ -163,7 +163,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) write_reg(par, 0xAE); diff --git a/drivers/staging/fbtft/fb_uc1611.c b/drivers/staging/fbtft/fb_uc1611.c index 4d65567eefe2..dfaf8bc70f73 100644 --- a/drivers/staging/fbtft/fb_uc1611.c +++ b/drivers/staging/fbtft/fb_uc1611.c @@ -129,7 +129,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) From 1b989094bae2d73ea65994cc388bb00585005556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Br=C3=A1s?= Date: Tue, 7 Aug 2018 21:29:49 -0300 Subject: [PATCH 899/903] staging: fbtft: Add spaces around / - Style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Puts spaces around the /. Signed-off-by: Leonardo Brás Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index a03d8adf3f9a..a2df02d97a8e 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -767,7 +767,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbops->fb_setcolreg = fbtft_fb_setcolreg; fbops->fb_blank = fbtft_fb_blank; - fbdefio->delay = HZ/fps; + fbdefio->delay = HZ / fps; fbdefio->deferred_io = fbtft_deferred_io; fb_deferred_io_init(info); From a621f75cb8dde0ea57ff14e001766da1f1347431 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 8 Aug 2018 13:06:21 +0200 Subject: [PATCH 900/903] staging: rtl8188eu: remove unused mp_custom_oid.h The header mp_custom_oid.h is not used, so remove it. 'git grep mp_custom_oid.h drivers/staging/rtl8188eu/' returns nothing. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/include/mp_custom_oid.h | 339 ------------------ 1 file changed, 339 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/mp_custom_oid.h diff --git a/drivers/staging/rtl8188eu/include/mp_custom_oid.h b/drivers/staging/rtl8188eu/include/mp_custom_oid.h deleted file mode 100644 index 8dd8451cbad0..000000000000 --- a/drivers/staging/rtl8188eu/include/mp_custom_oid.h +++ /dev/null @@ -1,339 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __CUSTOM_OID_H -#define __CUSTOM_OID_H - -/* by Owen */ -/* 0xFF818000 - 0xFF81802F RTL8180 Mass Production Kit */ -/* 0xFF818500 - 0xFF81850F RTL8185 Setup Utility */ -/* 0xFF818580 - 0xFF81858F RTL8185 Phy Status Utility */ - -/* */ - -/* by Owen for Production Kit */ -/* For Production Kit with Agilent Equipments */ -/* in order to make our custom oids hopefully somewhat unique */ -/* we will use 0xFF (indicating implementation specific OID) */ -/* 81(first byte of non zero Realtek unique identifier) */ -/* 80 (second byte of non zero Realtek unique identifier) */ -/* XX (the custom OID number - providing 255 possible custom oids) */ - -#define OID_RT_PRO_RESET_DUT 0xFF818000 -#define OID_RT_PRO_SET_DATA_RATE 0xFF818001 -#define OID_RT_PRO_START_TEST 0xFF818002 -#define OID_RT_PRO_STOP_TEST 0xFF818003 -#define OID_RT_PRO_SET_PREAMBLE 0xFF818004 -#define OID_RT_PRO_SET_SCRAMBLER 0xFF818005 -#define OID_RT_PRO_SET_FILTER_BB 0xFF818006 -#define OID_RT_PRO_SET_MANUAL_DIVERSITY_BB 0xFF818007 -#define OID_RT_PRO_SET_CHANNEL_DIRECT_CALL 0xFF818008 -#define OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL 0xFF818009 -#define OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL 0xFF81800A - -#define OID_RT_PRO_SET_TX_ANTENNA_BB 0xFF81800D -#define OID_RT_PRO_SET_ANTENNA_BB 0xFF81800E -#define OID_RT_PRO_SET_CR_SCRAMBLER 0xFF81800F -#define OID_RT_PRO_SET_CR_NEW_FILTER 0xFF818010 -#define OID_RT_PRO_SET_TX_POWER_CONTROL 0xFF818011 -#define OID_RT_PRO_SET_CR_TX_CONFIG 0xFF818012 -#define OID_RT_PRO_GET_TX_POWER_CONTROL 0xFF818013 -#define OID_RT_PRO_GET_CR_SIGNAL_QUALITY 0xFF818014 -#define OID_RT_PRO_SET_CR_SETPOINT 0xFF818015 -#define OID_RT_PRO_SET_INTEGRATOR 0xFF818016 -#define OID_RT_PRO_SET_SIGNAL_QUALITY 0xFF818017 -#define OID_RT_PRO_GET_INTEGRATOR 0xFF818018 -#define OID_RT_PRO_GET_SIGNAL_QUALITY 0xFF818019 -#define OID_RT_PRO_QUERY_EEPROM_TYPE 0xFF81801A -#define OID_RT_PRO_WRITE_MAC_ADDRESS 0xFF81801B -#define OID_RT_PRO_READ_MAC_ADDRESS 0xFF81801C -#define OID_RT_PRO_WRITE_CIS_DATA 0xFF81801D -#define OID_RT_PRO_READ_CIS_DATA 0xFF81801E -#define OID_RT_PRO_WRITE_POWER_CONTROL 0xFF81801F -#define OID_RT_PRO_READ_POWER_CONTROL 0xFF818020 -#define OID_RT_PRO_WRITE_EEPROM 0xFF818021 -#define OID_RT_PRO_READ_EEPROM 0xFF818022 -#define OID_RT_PRO_RESET_TX_PACKET_SENT 0xFF818023 -#define OID_RT_PRO_QUERY_TX_PACKET_SENT 0xFF818024 -#define OID_RT_PRO_RESET_RX_PACKET_RECEIVED 0xFF818025 -#define OID_RT_PRO_QUERY_RX_PACKET_RECEIVED 0xFF818026 -#define OID_RT_PRO_QUERY_RX_PACKET_CRC32_ERROR 0xFF818027 -#define OID_RT_PRO_QUERY_CURRENT_ADDRESS 0xFF818028 -#define OID_RT_PRO_QUERY_PERMANENT_ADDRESS 0xFF818029 -#define OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS 0xFF81802A -#define OID_RT_PRO_RECEIVE_PACKET 0xFF81802C -/* added by Owen on 04/08/03 for Cameo's request */ -#define OID_RT_PRO_WRITE_EEPROM_BYTE 0xFF81802D -#define OID_RT_PRO_READ_EEPROM_BYTE 0xFF81802E -#define OID_RT_PRO_SET_MODULATION 0xFF81802F -/* */ - -/* Sean */ -#define OID_RT_DRIVER_OPTION 0xFF818080 -#define OID_RT_RF_OFF 0xFF818081 -#define OID_RT_AUTH_STATUS 0xFF818082 - -/* */ -#define OID_RT_PRO_SET_CONTINUOUS_TX 0xFF81800B -#define OID_RT_PRO_SET_SINGLE_CARRIER_TX 0xFF81800C -#define OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX 0xFF81802B -#define OID_RT_PRO_SET_SINGLE_TONE_TX 0xFF818043 -/* */ - - -/* by Owen for RTL8185 Phy Status Report Utility */ -#define OID_RT_UTILITY_false_ALARM_COUNTERS 0xFF818580 -#define OID_RT_UTILITY_SELECT_DEBUG_MODE 0xFF818581 -#define OID_RT_UTILITY_SELECT_SUBCARRIER_NUMBER 0xFF818582 -#define OID_RT_UTILITY_GET_RSSI_STATUS 0xFF818583 -#define OID_RT_UTILITY_GET_FRAME_DETECTION_STATUS 0xFF818584 -#define OID_RT_UTILITY_GET_AGC_AND_FREQUENCY_OFFSET_ESTIMATION_STATUS \ - 0xFF818585 -#define OID_RT_UTILITY_GET_CHANNEL_ESTIMATION_STATUS 0xFF818586 -/* */ - -/* by Owen on 03/09/19-03/09/22 for RTL8185 */ -#define OID_RT_WIRELESS_MODE 0xFF818500 -#define OID_RT_SUPPORTED_RATES 0xFF818501 -#define OID_RT_DESIRED_RATES 0xFF818502 -#define OID_RT_WIRELESS_MODE_STARTING_ADHOC 0xFF818503 -/* */ - -#define OID_RT_GET_CONNECT_STATE 0xFF030001 -#define OID_RT_RESCAN 0xFF030002 -#define OID_RT_SET_KEY_LENGTH 0xFF030003 -#define OID_RT_SET_DEFAULT_KEY_ID 0xFF030004 - -#define OID_RT_SET_CHANNEL 0xFF010182 -#define OID_RT_SET_SNIFFER_MODE 0xFF010183 -#define OID_RT_GET_SIGNAL_QUALITY 0xFF010184 -#define OID_RT_GET_SMALL_PACKET_CRC 0xFF010185 -#define OID_RT_GET_MIDDLE_PACKET_CRC 0xFF010186 -#define OID_RT_GET_LARGE_PACKET_CRC 0xFF010187 -#define OID_RT_GET_TX_RETRY 0xFF010188 -#define OID_RT_GET_RX_RETRY 0xFF010189 -#define OID_RT_PRO_SET_FW_DIG_STATE 0xFF01018A/* S */ -#define OID_RT_PRO_SET_FW_RA_STATE 0xFF01018B/* S */ - -#define OID_RT_GET_RX_TOTAL_PACKET 0xFF010190 -#define OID_RT_GET_TX_BEACON_OK 0xFF010191 -#define OID_RT_GET_TX_BEACON_ERR 0xFF010192 -#define OID_RT_GET_RX_ICV_ERR 0xFF010193 -#define OID_RT_SET_ENCRYPTION_ALGORITHM 0xFF010194 -#define OID_RT_SET_NO_AUTO_RESCAN 0xFF010195 -#define OID_RT_GET_PREAMBLE_MODE 0xFF010196 -#define OID_RT_GET_DRIVER_UP_DELTA_TIME 0xFF010197 -#define OID_RT_GET_AP_IP 0xFF010198 -#define OID_RT_GET_CHANNELPLAN 0xFF010199 -#define OID_RT_SET_PREAMBLE_MODE 0xFF01019A -#define OID_RT_SET_BCN_INTVL 0xFF01019B -#define OID_RT_GET_RF_VENDER 0xFF01019C -#define OID_RT_DEDICATE_PROBE 0xFF01019D -#define OID_RT_PRO_RX_FILTER_PATTERN 0xFF01019E - -#define OID_RT_GET_DCST_CURRENT_THRESHOLD 0xFF01019F - -#define OID_RT_GET_CCA_ERR 0xFF0101A0 -#define OID_RT_GET_CCA_UPGRADE_THRESHOLD 0xFF0101A1 -#define OID_RT_GET_CCA_FALLBACK_THRESHOLD 0xFF0101A2 - -#define OID_RT_GET_CCA_UPGRADE_EVALUATE_TIMES 0xFF0101A3 -#define OID_RT_GET_CCA_FALLBACK_EVALUATE_TIMES 0xFF0101A4 - -/* by Owen on 03/31/03 for Cameo's request */ -#define OID_RT_SET_RATE_ADAPTIVE 0xFF0101A5 -/* */ -#define OID_RT_GET_DCST_EVALUATE_PERIOD 0xFF0101A5 -#define OID_RT_GET_DCST_TIME_UNIT_INDEX 0xFF0101A6 -#define OID_RT_GET_TOTAL_TX_BYTES 0xFF0101A7 -#define OID_RT_GET_TOTAL_RX_BYTES 0xFF0101A8 -#define OID_RT_CURRENT_TX_POWER_LEVEL 0xFF0101A9 -#define OID_RT_GET_ENC_KEY_MISMATCH_COUNT 0xFF0101AA -#define OID_RT_GET_ENC_KEY_MATCH_COUNT 0xFF0101AB -#define OID_RT_GET_CHANNEL 0xFF0101AC - -#define OID_RT_SET_CHANNELPLAN 0xFF0101AD -#define OID_RT_GET_HARDWARE_RADIO_OFF 0xFF0101AE -#define OID_RT_CHANNELPLAN_BY_COUNTRY 0xFF0101AF -#define OID_RT_SCAN_AVAILABLE_BSSID 0xFF0101B0 -#define OID_RT_GET_HARDWARE_VERSION 0xFF0101B1 -#define OID_RT_GET_IS_ROAMING 0xFF0101B2 -#define OID_RT_GET_IS_PRIVACY 0xFF0101B3 -#define OID_RT_GET_KEY_MISMATCH 0xFF0101B4 -#define OID_RT_SET_RSSI_ROAM_TRAFFIC_TH 0xFF0101B5 -#define OID_RT_SET_RSSI_ROAM_SIGNAL_TH 0xFF0101B6 -#define OID_RT_RESET_LOG 0xFF0101B7 -#define OID_RT_GET_LOG 0xFF0101B8 -#define OID_RT_SET_INDICATE_HIDDEN_AP 0xFF0101B9 -#define OID_RT_GET_HEADER_FAIL 0xFF0101BA -#define OID_RT_SUPPORTED_WIRELESS_MODE 0xFF0101BB -#define OID_RT_GET_CHANNEL_LIST 0xFF0101BC -#define OID_RT_GET_SCAN_IN_PROGRESS 0xFF0101BD -#define OID_RT_GET_TX_INFO 0xFF0101BE -#define OID_RT_RF_READ_WRITE_OFFSET 0xFF0101BF -#define OID_RT_RF_READ_WRITE 0xFF0101C0 - -/* For Netgear request. 2005.01.13, by rcnjko. */ -#define OID_RT_FORCED_DATA_RATE 0xFF0101C1 -#define OID_RT_WIRELESS_MODE_FOR_SCAN_LIST 0xFF0101C2 -/* For Netgear request. 2005.02.17, by rcnjko. */ -#define OID_RT_GET_BSS_WIRELESS_MODE 0xFF0101C3 -/* For AZ project. 2005.06.27, by rcnjko. */ -#define OID_RT_SCAN_WITH_MAGIC_PACKET 0xFF0101C4 - -/* Vincent 8185MP */ -#define OID_RT_PRO_RX_FILTER 0xFF0111C0 - -#define OID_CE_USB_WRITE_REGISTRY 0xFF0111C1 -#define OID_CE_USB_READ_REGISTRY 0xFF0111C2 - -#define OID_RT_PRO_SET_INITIAL_GA 0xFF0111C3 -#define OID_RT_PRO_SET_BB_RF_STANDBY_MODE 0xFF0111C4 -#define OID_RT_PRO_SET_BB_RF_SHUTDOWN_MODE 0xFF0111C5 -#define OID_RT_PRO_SET_TX_CHARGE_PUMP 0xFF0111C6 -#define OID_RT_PRO_SET_RX_CHARGE_PUMP 0xFF0111C7 -#define OID_RT_PRO_RF_WRITE_REGISTRY 0xFF0111C8 -#define OID_RT_PRO_RF_READ_REGISTRY 0xFF0111C9 -#define OID_RT_PRO_QUERY_RF_TYPE 0xFF0111CA - -/* AP OID */ -#define OID_RT_AP_GET_ASSOCIATED_STATION_LIST 0xFF010300 -#define OID_RT_AP_GET_CURRENT_TIME_STAMP 0xFF010301 -#define OID_RT_AP_SWITCH_INTO_AP_MODE 0xFF010302 -#define OID_RT_AP_SET_DTIM_PERIOD 0xFF010303 -/* Determine if driver supports AP mode. */ -#define OID_RT_AP_SUPPORTED 0xFF010304 -/* Set WPA-PSK passphrase into authenticator. */ -#define OID_RT_AP_SET_PASSPHRASE 0xFF010305 - -/* 8187MP. 2004.09.06, by rcnjko. */ -#define OID_RT_PRO8187_WI_POLL 0xFF818780 -#define OID_RT_PRO_WRITE_BB_REG 0xFF818781 -#define OID_RT_PRO_READ_BB_REG 0xFF818782 -#define OID_RT_PRO_WRITE_RF_REG 0xFF818783 -#define OID_RT_PRO_READ_RF_REG 0xFF818784 - -/* Meeting House. added by Annie, 2005-07-20. */ -#define OID_RT_MH_VENDER_ID 0xFFEDC100 - -/* 8711 MP OID added 20051230. */ -#define OID_RT_PRO8711_JOIN_BSS 0xFF871100/* S */ - -#define OID_RT_PRO_READ_REGISTER 0xFF871101 /* Q */ -#define OID_RT_PRO_WRITE_REGISTER 0xFF871102 /* S */ - -#define OID_RT_PRO_BURST_READ_REGISTER 0xFF871103 /* Q */ -#define OID_RT_PRO_BURST_WRITE_REGISTER 0xFF871104 /* S */ - -#define OID_RT_PRO_WRITE_TXCMD 0xFF871105 /* S */ - -#define OID_RT_PRO_READ16_EEPROM 0xFF871106 /* Q */ -#define OID_RT_PRO_WRITE16_EEPROM 0xFF871107 /* S */ - -#define OID_RT_PRO_H2C_SET_COMMAND 0xFF871108 /* S */ -#define OID_RT_PRO_H2C_QUERY_RESULT 0xFF871109 /* Q */ - -#define OID_RT_PRO8711_WI_POLL 0xFF87110A /* Q */ -#define OID_RT_PRO8711_PKT_LOSS 0xFF87110B /* Q */ -#define OID_RT_RD_ATTRIB_MEM 0xFF87110C/* Q */ -#define OID_RT_WR_ATTRIB_MEM 0xFF87110D/* S */ - - -/* Method 2 for H2C/C2H */ -#define OID_RT_PRO_H2C_CMD_MODE 0xFF871110 /* S */ -#define OID_RT_PRO_H2C_CMD_RSP_MODE 0xFF871111 /* Q */ -#define OID_RT_PRO_H2C_CMD_EVENT_MODE 0xFF871112 /* S */ -#define OID_RT_PRO_WAIT_C2H_EVENT 0xFF871113 /* Q */ -#define OID_RT_PRO_RW_ACCESS_PROTOCOL_TEST 0xFF871114/* Q */ - -#define OID_RT_PRO_SCSI_ACCESS_TEST 0xFF871115 /* Q, S */ - -#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_OUT 0xFF871116 /* S */ -#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_IN 0xFF871117 /* Q,S */ -#define OID_RT_RRO_RX_PKT_VIA_IOCTRL 0xFF871118 /* Q */ -#define OID_RT_RRO_RX_PKTARRAY_VIA_IOCTRL 0xFF871119 /* Q */ - -#define OID_RT_RPO_SET_PWRMGT_TEST 0xFF87111A /* S */ -#define OID_RT_PRO_QRY_PWRMGT_TEST 0XFF87111B /* Q */ -#define OID_RT_RPO_ASYNC_RWIO_TEST 0xFF87111C /* S */ -#define OID_RT_RPO_ASYNC_RWIO_POLL 0xFF87111D /* Q */ -#define OID_RT_PRO_SET_RF_INTFS 0xFF87111E /* S */ -#define OID_RT_POLL_RX_STATUS 0xFF87111F /* Q */ - -#define OID_RT_PRO_CFG_DEBUG_MESSAGE 0xFF871120 /* Q,S */ -#define OID_RT_PRO_SET_DATA_RATE_EX 0xFF871121/* S */ -#define OID_RT_PRO_SET_BASIC_RATE 0xFF871122/* S */ -#define OID_RT_PRO_READ_TSSI 0xFF871123/* S */ -#define OID_RT_PRO_SET_POWER_TRACKING 0xFF871124/* S */ - - -#define OID_RT_PRO_QRY_PWRSTATE 0xFF871150 /* Q */ -#define OID_RT_PRO_SET_PWRSTATE 0xFF871151 /* S */ - -/* Method 2 , using workitem */ -#define OID_RT_SET_READ_REG 0xFF871181 /* S */ -#define OID_RT_SET_WRITE_REG 0xFF871182 /* S */ -#define OID_RT_SET_BURST_READ_REG 0xFF871183 /* S */ -#define OID_RT_SET_BURST_WRITE_REG 0xFF871184 /* S */ -#define OID_RT_SET_WRITE_TXCMD 0xFF871185 /* S */ -#define OID_RT_SET_READ16_EEPROM 0xFF871186 /* S */ -#define OID_RT_SET_WRITE16_EEPROM 0xFF871187 /* S */ -#define OID_RT_QRY_POLL_WKITEM 0xFF871188 /* Q */ - -/* For SDIO INTERFACE only */ -#define OID_RT_PRO_SYNCPAGERW_SRAM 0xFF8711A0 /* Q, S */ -#define OID_RT_PRO_871X_DRV_EXT 0xFF8711A1 - -/* For USB INTERFACE only */ -#define OID_RT_PRO_USB_VENDOR_REQ 0xFF8711B0 /* Q, S */ -#define OID_RT_PRO_SCSI_AUTO_TEST 0xFF8711B1 /* S */ -#define OID_RT_PRO_USB_MAC_AC_FIFO_WRITE 0xFF8711B2 /* S */ -#define OID_RT_PRO_USB_MAC_RX_FIFO_READ 0xFF8711B3 /* Q */ -#define OID_RT_PRO_USB_MAC_RX_FIFO_POLLING 0xFF8711B4 /* Q */ - -#define OID_RT_PRO_H2C_SET_RATE_TABLE 0xFF8711FB /* S */ -#define OID_RT_PRO_H2C_GET_RATE_TABLE 0xFF8711FC /* S */ -#define OID_RT_PRO_H2C_C2H_LBK_TEST 0xFF8711FE - -#define OID_RT_PRO_ENCRYPTION_CTRL 0xFF871200 /* Q, S */ -#define OID_RT_PRO_ADD_STA_INFO 0xFF871201 /* S */ -#define OID_RT_PRO_DELE_STA_INFO 0xFF871202 /* S */ -#define OID_RT_PRO_QUERY_DR_VARIABLE 0xFF871203 /* Q */ - -#define OID_RT_PRO_RX_PACKET_TYPE 0xFF871204 /* Q, S */ - -#define OID_RT_PRO_READ_EFUSE 0xFF871205 /* Q */ -#define OID_RT_PRO_WRITE_EFUSE 0xFF871206 /* S */ -#define OID_RT_PRO_RW_EFUSE_PGPKT 0xFF871207 /* Q, S */ -#define OID_RT_GET_EFUSE_CURRENT_SIZE 0xFF871208 /* Q */ - -#define OID_RT_SET_BANDWIDTH 0xFF871209 /* S */ -#define OID_RT_SET_CRYSTAL_CAP 0xFF87120A /* S */ - -#define OID_RT_SET_RX_PACKET_TYPE 0xFF87120B /* S */ - -#define OID_RT_GET_EFUSE_MAX_SIZE 0xFF87120C /* Q */ - -#define OID_RT_PRO_SET_TX_AGC_OFFSET 0xFF87120D /* S */ - -#define OID_RT_PRO_SET_PKT_TEST_MODE 0xFF87120E /* S */ - -#define OID_RT_PRO_FOR_EVM_TEST_SETTING 0xFF87120F /* S */ - -#define OID_RT_PRO_GET_THERMAL_METER 0xFF871210 /* Q */ - -#define OID_RT_RESET_PHY_RX_PACKET_COUNT 0xFF871211 /* S */ -#define OID_RT_GET_PHY_RX_PACKET_RECEIVED 0xFF871212 /* Q */ -#define OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR 0xFF871213 /* Q */ - -#define OID_RT_SET_POWER_DOWN 0xFF871214 /* S */ - -#define OID_RT_GET_POWER_MODE 0xFF871215 /* Q */ - -#define OID_RT_PRO_EFUSE 0xFF871216 /* Q, S */ -#define OID_RT_PRO_EFUSE_MAP 0xFF871217 /* Q, S */ - -#endif /* ifndef __CUSTOM_OID_H */ From 976418c5771992948753e875340f5b07505d3a28 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 7 Aug 2018 22:12:39 +0100 Subject: [PATCH 901/903] staging:rtl8192u: Remove stale comment - Style Remove a comment which appears to be from a previous version of code. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 5639bb498865..d4c8c28190ff 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -17,8 +17,6 @@ enum dot11d_state { }; struct rt_dot11d_info { - /* DECLARE_RT_OBJECT(rt_dot11d_info); */ - bool enabled; /* dot11MultiDomainCapabilityEnabled */ u16 country_ie_len; /* > 0 if country_ie_buf[] contains valid country information element. */ From 6a2e1905bfb9c826bcc0c866a8abfb8802a02ab7 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 7 Aug 2018 22:12:40 +0100 Subject: [PATCH 902/903] staging:rtl8192u: Add spaces around '+' operator - Style Add spaces around '+' operator as required by the coding standard. This clears the checkpatch issue. This change is purely coding style in nature and should have not effect on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index d4c8c28190ff..8d4d5e582782 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -24,8 +24,8 @@ struct rt_dot11d_info { u8 country_ie_src_addr[6]; /* Source AP of the country IE. */ u8 country_ie_watchdog; - u8 channel_map[MAX_CHANNEL_NUMBER+1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ - u8 max_tx_pwr_dbm_list[MAX_CHANNEL_NUMBER+1]; + u8 channel_map[MAX_CHANNEL_NUMBER + 1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ + u8 max_tx_pwr_dbm_list[MAX_CHANNEL_NUMBER + 1]; enum dot11d_state state; }; From e4f6a44c4aeca9eda153302abb0c14d053914f72 Mon Sep 17 00:00:00 2001 From: John Whitmore Date: Tue, 7 Aug 2018 22:12:41 +0100 Subject: [PATCH 903/903] staging:rtl8192u: Remove unused macro definitions - Style Removed unused macro definitions as they add nothing to the code. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.h b/drivers/staging/rtl8192u/ieee80211/dot11d.h index 8d4d5e582782..363a6bed18dd 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.h +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.h @@ -45,18 +45,10 @@ struct rt_dot11d_info { #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->country_ie_src_addr, __pTa) #define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->country_ie_src_addr, __pTa) -#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \ - (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->country_ie_len) ? \ - FALSE : \ - (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->country_ie_buf, (__Ie).Octet, (__Ie).Length))) - -#define CIE_WATCHDOG_TH 1 #define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->country_ie_watchdog) #define RESET_CIE_WATCHDOG(__pIeeeDev) (GET_CIE_WATCHDOG(__pIeeeDev) = 0) #define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev)) -#define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE) - void Dot11d_Init( struct ieee80211_device *dev