diff options
235 files changed, 3855 insertions, 6088 deletions
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: [email protected] +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/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 <Documentation/devicetree/bindings/iio/iio-bindings.txt> for details. + +Properties for consumer drivers: + - Consumer drivers can be connected to this producer device, as specified + in <Documentation/devicetree/bindings/iio/iio-bindings.txt> + - Channels exposed are specified in: + <dt-bindings/iio/adc/at91-sama5d2_adc.txt> Example: @@ -38,4 +46,5 @@ adc: adc@fc030000 { atmel,trigger-edge-type = <IRQ_TYPE_EDGE_BOTH>; dmas = <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(25))>; dma-names = "rx"; + #io-channel-cells = <1>; } diff --git a/Documentation/devicetree/bindings/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"; + }; 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 diff --git a/MAINTAINERS b/MAINTAINERS index 07d1576fc766..681c9e411b86 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2547,6 +2547,13 @@ S: Maintained F: drivers/auxdisplay/ F: include/linux/cfag12864b.h +AVIA HX711 ANALOG DIGITAL CONVERTER IIO DRIVER +M: Andreas Klinger <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/iio/adc/avia-hx711.txt +F: drivers/iio/adc/hx711.c + AX.25 NETWORK LAYER M: Ralf Baechle <[email protected]> @@ -6005,6 +6012,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 <[email protected]> +S: Maintained +F: drivers/input/touchscreen/resistive-adc-touch.c + GENERIC UIO DRIVER FOR PCI DEVICES M: "Michael S. Tsirkin" <[email protected]> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 9da79070357c..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 @@ -717,6 +715,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 diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 8729d6524b4d..e02f7d1c86bc 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 */ @@ -118,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 */ @@ -131,8 +152,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 +202,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 +226,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. @@ -184,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, \ @@ -192,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, \ } @@ -212,16 +291,50 @@ .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, \ } +#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)|\ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .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)|\ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .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 +373,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,14 +396,17 @@ 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; 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; + struct at91_adc_touch touch_st; u16 buffer[AT91_BUFFER_MAX_HWORDS]; /* * lock to prevent concurrent 'single conversion' requests through @@ -329,8 +461,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 +488,231 @@ 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 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; + 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 +734,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 +884,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 +913,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 +947,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); } @@ -613,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, @@ -622,7 +1016,24 @@ 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) { + 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"); + } i++; } iio_push_to_buffers_with_timestamp(indio_dev, st->buffer, @@ -654,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)); @@ -688,9 +1107,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 +1166,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; + + 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); - return f_adc; + iio_push_to_buffers(indio_dev, st->buffer); } static irqreturn_t at91_adc_interrupt(int irq, void *private) @@ -757,17 +1251,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 +1291,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; + ret = at91_adc_read_position(st, chan->channel, + (u16 *)val); + mutex_unlock(&st->lock); + iio_device_release_direct_mode(indio_dev); - 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; - } + return at91_adc_adjust_val_osr(st, val); + } + if (chan->type == IIO_PRESSURE) { + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + mutex_lock(&st->lock); - at91_adc_writel(st, AT91_SAMA5D2_IDR, BIT(chan->channel)); - at91_adc_writel(st, AT91_SAMA5D2_CHDR, BIT(chan->channel)); + ret = at91_adc_read_pressure(st, chan->channel, + (u16 *)val); + mutex_unlock(&st->lock); + iio_device_release_direct_mode(indio_dev); - /* Needed to ACK the DRDY interruption */ - at91_adc_readl(st, AT91_SAMA5D2_LCDR); + return at91_adc_adjust_val_osr(st, val); + } - mutex_unlock(&st->lock); + /* in this case we have a voltage channel */ - iio_device_release_direct_mode(indio_dev); + 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; + ret = at91_adc_adjust_val_osr(st, val); + if (chan->scan_type.sign == 's') + *val = sign_extend32(*val, 11); + 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) @@ -838,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; } @@ -849,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) - return -EINVAL; + 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; - if (val < st->soc_info.min_sample_rate || - val > st->soc_info.max_sample_rate) + at91_adc_setup_samp_freq(st, val); + return 0; + default: return -EINVAL; - - at91_adc_setup_samp_freq(st, val); - - return 0; + }; } static void at91_adc_dma_init(struct platform_device *pdev) @@ -974,11 +1545,23 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) return 0; } -static const struct iio_info at91_adc_info = { - .read_raw = &at91_adc_read_raw, - .write_raw = &at91_adc_write_raw, - .hwfifo_set_watermark = &at91_adc_set_watermark, -}; +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 void at91_adc_hw_init(struct at91_adc_state *st) { @@ -992,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, @@ -1022,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, @@ -1030,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; @@ -1044,13 +1653,22 @@ 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); + + 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); @@ -1100,6 +1718,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 +1778,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 +1891,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: diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c index b56985078d8c..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(0x02, 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); } 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}, diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 42618fe4f83e..0f6efe913b5f 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 <linux/jiffies.h> #include <linux/irq.h> #include <linux/interrupt.h> -#include <linux/kfifo.h> -#include <linux/spinlock.h> #include <linux/iio/iio.h> #include <linux/acpi.h> #include <linux/platform_device.h> @@ -84,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, @@ -280,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; @@ -297,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: @@ -630,7 +635,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); @@ -646,8 +651,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; } @@ -655,11 +665,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) @@ -687,7 +696,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); @@ -1005,7 +1014,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) { @@ -1018,8 +1027,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..de8391693e17 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 <linux/i2c.h> #include <linux/i2c-mux.h> -#include <linux/kfifo.h> -#include <linux/spinlock.h> #include <linux/mutex.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h> @@ -88,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; @@ -96,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; }; @@ -116,40 +114,40 @@ 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. + * @chip_period: chip internal period estimation (~1kHz). + * @it_timestamp: timestamp from previous interrupt. + * @data_timestamp: timestamp for next data sample. */ 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; unsigned skip_samples; + s64 chip_period; + s64 it_timestamp; + s64 data_timestamp; }; /*register and associated bit definition*/ @@ -174,6 +172,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 @@ -198,7 +197,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 @@ -231,13 +229,24 @@ 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 -#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 + +/* 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 @@ -300,7 +309,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..548e042f7b5b 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -19,18 +19,83 @@ #include <linux/jiffies.h> #include <linux/irq.h> #include <linux/interrupt.h> -#include <linux/kfifo.h> #include <linux/poll.h> +#include <linux/math64.h> +#include <asm/unaligned.h> #include "inv_mpu_iio.h" -static void inv_clear_kfifo(struct inv_mpu6050_state *st) +/** + * 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) { - unsigned long flags; + /* 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; + } - /* 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); + /* 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) @@ -39,6 +104,9 @@ int inv_reset_fifo(struct iio_dev *indio_dev) 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) { @@ -62,9 +130,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) { @@ -99,23 +164,6 @@ reset_fifo_fail: } /** - * 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. */ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) @@ -129,6 +177,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) u16 fifo_count; s64 timestamp; int int_status; + size_t i, nb; mutex_lock(&st->lock); @@ -139,6 +188,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); @@ -163,38 +215,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; - 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 { + 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); 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) + 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; + } + timestamp = inv_mpu6050_get_timestamp(st); + iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); + } end_session: mutex_unlock(&st->lock); diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 19bdf3d2962a..ed1b3ebade94 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[] = { @@ -207,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); 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 <[email protected]> + * + */ +#include <linux/input.h> +#include <linux/input/touchscreen.h> +#include <linux/iio/consumer.h> +#include <linux/iio/iio.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> + +#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 <[email protected]>"); +MODULE_DESCRIPTION("Generic ADC Resistive Touch Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index a1a0025b59e0..e392358ec244 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,20 @@ 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 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 (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 +492,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 +530,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 +569,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 +707,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 +862,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 +870,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; } 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); 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. 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 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. 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 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 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 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; 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 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 (scans_left) { - samples_left = ((unsigned long long)scans_left * - cmd->scan_end_arg) - scan_pos; - } + if (cmd->stop_src != TRIG_COUNT) + return nsamples; - if (samples_left < nsamples) - nsamples = samples_left; - } + scans_left = __comedi_nscans_left(s, cmd->stop_arg); + if (!scans_left) + return 0; + + 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); 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, 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, 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 */ 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 <[email protected]>"); -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"); 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[] = { 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[] = { 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; diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index bd559956f199..b7004edd3ce2 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -28,6 +28,7 @@ #include <linux/uaccess.h> #include <linux/slab.h> #include <linux/goldfish.h> +#include <linux/acpi.h> MODULE_AUTHOR("Google, Inc."); MODULE_DESCRIPTION("Android QEMU Audio Driver"); @@ -61,11 +62,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,10 +108,30 @@ 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) { struct goldfish_audio *data = fp->private_data; + unsigned long irq_flags; int length; int result = 0; @@ -124,12 +140,16 @@ 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); + spin_lock_irqsave(&data->lock, irq_flags); + data->buffer_status &= ~AUDIO_INT_READ_BUFFER_FULL; + spin_unlock_irqrestore(&data->lock, irq_flags); + + length = audio_read(data, AUDIO_READ_BUFFER_AVAILABLE); /* copy data to user space */ if (copy_to_user(buf, data->read_buffer, length)) @@ -177,10 +197,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 +220,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 +232,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 +255,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 @@ -295,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; @@ -320,18 +341,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; @@ -351,12 +372,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), } }; 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/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; 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; 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, 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 <linux/module.h> -#include <linux/delay.h> -#include <linux/mutex.h> -#include <linux/device.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/slab.h> -#include <linux/sysfs.h> - -#include <linux/iio/iio.h> -#include <linux/iio/sysfs.h> - -#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 <[email protected]>"); -MODULE_DESCRIPTION("Analog Devices ADIS16060 Yaw Rate Gyroscope Driver"); -MODULE_LICENSE("GPL v2"); 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); diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index 6b13d85d9d34..d5b27e224b56 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts @@ -24,15 +24,12 @@ }; }; - gpio-keys-polled { - compatible = "gpio-keys-polled"; - #address-cells = <1>; - #size-cells = <0>; - poll-interval = <20>; + gpio-keys { + compatible = "gpio-keys"; reset { label = "reset"; - gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; + gpios = <&gpio 18 GPIO_ACTIVE_HIGH>; linux,code = <KEY_RESTART>; }; }; @@ -42,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>; }; }; }; @@ -74,7 +71,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 +101,8 @@ &sysclock { compatible = "fixed-clock"; - clock-frequency = <90000000>; + /* This is normally 1/4 of cpuclock */ + clock-frequency = <225000000>; }; &cpuclock { @@ -113,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 eb3966b7f033..a87fcc6d61b2 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 { @@ -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 = <GIC_SHARED 12 IRQ_TYPE_LEVEL_HIGH>; - 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 { @@ -447,31 +424,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>; }; }; }; diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c index 2c7a2e666bfb..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); @@ -2012,8 +2011,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 +2038,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 +2047,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) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index c741ec3f4e50..5485dd2d9b61 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -1,6 +1,8 @@ config GPIO_MT7621 - bool "Mediatek GPIO Support" - depends on SOC_MT7620 || SOC_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 SoC GPIO device + Say yes here to support the Mediatek MT7621 SoC GPIO device diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 0c4fb4a1b4a9..281e6214d543 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -5,33 +5,29 @@ */ #include <linux/err.h> -#include <linux/gpio.h> #include <linux/gpio/driver.h> #include <linux/interrupt.h> #include <linux/io.h> -#include <linux/irqdomain.h> #include <linux/module.h> #include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/spinlock.h> -#define MTK_BANK_CNT 3 -#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 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; @@ -39,12 +35,24 @@ struct mtk_gc { 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 irq_domain *gpio_irq_domain; struct mtk_gc gc_map[MTK_BANK_CNT]; }; @@ -55,272 +63,227 @@ 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) -{ - struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip); - u32 offset = (reg * 0x10) + (rg->bank * 0x4); - - 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) +mtk_gpio_r32(struct mtk_gc *rg, u32 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); + struct gpio_chip *gc = &rg->chip; + struct mtk_data *gpio_data = gpiochip_get_data(gc); - return 0; + offset = (rg->bank * GPIO_BANK_WIDE) + offset; + return gc->read_reg(gpio_data->gpio_membase + offset); } -static int -mediatek_gpio_direction_output(struct gpio_chip *chip, - unsigned int offset, int value) +static irqreturn_t +mediatek_gpio_irq_handler(int irq, void *data) { - struct mtk_gc *rg = to_mediatek_gpio(chip); - unsigned long flags; - u32 t; + struct gpio_chip *gc = data; + struct mtk_gc *rg = to_mediatek_gpio(gc); + irqreturn_t ret = IRQ_NONE; + unsigned long pending; + int bit; - 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); + pending = mtk_gpio_r32(rg, GPIO_REG_STAT); - return 0; -} + for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) { + u32 map = irq_find_mapping(gc->irq.domain, bit); -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; -} - -static int -mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin) -{ - struct mtk_data *gpio_data = gpiochip_get_data(chip); - struct mtk_gc *rg = to_mediatek_gpio(chip); - - 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_data = dev_get_drvdata(&pdev->dev); - const __be32 *id = of_get_property(bank, "reg", NULL); - struct mtk_gc *rg; - int ret; - - if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT) - return -EINVAL; - - rg = &gpio_data->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); - if (ret < 0) { - dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n", - rg->chip.ngpio, ret); - return ret; + generic_handle_irq(map); + mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit)); + ret |= IRQ_HANDLED; } - /* 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); - - for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) { - u32 map = irq_find_mapping(gpio_data->gpio_irq_domain, - (MTK_BANK_WIDTH * i) + bit); - - generic_handle_irq(map); - mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit)); - } - } + 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; - - if (!rg) - return; + 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); - 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)); + 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 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; - - if (!rg) - return; + 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); - mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~PIN_MASK(pin)); - mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~PIN_MASK(pin)); + 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 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) - return -1; + u32 mask = BIT(pin); 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; + break; + case IRQ_TYPE_EDGE_RISING: + rg->rising |= mask; + break; + case IRQ_TYPE_EDGE_FALLING: rg->falling |= mask; - else - 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 = { - .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_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_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 *node, int bank) { + struct mtk_data *gpio = dev_get_drvdata(&pdev->dev); + struct mtk_gc *rg; + void __iomem *dat, *set, *ctrl, *diro; int ret; - ret = irq_set_chip_data(irq, d->host_data); - if (ret < 0) + rg = &gpio->gc_map[bank]; + memset(rg, 0, sizeof(*rg)); + + spin_lock_init(&rg->lock); + 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); + 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; + } + + 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; - irq_set_chip_and_handler(irq, &mediatek_gpio_irq_chip, - handle_level_irq); - irq_set_handler_data(irq, d); + } + + 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; + } + + 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) { + 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) { - 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) @@ -331,24 +294,11 @@ 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); - for_each_child_of_node(np, bank) - 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); + for (i = 0; i < MTK_BANK_CNT; i++) + mediatek_gpio_bank_probe(pdev, np, i); return 0; } @@ -367,4 +317,4 @@ static struct platform_driver mediatek_gpio_driver = { }, }; -module_platform_driver(mediatek_gpio_driver); +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 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 <dt-bindings/gpio/gpio.h>. + 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 <dt-bindings/gpio/gpio.h>. - 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 = <GIC_SHARED 12 IRQ_TYPE_LEVEL_HIGH>; - 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>; - }; }; 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 */ diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h b/drivers/staging/mt7621-mmc/mt6575_sd.h index 33fa59a019ec..4e287c140acb 100644 --- a/drivers/staging/mt7621-mmc/mt6575_sd.h +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h @@ -42,11 +42,6 @@ // #include <mach/mt6575_reg_base.h> /* --- by chhung */ /*--------------------------------------------------------------------------*/ -/* Common Macro */ -/*--------------------------------------------------------------------------*/ -#define REG_ADDR(x) (base + OFFSET_##x) - -/*--------------------------------------------------------------------------*/ /* Common Definition */ /*--------------------------------------------------------------------------*/ #define MSDC_FIFO_SZ (128) @@ -56,13 +51,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) @@ -102,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 */ @@ -478,422 +400,7 @@ 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 */ - u8 mode; /* dma mode */ - 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 */ @@ -947,11 +454,6 @@ struct msdc_host { u32 app_cmd_arg; }; -#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) { u32 val = readl(reg); diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 648a2dd1436e..04d23cc7cd4a 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -50,15 +50,11 @@ #include "dbg.h" #include "mt6575_sd.h" -//#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*/ #define DRV_NAME "mtk-sd" @@ -91,10 +87,8 @@ #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) #define MAX_SGMT_SZ (MAX_DMA_CNT) #define MAX_REQ_SZ (MAX_SGMT_SZ * 8) @@ -147,59 +141,37 @@ 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_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) - -#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) +#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 (sdr_read32(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 = sdr_read32(MSDC_INT); \ - sdr_write32(MSDC_INT, val); \ + volatile u32 val = readl(host->base + MSDC_INT); \ + writel(val, host->base + MSDC_INT); \ } while (0) -#define msdc_clr_fifo() \ - 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); \ - } while (0) +static void msdc_clr_fifo(struct msdc_host *host) +{ + 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 = sdr_read32(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 */ @@ -237,19 +209,15 @@ 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(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 { \ - sdr_write32(SDC_ARG, (arg)); \ - sdr_write32(SDC_CMD, (cmd)); \ + writel((arg), host->base + SDC_ARG); \ + writel((cmd), host->base + SDC_CMD); \ } 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) (((struct msdc_host *)(h))->card_inserted) - /* +++ by chhung */ #ifndef __ASSEMBLY__ #define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff) @@ -404,7 +372,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; @@ -416,7 +383,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); @@ -426,14 +393,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 = sdr_read32(MSDC_PS); + status = readl(host->base + MSDC_PS); if (cd_active_low) inserted = (status & MSDC_PS_CDSTS) ? 0 : 1; else @@ -471,19 +437,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 = sdr_read32(MSDC_CLKSRC_REG); - if (sdr_read32(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; } - sdr_write32(MSDC_CLKSRC_REG, val); + writel(val, host->base + MSDC_CLKSRC_REG); host->hclk = hclks[clksrc]; host->hw->clk_src = clksrc; @@ -493,7 +458,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; @@ -534,11 +498,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 (!(sdr_read32(MSDC_CFG) & MSDC_CFG_CKSTB)) + while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) cpu_relax(); host->sclk = sclk; @@ -555,13 +519,12 @@ 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."); msdc_reset_hw(host); - msdc_clr_fifo(); + msdc_clr_fifo(host); msdc_clr_int(); // need to check FIFO count 0 ? @@ -580,7 +543,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 */ @@ -593,27 +555,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; } @@ -624,7 +586,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 */ @@ -633,9 +594,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); } } @@ -744,30 +705,12 @@ 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, - int tune, /* not used */ - unsigned long timeout) +static inline u32 msdc_cmd_find_resp(struct mmc_command *cmd) { - void __iomem *base = host->base; 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) { + 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; @@ -800,6 +743,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 | @@ -870,7 +837,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: @@ -883,19 +850,15 @@ 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 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); + //sdr_set_bits(host->base + MSDC_INTEN, wints); spin_unlock(&host->lock); if (!wait_for_completion_timeout(&host->cmd_done, 10 * timeout)) { @@ -905,7 +868,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: @@ -950,12 +913,13 @@ 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 */ + /* check if has data phase */ + if (readl(host->base + SDC_CMD) & 0x1800) { msdc_abort_data(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); @@ -963,7 +927,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(host->base + MSDC_PS) & 0x10000) != 0x10000); } */ /* CMD12 Error Handle */ @@ -975,7 +939,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)) @@ -991,9 +955,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"); } @@ -1001,31 +963,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", sdr_read32(MSDC_DMA_CFG)); - //while (sdr_read32(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 (sdr_read32(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"); } @@ -1040,97 +1000,54 @@ 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; - switch (dma->mode) { - 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))); - 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)); -//#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: - - /* 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); - } + BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ - 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); + N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size); - sdr_write32(MSDC_DMA_SA, PHYSADDR((u32)dma->gpd_addr)); - break; - - default: - break; - } + gpd = dma->gpd; + bd = dma->bd; - 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)); + /* 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(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); -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 */ + if (j == sglen - 1) + bd[j].eol = 1; /* the last bd */ + else + bd[j].eol = 0; - dma->sg = sg; - dma->sglen = sglen; + bd[j].chksum = 0; /* checksume need to clear first */ + bd[j].chksum = msdc_dma_calcs((u8 *)(&bd[j]), 16); + } - dma->mode = MSDC_MODE_DMA_DESC; + 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(host->base + MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1); - N_MSG(DMA, "DMA mode<%d> sglen<%d> xfersz<%d>", dma->mode, dma->sglen, - host->xfer_size); + writel(PHYSADDR((u32)dma->gpd_addr), host->base + MSDC_DMA_SA); - msdc_dma_config(host, dma); + 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) @@ -1139,7 +1056,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; @@ -1182,14 +1098,14 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) } } - sdr_write32(SDC_BLK_NUM, data->blocks); - //msdc_clr_fifo(); /* no need */ + writel(data->blocks, host->base + SDC_BLK_NUM); + //msdc_clr_fifo(host); /* no need */ msdc_dma_on(); /* enable DMA mode first!! */ 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, @@ -1210,14 +1126,18 @@ 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(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); - msdc_clr_fifo(); + msdc_clr_fifo(host); msdc_clr_int(); } spin_lock(&host->lock); @@ -1311,7 +1231,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; @@ -1322,8 +1241,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 { @@ -1334,7 +1254,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); @@ -1356,14 +1277,15 @@ 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 */ + /* 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; @@ -1373,7 +1295,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; @@ -1385,10 +1306,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 { @@ -1398,7 +1319,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); @@ -1409,14 +1331,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, - sdr_read32(MSDC_DAT_RDDLY0), sdr_read32(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) { @@ -1432,11 +1355,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(host->base + MSDC_DAT_RDDLY0); + cur_rxdly1 = readl(host->base + MSDC_DAT_RDDLY1); /* E1 ECO. YD: Reverse */ - if (sdr_read32(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; @@ -1475,8 +1398,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, host->base + MSDC_DAT_RDDLY0); + writel(cur_rxdly1, host->base + MSDC_DAT_RDDLY1); } while (++rxdly < 32); @@ -1487,7 +1410,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; @@ -1499,15 +1421,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 = sdr_read32(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 (sdr_read32(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; @@ -1529,7 +1452,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); @@ -1556,7 +1480,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 */ @@ -1565,7 +1490,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, host->base + MSDC_DAT_RDDLY0); } while (++rxdly < 32); done: @@ -1620,12 +1545,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; @@ -1717,8 +1640,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 = sdr_read32(SDC_CFG); + u32 val = readl(host->base + SDC_CFG); val &= ~SDC_CFG_BUSWIDTH; @@ -1736,7 +1658,7 @@ static void msdc_set_buswidth(struct msdc_host *host, u32 width) break; } - sdr_write32(SDC_CFG, val); + writel(val, host->base + SDC_CFG); N_MSG(CFG, "Bus Width = %d", width); } @@ -1745,7 +1667,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 @@ -1791,18 +1712,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 */ - 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, 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); } @@ -1812,13 +1738,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 = (sdr_read32(MSDC_PS) >> 31); + ro = (readl(host->base + MSDC_PS) >> 31); spin_unlock_irqrestore(&host->lock, flags); } return ro; @@ -1828,7 +1753,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; @@ -1852,10 +1776,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 = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1; + present = present ? 0 : 1; else - present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0; + present = present ? 1 : 0; host->card_inserted = present; #endif spin_unlock_irqrestore(&host->lock, flags); @@ -1882,17 +1807,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 = sdr_read32(MSDC_INT); - u32 inten = sdr_read32(MSDC_INTEN); inten &= intsts; + u32 intsts = readl(host->base + MSDC_INT); + u32 inten = readl(host->base + MSDC_INTEN); inten &= intsts; - sdr_write32(MSDC_INT, intsts); /* clear interrupts */ + writel(intsts, host->base + MSDC_INT); /* clear interrupts */ /* MSG will cause fatal error */ /* card change interrupt */ @@ -1920,18 +1844,18 @@ 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) { 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(host->base + 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 */ } } @@ -1946,14 +1870,16 @@ 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(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 = sdr_read32(SDC_ACMD_RESP); + *rsp = readl(host->base + SDC_ACMD_RESP); else - *rsp = sdr_read32(SDC_RESP0); + *rsp = readl(host->base + SDC_RESP0); break; } } else if ((intsts & MSDC_INT_RSPCRCERR) || (intsts & MSDC_INT_ACMDCRCERR)) { @@ -1969,7 +1895,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); @@ -1977,7 +1903,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, sdr_read32(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 { @@ -2017,7 +1944,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) { @@ -2026,9 +1952,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; } @@ -2044,17 +1970,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. @@ -2066,7 +1995,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 */ @@ -2077,41 +2005,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(); + 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, sdr_read32(MSDC_INTEN)); - sdr_write32(MSDC_INT, sdr_read32(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 */ - 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, 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 - sdr_write32(MSDC_PATCH_BIT0, 0x003C000F); /* 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 (sdr_read32(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 @@ -2120,40 +2058,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); @@ -2163,11 +2101,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, sdr_read32(MSDC_INTEN)); - sdr_write32(MSDC_INT, sdr_read32(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); @@ -2429,8 +2365,8 @@ 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); + 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); if (ret) { diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 17f2105ec698..b373d761312a 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -55,6 +55,7 @@ #include <linux/platform_device.h> #include <ralink_regs.h> +#include <mt7621.h> /* * 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 @@ -184,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); @@ -225,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); } @@ -270,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: @@ -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; diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 0c3e498ae99c..1e49a7b9e5fb 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 <[email protected]> */ @@ -54,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); @@ -65,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); @@ -81,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; @@ -94,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"); } @@ -127,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; @@ -173,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); @@ -181,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); @@ -198,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; @@ -243,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); @@ -383,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; @@ -404,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); diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index 37f299080410..d045b5568e0f 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; @@ -65,6 +66,7 @@ struct mt7621_spi { unsigned int sys_freq; unsigned int speed; struct clk *clk; + int pending_write; struct mt7621_spi_ops *ops; }; @@ -96,6 +98,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) @@ -104,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); @@ -137,36 +140,34 @@ 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)) { - 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; + switch (spi->mode & (SPI_CPOL | SPI_CPHA)) { + case SPI_MODE_0: + break; + case SPI_MODE_1: + reg |= MT7621_CPHA; + break; + case SPI_MODE_2: + reg |= MT7621_CPOL; + break; + case SPI_MODE_3: + reg |= MT7621_CPOL | MT7621_CPHA; + break; } mt7621_spi_write(rs, MT7621_SPI_MASTER, reg); return 0; } -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++) { 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); } @@ -174,90 +175,124 @@ static inline int mt7621_spi_wait_till_ready(struct spi_device *spi) return -ETIMEDOUT; } -static int mt7621_spi_transfer_half_duplex(struct spi_master *master, - struct spi_message *m) +static void mt7621_spi_read_half_duplex(struct mt7621_spi *rs, + int rx_len, u8 *buf) { - struct mt7621_spi *rs = spi_master_get_devdata(master); - struct spi_device *spi = m->spi; - unsigned int speed = spi->max_speed_hz; - struct spi_transfer *t = NULL; - int status = 0; - int i, len = 0; - int rx_len = 0; - u32 data[9] = { 0 }; - u32 val; + /* 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; - mt7621_spi_wait_till_ready(spi); + rs->pending_write = 0; - list_for_each_entry(t, &m->transfers, transfer_list) { - const u8 *buf = t->tx_buf; + while (rx_len || tx_len) { + int i; + u32 val = (min(tx_len, 4) * 8) << 24; + int rx = min(rx_len, 32); - if (t->rx_buf) - rx_len += t->len; + if (tx_len > 4) + val |= (tx_len - 4) * 8; + val |= (rx * 8) << 12; + mt7621_spi_write(rs, MT7621_SPI_MOREBUF, val); - if (!buf) - continue; + tx_len = 0; - if (t->speed_hz < speed) - speed = t->speed_hz; + val = mt7621_spi_read(rs, MT7621_SPI_TRANS); + val |= SPI_CTL_START; + mt7621_spi_write(rs, MT7621_SPI_TRANS, val); - if (WARN_ON(len + t->len > 36)) { - status = -EIO; - goto msg_done; - } + mt7621_spi_wait_till_ready(rs); - for (i = 0; i < t->len; i++, len++) - data[len / 4] |= buf[i] << (8 * (len & 3)); + 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; } +} - if (WARN_ON(rx_len > 32)) { - status = -EIO; - goto msg_done; - } +static inline void mt7621_spi_flush(struct mt7621_spi *rs) +{ + mt7621_spi_read_half_duplex(rs, 0, NULL); +} - if (mt7621_spi_prepare(spi, speed)) { - status = -EIO; - goto msg_done; +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); + } } - 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); + while (tx_len > 0) { + if (len >= 36) { + rs->pending_write = len; + mt7621_spi_flush(rs); + len = 0; + } - val = mt7621_spi_read(rs, MT7621_SPI_TRANS); - val |= SPI_CTL_START; - mt7621_spi_write(rs, MT7621_SPI_TRANS, val); + 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; +} - mt7621_spi_wait_till_ready(spi); +static int mt7621_spi_transfer_half_duplex(struct spi_master *master, + struct spi_message *m) +{ + struct mt7621_spi *rs = spi_master_get_devdata(master); + struct spi_device *spi = m->spi; + unsigned int speed = spi->max_speed_hz; + struct spi_transfer *t = NULL; + int status = 0; - mt7621_spi_set_cs(spi, 0); + mt7621_spi_wait_till_ready(rs); - for (i = 0; i < rx_len; i += 4) - data[i / 4] = mt7621_spi_read(rs, MT7621_SPI_DATA0 + i); + list_for_each_entry(t, &m->transfers, transfer_list) + if (t->speed_hz < speed) + speed = t->speed_hz; - m->actual_length = len + rx_len; + if (mt7621_spi_prepare(spi, speed)) { + status = -EIO; + goto msg_done; + } - len = 0; + mt7621_spi_set_cs(spi, 1); + m->actual_length = 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)); + 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); msg_done: m->status = status; spi_finalize_current_message(master); @@ -278,7 +313,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 +358,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); @@ -384,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; @@ -434,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); @@ -444,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); diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index b061f77dda41..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 * @@ -78,7 +79,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]; @@ -880,15 +880,13 @@ 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 */ 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; @@ -902,9 +900,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, @@ -960,19 +960,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; @@ -989,23 +979,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; } @@ -1175,6 +1153,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); @@ -1277,6 +1262,8 @@ device_create_failed: minor_failed: free_gpio(device); GPIO_failed: + kfree(device->rx_buffer); +RX_failed: kfree(device); return retval; @@ -1300,8 +1287,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; } 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 90280e9b006d..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 * @@ -111,27 +112,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 +141,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 +369,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 +411,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 +490,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 +704,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 +777,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]); } /*-------------------------------------------------------------------------*/ diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index c131ffbdc2db..319b86c14234 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 @@ -20,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); 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 diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 4140e37bf859..be1e8bf41e00 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_ @@ -314,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_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 72099f5d6915..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_ @@ -499,7 +491,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; 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..3ac3dd796ec9 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_ @@ -309,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); @@ -484,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 52ad085383a0..e47927b9c3b8 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 @@ -186,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) { @@ -334,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_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 <rtw_iol.h> 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 <drv_types.h> 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..f05658c9239e 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_ @@ -5456,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_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..79567cf470de 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_ @@ -44,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) @@ -106,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) @@ -201,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_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..5b8d7288a4e7 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_ @@ -193,7 +185,6 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) } } } - } int rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) @@ -1038,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_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 <rtw_sreset.h> 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..d16a7fa32a25 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_ @@ -41,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) @@ -1154,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) @@ -1393,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) 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 <[email protected]> * 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 <osdep_service.h> #include <drv_types.h> 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 <pwrseqcmd.h> 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 <osdep_service.h> 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 <osdep_service.h> 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 <linux/kmemleak.h> 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 <osdep_service.h> 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 <[email protected]> * 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 <linux/ieee80211.h> 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..deadf26ea2aa 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 <osdep_service.h> #include <drv_types.h> @@ -36,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) { @@ -77,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); @@ -137,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: @@ -145,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); } 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 <linux/module.h> 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_ diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index c466a5e7e3bd..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; } @@ -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, @@ -365,11 +365,11 @@ 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; - } 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, @@ -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); 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/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){ 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); } } /******************************************************************************************************************** diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 1b61a8de1edf..1dd4c6ae7319 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}; @@ -41,17 +44,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 +97,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 @@ -111,20 +117,19 @@ 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) + +/* + *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 PHT_CAPABILITY_ELE pCapELE; @@ -147,20 +152,19 @@ 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; - } -/******************************************************************************************************************** - *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 * 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 PHT_INFORMATION_ELE pHTInfoEle; @@ -210,12 +214,11 @@ 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; } /* -* 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; @@ -261,17 +264,15 @@ static bool IsHTHalfNmodeSGI(struct ieee80211_device *ieee, bool is40MHz) u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate) { - u8 is40MHz; u8 isShortGI; 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) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; @@ -280,17 +281,17 @@ 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)]; } -/******************************************************************************************************************** +/* *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; @@ -322,16 +323,15 @@ 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]; } } - - 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) || @@ -353,32 +353,33 @@ 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; struct ieee80211_network *net = &ieee->current_network; + if (net->bssht.bdRT2RTAggregation) pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; 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; @@ -389,32 +390,34 @@ 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. + +/* + *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; @@ -440,18 +443,19 @@ 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) { @@ -461,25 +465,27 @@ 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) - * *****************************************************************************************************************/ + * 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 +/* + *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; @@ -496,6 +502,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)) @@ -504,52 +511,48 @@ 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; } - -/******************************************************************************************************************** +/* *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. - * *****************************************************************************************************************/ + */ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 IsEncrypt) { PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; 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; } 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]); + 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)) { + 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; @@ -557,7 +560,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!! @@ -566,9 +569,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) { @@ -590,10 +594,13 @@ 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; + for (i = 1; i < 16; i++) pCapELE->MCS[i] = 0; } @@ -601,7 +608,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,30 +619,32 @@ 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 + /* + * 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 + +/* + *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) { 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; } @@ -661,48 +669,46 @@ 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; } //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_HT, posHTInfo, *len - 2); //HTDebugHTInfo(posHTInfo, "HTConstructInforElement"); - return; } /* - * 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 - * u8* len //store len + * u8* posRT2RTAgg //pointer to store Information Ele + * u8* len //store len * output: none * return: none * notice: - * *****************************************************************************************************************/ + */ 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; } @@ -714,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; @@ -727,37 +732,32 @@ 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; } */ - #else // Do Nothing #endif posRT2RTAgg->Length = 6; #endif - - - - } - -/******************************************************************************************************************** +/* *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: - * *****************************************************************************************************************/ + */ 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; } @@ -766,61 +766,60 @@ 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(). - - //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; + // 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; //should never reach here default: - - break; - + break; } return true; } /* -* 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; u8 bitMap; 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; } @@ -838,59 +837,56 @@ 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); } - - /* -** -**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) { - u8 i = 0; // 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]; - } - + 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 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 signal 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; return true; } + void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); void HTOnAssocRsp(struct ieee80211_device *ieee) { @@ -924,11 +920,10 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) else pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf); - //////////////////////////////////////////////////////// // 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 // @@ -936,31 +931,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; @@ -969,26 +966,26 @@ 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) 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 + /* + * 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 @@ -1003,8 +1000,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 @@ -1026,22 +1025,25 @@ 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; @@ -1052,31 +1054,30 @@ 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 -********************************************************************************************************************/ + * 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; @@ -1089,10 +1090,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 @@ -1103,13 +1106,11 @@ 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)); - 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; @@ -1125,22 +1126,23 @@ 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 RegHTSuppRateSets[4] = 0x01; //support MCS 32 } } -/******************************************************************************************************************** + +/* *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; memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf)); pBssHT->bdHTCapLen = 0; @@ -1152,14 +1154,16 @@ void HTInitializeBssDesc(PBSS_HT pBssHT) pBssHT->bdRT2RTAggregation = false; 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 + * 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; @@ -1198,8 +1202,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) @@ -1213,7 +1219,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 +1230,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 +1237,6 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802 pHTInfo->IOTAction = 0; } - } void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork) @@ -1244,27 +1246,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; - // - // <TODO: Config according to OBSS non-HT STA present!!> - // + /* + * <TODO: Config according to OBSS non-HT STA present!!> + */ } } 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) { @@ -1276,9 +1278,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; @@ -1287,8 +1289,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)) @@ -1318,10 +1318,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); @@ -1335,9 +1337,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); 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 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; diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c index bbf6f3fa21ea..c306ad7e395c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_efuse.c +++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c @@ -12,28 +12,25 @@ #include <linux/jiffies.h> -/*------------------------Define local variable------------------------------*/ -u8 fakeEfuseBank = 0; -u32 fakeEfuseUsedBytes = 0; +/* Define global variables */ +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}; -/*------------------------Define local variable------------------------------*/ -/* */ #define REG_EFUSE_CTRL 0x0030 #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ -/* */ bool Efuse_Read1ByteFromFakeContent( diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 0822e440204e..8e0025e1ff14 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]; @@ -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]; @@ -1163,38 +1144,24 @@ 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 */ - 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]); - } - memcpy(mac_addr, mac, ETH_ALEN); - } else{ /* Use the mac address stored in the Efuse */ - memcpy(mac, mac_addr, ETH_ALEN); + 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 */ + 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] == 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); + ether_addr_copy(mac_addr, addr); } 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"); } } 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 }, 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/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 */ diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 3922d0308a81..0d2c61b67d0e 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1612,202 +1612,201 @@ 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 -) +static s16 get_bandwidth_idx(const enum CHANNEL_WIDTH bandwidth) { - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - s16 band = -1, regulation = -1, bandwidth = -1, rateSection = -1, channel = -1; - s8 powerLimit = MAX_POWER_INDEX; - - 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; - case 2: - regulation = TXPWR_LMT_MKK; - break; - case 3: - regulation = TXPWR_LMT_FCC; - break; - - case 4: - regulation = TXPWR_LMT_WW; - break; - + 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: - regulation = (Band == BAND_ON_2_4G) ? pHalData->Regulation2_4G : pHalData->Regulation5G; - break; + return -1; } +} - /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", Adapter->registrypriv.RegPwrTblSel, regulation); */ - - - if (Band == BAND_ON_2_4G) - band = 0; - else if (Band == BAND_ON_5G) - 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; - - switch (DataRate) { +static s16 get_rate_sctn_idx(const u8 rate) +{ + switch (rate) { case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M: - rateSection = 0; - break; - + 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: - rateSection = 1; - break; - + 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: - rateSection = 2; - break; - + 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: - rateSection = 3; - break; - + 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: - rateSection = 4; - break; - + 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: - rateSection = 5; - break; - + 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: - rateSection = 6; - break; - + 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: - rateSection = 7; - break; - + 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: - rateSection = 8; - break; - + 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: - rateSection = 9; - break; + 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) +{ + 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) && + (hal_data->EEPROMRegulatory != 1)) || + (adapter->registrypriv.RegEnableTxPowerLimit == 0)) + return MAX_POWER_INDEX; + switch (adapter->registrypriv.RegPwrTblSel) { + case 1: + idx_regulation = TXPWR_LMT_ETSI; + break; + case 2: + idx_regulation = TXPWR_LMT_MKK; + break; + case 3: + idx_regulation = TXPWR_LMT_FCC; + break; + case 4: + idx_regulation = TXPWR_LMT_WW; + break; default: - DBG_871X("Wrong rate 0x%x\n", DataRate); + idx_regulation = (band_type == BAND_ON_2_4G) ? + hal_data->Regulation2_4G : + hal_data->Regulation5G; break; } - if (Band == BAND_ON_5G && rateSection == 0) - DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate); + /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", */ + /* adapter->registrypriv.RegPwrTblSel, idx_regulation); */ - /* workaround for wrong index combination to obtain tx power limit, */ - /* OFDM only exists in BW 20M */ - if (rateSection == 1) - bandwidth = 0; + if (band_type == BAND_ON_2_4G) + idx_band = 0; + else if (band_type == BAND_ON_5G) + idx_band = 1; + + 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) + 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 */ /* CCK table will only be given in BW 20M */ - if (rateSection == 0) - 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 == 0 || idx_rate_sctn == 1) + idx_bandwidth = 0; + else 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) - channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, Channel); - else if (Band == BAND_ON_5G) - channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, Channel); - else if (Band == BAND_ON_BOTH) { - /* BAND_ON_BOTH don't care temporarily */ - } + if (band_type == BAND_ON_2_4G || band_type == BAND_ON_5G) + channel = phy_GetChannelIndexOfTxPowerLimit(band_type, channel); - 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]; - - powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : - pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channel][RfPath]; - - } else if (Band == BAND_ON_5G) { + limits[i] = hal_data->TxPwrLimit_2_4G[i] + [idx_bandwidth] + [idx_rate_sctn] + [idx_channel] + [rf_path]; + + pwr_lmt = (idx_regulation == TXPWR_LMT_WW) ? + phy_GetWorldWideLimit(limits) : + hal_data->TxPwrLimit_2_4G[idx_regulation] + [idx_bandwidth] + [idx_rate_sctn] + [idx_channel] + [rf_path]; + + } 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]; - - powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : - pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channel][RfPath]; - } else + limits[i] = hal_data->TxPwrLimit_5G[i] + [idx_bandwidth] + [idx_rate_sctn] + [idx_channel] + [rf_path]; + + pwr_lmt = (idx_regulation == TXPWR_LMT_WW) ? + phy_GetWorldWideLimit(limits) : + 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) @@ -3294,4 +3293,3 @@ void phy_free_filebuf(struct adapter *padapter) vfree(pHalData->rf_tx_pwr_lmt); } - 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, 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/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 02178e25fbb8..af2234798fa8 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)); @@ -1273,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; } @@ -3013,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/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 39502156f652..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}; @@ -313,7 +310,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 +442,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; 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) { 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; 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; 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: 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 * 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.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; } 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 <linux/kernel.h> -#include <linux/string.h> - -#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 <http://www.gnu.org/licenses/>. - * - * Author: - * Wei WANG ([email protected]) - * Micky Ching ([email protected]) - */ - -#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; } 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); } 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; 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 { 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 diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0aaae33f97b9..52c0c1066375 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 @@ -145,6 +110,7 @@ struct set_ip_addr { }; struct sta_inactive_t { + u32 inactive_time; u8 mac[6]; }; @@ -180,10 +146,12 @@ union message_body { }; struct host_if_msg { - u16 id; union message_body body; 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 { @@ -219,9 +187,7 @@ 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 completion hif_wait_response; static struct mutex hif_deinit_lock; static struct timer_list periodic_rssi; static struct wilc_vif *periodic_rssi_vif; @@ -230,33 +196,42 @@ 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 inactive_time; 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 - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -static int wilc_enqueue_cmd(struct host_if_msg *msg) +/* '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 *), + bool is_sync) { - struct host_if_msg *new_msg; + struct host_if_msg *msg; - new_msg = kmemdup(msg, sizeof(*new_msg), GFP_ATOMIC); - if (!new_msg) - return -ENOMEM; + 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; + msg->is_sync = is_sync; + if (is_sync) + init_completion(&msg->work_comp); + + return 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)) + return -EINVAL; - INIT_WORK(&new_msg->work, host_if_work); - queue_work(hif_workqueue, &new_msg->work); return 0; } @@ -284,9 +259,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 +277,27 @@ static void handle_set_channel(struct wilc_vif *vif, if (ret) netdev_err(vif->ndev, "Failed to set channel\n"); + kfree(msg); } -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 +317,21 @@ 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); } -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 +348,15 @@ static void handle_set_operation_mode(struct wilc_vif *vif, if (ret) netdev_err(vif->ndev, "Failed to set driver handler\n"); + kfree(msg); } -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 +378,14 @@ 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); } -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 +406,14 @@ 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); } -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; @@ -437,11 +427,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); + complete(&msg->work_comp); + /* free 'msg' data later, in caller */ } -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 +724,14 @@ static void handle_cfg_param(struct wilc_vif *vif, struct cfg_param_attr *param) unlock: mutex_unlock(&hif_drv->cfg_values_lock); + kfree(msg); } -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 +841,7 @@ error: kfree(hdn_ntwk_wid_val); - return result; + kfree(msg); } static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt) @@ -885,9 +883,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 +895,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_work(msg); + if (result) + goto error; + + usleep_range(2 * 1000, 2 * 1000); + 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 +1146,13 @@ error: conn_attr->ies = NULL; kfree(cur_byte); - return result; + kfree(msg); } -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 +1161,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 +1180,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 +1216,17 @@ static s32 handle_connect_timeout(struct wilc_vif *vif) eth_zero_addr(wilc_connected_ssid); - return result; +out: + kfree(msg); } -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 +1240,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 +1285,7 @@ done: kfree(info); } - return result; + kfree(msg); } static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, @@ -1411,24 +1422,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 +1446,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 +1470,12 @@ 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); } static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) @@ -1504,8 +1512,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]; @@ -1539,8 +1550,6 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) 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; @@ -1561,7 +1570,6 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) 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; @@ -1593,7 +1601,7 @@ static int handle_key(struct wilc_vif *vif, struct key_attr *hif_key) wilc_get_vif_idx(vif)); } out_wep: - complete(&hif_drv->comp_test_key_block); + complete(&msg->work_comp); break; case WPA_RX_GTK: @@ -1657,9 +1665,7 @@ out_wep: kfree(key_buf); } out_wpa_rx_gtk: - complete(&hif_drv->comp_test_key_block); - kfree(hif_key->attr.wpa.key); - kfree(hif_key->attr.wpa.seq); + complete(&msg->work_comp); break; case WPA_PTK: @@ -1714,23 +1720,26 @@ out_wpa_rx_gtk: } out_wpa_ptk: - complete(&hif_drv->comp_test_key_block); - kfree(hif_key->attr.wpa.key); + complete(&msg->work_comp); 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"); - return result; + /* free 'msg' data in caller sync call */ } -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; @@ -1797,7 +1806,8 @@ static void handle_disconnect(struct wilc_vif *vif) out: - complete(&hif_drv->comp_test_disconn_block); + complete(&msg->work_comp); + /* free 'msg' in caller after receiving completion */ } void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) @@ -1809,31 +1819,34 @@ 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; 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, 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); + complete(&msg->work_comp); + /* free 'msg' data in caller */ } -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; @@ -1878,24 +1891,27 @@ static s32 handle_get_statistics(struct wilc_vif *vif, else if (stats->link_speed != DEFAULT_LINK_SPEED) wilc_enable_tcp_ack_filter(false); - if (stats != &vif->wilc->dummy_statistics) - complete(&hif_wait_response); - return 0; + /* free 'msg' for async command, for sync caller will free it */ + if (msg->is_sync) + complete(&msg->work_comp); + else + kfree(msg); } -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; wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME; wid.type = WID_STR; 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,29 +1921,30 @@ 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; 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, wilc_get_vif_idx(vif)); - if (result) { + if (result) netdev_err(vif->ndev, "Failed to get inactive time\n"); - return -EFAULT; - } - complete(&hif_drv->comp_inactive_time); - - return result; +out: + /* free 'msg' data in caller */ + complete(&msg->work_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 +1993,13 @@ error: kfree(wid.val); kfree(param->head); kfree(param->tail); + kfree(msg); } -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 +2013,7 @@ 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); } static u32 wilc_hif_pack_sta_param(u8 *buff, struct add_sta_param *param) @@ -2025,9 +2046,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 +2074,14 @@ static void handle_add_station(struct wilc_vif *vif, error: kfree(param->rates); kfree(wid.val); + kfree(msg); } -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; @@ -2091,11 +2117,15 @@ static void handle_del_all_sta(struct wilc_vif *vif, error: kfree(wid.val); - complete(&hif_wait_response); + /* free 'msg' data in caller */ + complete(&msg->work_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 +2146,14 @@ static void handle_del_station(struct wilc_vif *vif, struct del_sta *param) error: kfree(wid.val); + kfree(msg); } -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 +2177,7 @@ static void handle_edit_station(struct wilc_vif *vif, error: kfree(param->rates); kfree(wid.val); + kfree(msg); } static int handle_remain_on_chan(struct wilc_vif *vif, @@ -2213,9 +2247,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 +2260,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 +2273,18 @@ 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); } -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 +2298,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 +2308,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 +2318,10 @@ 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); } static void listen_timer_cb(struct timer_list *t) @@ -2293,23 +2330,28 @@ 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.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; - 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, false); + 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_work(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } } -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 +2370,14 @@ 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); } -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 +2411,14 @@ static void handle_set_mcast_filter(struct wilc_vif *vif, error: kfree(wid.val); + kfree(msg); } -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 +2431,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); } -static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr) +/* Note: 'msg' will be free after using data */ +static void handle_get_tx_pwr(struct work_struct *work) { + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + u8 *tx_pwr = &msg->body.tx_power.tx_pwr; int ret = 0; struct wid wid; @@ -2399,190 +2453,64 @@ static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr) if (ret) netdev_err(vif->ndev, "Failed to get TX PWR\n"); - complete(&hif_wait_response); + complete(&msg->work_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; - - msg = container_of(work, struct host_if_msg, work); - wilc = msg->vif->wilc; - - 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; - - case HOST_IF_MSG_CONNECT: - handle_connect(msg->vif, &msg->body.con_info); - break; - - case HOST_IF_MSG_RCVD_NTWRK_INFO: - handle_rcvd_ntwrk_info(msg->vif, &msg->body.net_info); - break; - - case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: - handle_rcvd_gnrl_async_info(msg->vif, - &msg->body.async_info); - break; - - case HOST_IF_MSG_KEY: - handle_key(msg->vif, &msg->body.key_info); - break; - - case HOST_IF_MSG_CFG_PARAMS: - handle_cfg_param(msg->vif, &msg->body.cfg_info); - break; - - case HOST_IF_MSG_SET_CHANNEL: - handle_set_channel(msg->vif, &msg->body.channel_info); - break; - - case HOST_IF_MSG_DISCONNECT: - handle_disconnect(msg->vif); - break; - - 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; + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - 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; + handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); + kfree(msg); +} - case HOST_IF_MSG_SCAN_TIMER_FIRED: - handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); - 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_TIMER_FIRED: - handle_connect_timeout(msg->vif); - break; + handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch); + kfree(msg); +} - case HOST_IF_MSG_POWER_MGMT: - handle_power_management(msg->vif, - &msg->body.pwr_mgmt_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_SET_WFIDRV_HANDLER: - ret = handle_set_wfi_drv_handler(msg->vif, &msg->body.drv); - break; + /* free 'msg' data in caller */ + complete(&msg->work_comp); +} - case HOST_IF_MSG_SET_OPERATION_MODE: - handle_set_operation_mode(msg->vif, &msg->body.mode); - 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_SET_IPADDRESS: - handle_set_ip_address(msg->vif, - msg->body.ip_info.ip_addr, - msg->body.ip_info.idx); - break; + del_timer(&msg->vif->hif_drv->scan_timer); - case HOST_IF_MSG_GET_IPADDRESS: - handle_get_ip_address(msg->vif, msg->body.ip_info.idx); - break; + if (!wilc_wlan_get_num_conn_ifcs(wilc)) + wilc_chip_sleep_manually(wilc); - case HOST_IF_MSG_GET_MAC_ADDRESS: - handle_get_mac_address(msg->vif, - &msg->body.get_mac_info); - break; + handle_scan_done(msg->vif, SCAN_EVENT_DONE); - 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); } 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.id = HOST_IF_MSG_SCAN_TIMER_FIRED; + msg = wilc_alloc_work(vif, handle_scan_timer, false); + if (IS_ERR(msg)) + return; - wilc_enqueue_cmd(&msg); + result = wilc_enqueue_work(msg); + if (result) + kfree(msg); } static void timer_connect_cb(struct timer_list *t) @@ -2590,19 +2518,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.id = HOST_IF_MSG_CONNECT_TIMER_FIRED; + msg = wilc_alloc_work(vif, handle_connect_timeout, false); + if (IS_ERR(msg)) + return; - wilc_enqueue_cmd(&msg); + result = wilc_enqueue_work(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) { @@ -2611,27 +2542,28 @@ 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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Request to remove WEP key\n"); else - wait_for_completion(&hif_drv->comp_test_key_block); + wait_for_completion(&msg->work_comp); + kfree(msg); return result; } 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) { @@ -2640,20 +2572,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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Default key index\n"); else - wait_for_completion(&hif_drv->comp_test_key_block); + wait_for_completion(&msg->work_comp); + kfree(msg); return result; } @@ -2661,7 +2594,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) { @@ -2669,35 +2602,40 @@ 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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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.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; + 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; - } + result = wilc_enqueue_work(msg); + if (result) + goto free_key; - wait_for_completion(&hif_drv->comp_test_key_block); - return 0; + wait_for_completion(&msg->work_comp); + +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) { @@ -2705,30 +2643,35 @@ 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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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.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; + 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; - } + result = wilc_enqueue_work(msg); + if (result) + goto free_key; - wait_for_completion(&hif_drv->comp_test_key_block); - return 0; + wait_for_completion(&msg->work_comp); + +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, @@ -2736,7 +2679,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; @@ -2751,43 +2694,50 @@ 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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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_work(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; + wait_for_completion(&msg->work_comp); + +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, @@ -2796,7 +2746,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; @@ -2804,7 +2754,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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); if (rx_mic) key_len += RX_MIC_KEY_LEN; @@ -2813,80 +2766,87 @@ 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.id = HOST_IF_MSG_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_work(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; + wait_for_completion(&msg->work_comp); + +free_key: + kfree(msg->body.key_info.attr.wpa.key); + +free_seq: + kfree(msg->body.key_info.attr.wpa.seq); + +free_msg: + kfree(msg); + return result; } int wilc_set_pmkid_info(struct wilc_vif *vif, struct host_if_pmkid_attr *pmkid) { int 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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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_work(msg); + if (result) { netdev_err(vif->ndev, "PMKID Info\n"); + kfree(msg); + } return result; } @@ -2894,21 +2854,22 @@ 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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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); - if (result) { + result = wilc_enqueue_work(msg); + if (result) netdev_err(vif->ndev, "Failed to send get mac address\n"); - return -EFAULT; - } + else + wait_for_completion(&msg->work_comp); + + kfree(msg); - wait_for_completion(&hif_wait_response); return result; } @@ -2919,7 +2880,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) { @@ -2932,57 +2893,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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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_work(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) { @@ -2990,17 +2969,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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_DISCONNECT; - msg.vif = vif; - - result = wilc_enqueue_cmd(&msg); + result = wilc_enqueue_work(msg); if (result) netdev_err(vif->ndev, "Failed to send message: disconnect\n"); else - wait_for_completion(&hif_drv->comp_test_disconn_block); + wait_for_completion(&msg->work_comp); + kfree(msg); return result; } @@ -3032,39 +3011,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; + + msg = wilc_alloc_work(vif, handle_set_channel, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_SET_CHANNEL; - msg.body.channel_info.set_ch = channel; - msg.vif = vif; + 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"); - 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.id = HOST_IF_MSG_SET_WFIDRV_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, false); + 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_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); - result = -EINVAL; + kfree(msg); } return result; @@ -3073,17 +3054,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.id = HOST_IF_MSG_SET_OPERATION_MODE; - msg.body.mode.mode = mode; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_set_operation_mode, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); + msg->body.mode.mode = mode; + result = wilc_enqueue_work(msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); - result = -EINVAL; + kfree(msg); } return result; @@ -3093,7 +3074,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) { @@ -3101,19 +3082,20 @@ 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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_GET_INACTIVETIME; - msg.vif = vif; + 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 - wait_for_completion(&hif_drv->comp_inactive_time); + wait_for_completion(&msg->work_comp); - *out_val = inactive_time; + *out_val = msg->body.mac_info.inactive_time; + kfree(msg); return result; } @@ -3121,49 +3103,61 @@ 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_drv *hif_drv = vif->hif_drv; - - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_GET_RSSI; - msg.vif = vif; + struct host_if_msg *msg; - result = wilc_enqueue_cmd(&msg); - if (result) { - netdev_err(vif->ndev, "Failed to send get host ch param\n"); + if (!rssi_level) { + netdev_err(vif->ndev, "RSS pointer value is null\n"); return -EFAULT; } - wait_for_completion(&hif_drv->comp_get_rssi); + msg = wilc_alloc_work(vif, handle_get_rssi, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - if (!rssi_level) { - netdev_err(vif->ndev, "RSS pointer value is null\n"); - return -EFAULT; + 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 = *msg->body.data; } - *rssi_level = rssi; + kfree(msg->body.data); + 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; + struct host_if_msg *msg; + + msg = wilc_alloc_work(vif, handle_get_statistics, is_sync); + if (IS_ERR(msg)) + return PTR_ERR(msg); - memset(&msg, 0, sizeof(struct host_if_msg)); - msg.id = HOST_IF_MSG_GET_STATISTICS; - msg.body.data = (char *)stats; - msg.vif = vif; + 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"); - return -EFAULT; + kfree(msg); + return result; + } + + if (is_sync) { + wait_for_completion(&msg->work_comp); + kfree(msg); } - if (stats != &vif->wilc->dummy_statistics) - wait_for_completion(&hif_wait_response); return result; } @@ -3173,8 +3167,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) { @@ -3182,16 +3176,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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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; @@ -3201,44 +3196,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_work(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.id = HOST_IF_MSG_CFG_PARAMS; - msg.body.cfg_info = *cfg_param; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_cfg_param, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - return wilc_enqueue_cmd(&msg); + msg->body.cfg_info = *cfg_param; + result = wilc_enqueue_work(msg); + if (result) + kfree(msg); + + return result; } static void get_periodic_rssi(struct timer_list *unused) @@ -3251,7 +3265,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)); } @@ -3266,8 +3280,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; @@ -3283,16 +3295,10 @@ 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); } - 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) { @@ -3332,7 +3338,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) { @@ -3361,18 +3366,19 @@ 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.id = HOST_IF_MSG_EXIT; - msg.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_cmd(&msg); - if (result != 0) + result = wilc_enqueue_work(msg); + 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); } @@ -3387,7 +3393,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; @@ -3406,27 +3412,29 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - memset(&msg, 0, sizeof(struct host_if_msg)); - - msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info, false); + if (IS_ERR(msg)) + return; - msg.body.net_info.len = length; - msg.body.net_info.buffer = kmemdup(buffer, length, GFP_KERNEL); - if (!msg.body.net_info.buffer) + 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); + result = wilc_enqueue_work(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; @@ -3456,22 +3464,25 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) return; } - memset(&msg, 0, sizeof(struct host_if_msg)); - - msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false); + if (IS_ERR(msg)) { + mutex_unlock(&hif_deinit_lock); + return; + } - msg.body.async_info.len = length; - msg.body.async_info.buffer = kmemdup(buffer, length, GFP_KERNEL); - if (!msg.body.async_info.buffer) { + 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); + result = wilc_enqueue_work(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); @@ -3480,7 +3491,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; @@ -3498,14 +3508,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.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_scan_complete, false); + if (IS_ERR(msg)) + return; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_work(msg); + if (result) { netdev_err(vif->ndev, "complete param (%d)\n", result); + kfree(msg); + } } } @@ -3516,22 +3529,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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_REMAIN_ON_CHAN; - 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_work(msg); + if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); + kfree(msg); + } return result; } @@ -3539,7 +3554,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) { @@ -3549,14 +3564,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.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; - msg.vif = vif; - msg.body.remain_on_ch.id = session_id; + msg = wilc_alloc_work(vif, handle_listen_state_expired, false); + 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_work(msg); + if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); + kfree(msg); + } return result; } @@ -3564,30 +3582,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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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_work(msg); + if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); + kfree(msg); + } return result; } @@ -3596,13 +3616,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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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; @@ -3623,15 +3644,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_work(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; @@ -3640,14 +3661,17 @@ error: int wilc_del_beacon(struct wilc_vif *vif) { int result = 0; - struct host_if_msg msg; + struct host_if_msg *msg; - msg.id = HOST_IF_MSG_DEL_BEACON; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_del_beacon, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_work(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3655,27 +3679,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; - - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; + struct add_sta_param *add_sta_info; - msg.id = HOST_IF_MSG_ADD_STATION; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_add_station, false); + 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_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(add_sta_info->rates); + kfree(msg); } return result; } @@ -3683,38 +3710,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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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_work(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, true); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_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)) { @@ -3723,16 +3754,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_work(msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); else - wait_for_completion(&hif_wait_response); + wait_for_completion(&msg->work_comp); + + kfree(msg); return result; } @@ -3741,27 +3776,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; - - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; + struct add_sta_param *add_sta_info; - msg.id = HOST_IF_MSG_EDIT_STATION; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_edit_station, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - 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_work(msg); if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); kfree(add_sta_info->rates); + kfree(msg); } return result; @@ -3770,23 +3808,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.id = HOST_IF_MSG_POWER_MGMT; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_power_management, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - pwr_mgmt_info->enabled = enabled; - pwr_mgmt_info->timeout = timeout; + msg->body.pwr_mgmt_info.enabled = enabled; + msg->body.pwr_mgmt_info.timeout = timeout; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_work(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3794,20 +3832,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; - - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; - msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER; - msg.vif = vif; + msg = wilc_alloc_work(vif, handle_set_mcast_filter, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - multicast_filter_param->enabled = enabled; - multicast_filter_param->cnt = count; + msg->body.multicast_info.enabled = enabled; + msg->body.multicast_info.cnt = count; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_work(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3979,19 +4017,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; - - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; - msg.id = HOST_IF_MSG_SET_IPADDRESS; + msg = wilc_alloc_work(vif, handle_set_ip_address, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.body.ip_info.ip_addr = ip_addr; - msg.vif = vif; - msg.body.ip_info.idx = idx; + msg->body.ip_info.ip_addr = ip_addr; + msg->body.ip_info.idx = idx; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_work(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -3999,19 +4038,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; - - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; - msg.id = HOST_IF_MSG_GET_IPADDRESS; + msg = wilc_alloc_work(vif, handle_get_ip_address, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.body.ip_info.ip_addr = ip_addr; - msg.vif = vif; - msg.body.ip_info.idx = idx; + msg->body.ip_info.ip_addr = ip_addr; + msg->body.ip_info.idx = idx; - result = wilc_enqueue_cmd(&msg); - if (result) + result = wilc_enqueue_work(msg); + if (result) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return result; } @@ -4019,17 +4059,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, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); - msg.id = HOST_IF_MSG_SET_TX_POWER; - 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_work(msg); + if (ret) { netdev_err(vif->ndev, "wilc_mq_send fail\n"); + kfree(msg); + } return ret; } @@ -4037,19 +4079,21 @@ 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; - - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; - msg.id = HOST_IF_MSG_GET_TX_POWER; - msg.vif = vif; + 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) + ret = wilc_enqueue_work(msg); + if (ret) { netdev_err(vif->ndev, "Failed to get TX PWR\n"); + } 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/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 02e6b1338440..0019bb8df6c1 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1118,6 +1118,8 @@ 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); + INIT_LIST_HEAD(&wl->rxq_head.list); register_inetaddr_notifier(&g_dev_notifier); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index e248702ee519..e96163f38e7b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1141,20 +1141,20 @@ 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; } 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) | - 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/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index f2b07e8aedd7..fe18ae9843db 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -155,16 +155,11 @@ struct wilc { u32 rx_buffer_offset; u8 *tx_buffer; - 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; - struct rxq_entry_t *rxq_head; - struct rxq_entry_t *rxq_tail; - int rxq_entries; + struct rxq_entry_t rxq_head; 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 d4ebbf67e50b..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 <linux/if_ether.h> +#include <linux/ip.h> #include "wilc_wfi_netdevice.h" #include "wilc_wlan_cfg.h" @@ -20,25 +22,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 +38,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 +61,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 +79,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); @@ -184,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; @@ -197,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; - - ip_hdr_ptr = &buffer[ETHERNET_HDR_LEN]; - protocol = ip_hdr_ptr[9]; + if (eth_hdr_ptr->h_proto == htons(ETH_P_IP)) { + const struct iphdr *ip_hdr_ptr = buffer + ETH_HLEN; - 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; @@ -253,11 +206,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; @@ -295,7 +249,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, @@ -402,12 +356,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,45 +377,37 @@ 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; } -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); - 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; - } - wilc->rxq_entries += 1; + list_add_tail(&rqe->list, &wilc->rxq_head.list); mutex_unlock(&wilc->rxq_cs); - return wilc->rxq_entries; } static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) { - if (wilc->rxq_head) { - struct rxq_entry_t *rqe; - - mutex_lock(&wilc->rxq_cs); - rqe = wilc->rxq_head; - wilc->rxq_head = wilc->rxq_head->next; - wilc->rxq_entries -= 1; - mutex_unlock(&wilc->rxq_cs); - return rqe; + struct rxq_entry_t *rqe = NULL; + + 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); } - 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 a5b9c68e1b9c..dbdebf009024 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; @@ -219,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; }; diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 42912257e2b9..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, @@ -282,9 +268,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; 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: diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index d7de9e9c47a2..ebfe69b138c7 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 @@ -428,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 = \ @@ -447,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; \ 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, 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 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; |